0

It seems like such a simple problem but its happened to me in previous psets and i cant seem to figure it out. I've run update50 and I've included all the header libraries--I have no clue why the variables are not being recognised. I copied the argv0 program during lecture 2 and had no problems running it but when I add string s variable to the program, it has a nervous breakdown. This is not the first program or problem set where this has happened. Any help would be greatly appreciated.

Code:

int main (int argc, string argv[]) {

printf("Enter a message you want encrypted\n");
string plain = get_string();

}

This is the error message in the terminal:

Caesar.c:9:12: error: unused variable 'plain' [-Werror,-Wunused-variable] string plain = get_string(); ^

Caesar.c:6:15: error: unused parameter 'argc' [-Werror,-Wunused-parameter] int main (int argc, string argv[]) { ^

Caesar.c:6:28: error: unused parameter 'argv' [-Werror,-Wunused-parameter] int main (int argc, string argv[]) {

1

Simply put, you have three vars that aren't being used. argc and argv aren't being accessed at all in the code (you could remove them to eliminate two of the errors) and then you create string var plain but don't do anything with it. If you were to print it on the next line, that error would also disappear.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

0

just printf() all unused variables

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .