Hello, I'm trying to write a program that will solve wordsearches. Right now, I'm running into a problem where I cannot pass an array as a parameter, even though it seems like I've followed the tutorial perfectly. (http://cplusplus.com/doc/tutorial/arrays/)
The specific error I'm getting is:
prog.cpp: In function ‘void print_word_search(char*)’:
prog.cpp:15: warning: array subscript has type ‘char’
prog.cpp:15: error: invalid types ‘char[char]’ for array subscript
prog.cpp: In function ‘int main()’:
prog.cpp:34: warning: array subscript has type ‘char’
prog.cpp:34: warning: array subscript has type ‘char’
prog.cpp:39: error: cannot convert ‘char (*)[5][5]’ to ‘char*’ for argument ‘1’ to ‘void print_word_search(char*)’
Strange...I made the changes you asked, but when I ran it on IDEone, there wasn't any output; not even "Please enter each letter"...as if "cout" was broken. Note that it was still taking input, so it wasn't a compile error. However, when I removed "print_word_search(&word_search[WIDTH][HEIGHT]);" it did give me output. When I tried to run it on codepad.org, it just flat out gave me a compile error. Unfortunately, I'm not at home right now, so I don't have access to a "real" compiler at the moment, so I'll have to get back to you with the results of that later.
Anyhow, I trust that you made the correct changes. Can you please explain what changes you made and why you made them? That will help me learn :P
for (char x = 0; x < WIDTH; x++){
for(char y = 0; y < HEIGHT; y++){
cout << w_search<<x<<y<<endl;
//output the variable for x & y.
}
cout << endl;
}
print_word_search(&word_search[WIDTH][HEIGHT]);//this calls the functions. You can also have [x][y], as you said char word_search[WIDTH][HEIGHT] you would have to the same for print_word_search(&word_search) as you are not calling nothing.
The output I got when I wrote Facebook,Google,Youtube and Yahoo was into a different font or somewhat. You should try and download visual studio it would be much better for you. I try it on xCode and it came up with
Please enter each letter in the word search. Sorry for the tedium:(
but not with the other stuff I got with visual studio after entering all the same word. Sorry about the explain.