Hey guys, I am getting a megaton of errors in this code segment and I cannot figure it out. I will just link the segment of code with the errors as well as the error list. Thanks. These segment of code is used to selecting a random word from char words 2D array (We have to use a 2D array) and then storing it in secretword.
warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data. Line 39 Column 1
warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS Line 42 Column 1
error C2109: subscript requires array or pointer type Line 43 Column 1
error C2109: subscript requires array or pointer type Line 51 Column 1
error C2664: 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::get(_Elem &)' : cannot convert parameter 1 from 'int' to 'char Line 52 Column 1
error C2065: 'i' : undeclared identifier Line 78 column 1
error C2143: syntax error : missing ')' before ';' Line 78 column 1
error C1903: unable to recover from previous error(s); stopping compilation Line 78 1
IntelliSense: expression must have pointer-to-object type Line 43 column 38
IntelliSense: expression must have pointer-to-object type Line 51 column 29
IntelliSense: no instance of overloaded function "std::basic_istream<_Elem, _Traits>::get [with _Elem=char, _Traits=std::char_traits<char>]" matches the argument list
argument types are: (int) No line or column
Part of the error is the way you are bracing your code I believe. The brace at line 35, what is it there for? Line 53, you return 0. Your program ends there. Nothing after that will run in your program. Also, the while at line 78 has no braces except at the end at line 86 (which I think is supposed to be the close brace for main(). It's hard to tell though with your indentation/bracing style.) Also, the if inside the while has no braces at all. Any block of code inside any kind of loop must be enclosed by braces if it contains more then 1 statement.
There are a bunch of errors inside the while itself. First, the test expression for a while loop can only contain 1 statement or expression. What you wrote looks like it belongs in a regular for loop. While loops should only have a test expression in the parentheses. And loops do not require semi-colons after the parentheses. This mistake also applies to the if loop. Finally, inside the if, you are trying to index a char variable. Only arrays (and certain other containers) can be indexed like that. And last, line 84 is comparing displayword to the length of secretword[i]. This is simply wrong for several reasons, first being like I said before, you are trying to index a variable, not an array. Second being the length of a char variable is 1 since it can only hold 1 character. Third, comparing the two does nothing in this context (like it does in the test expression of the if loop.)