In pset2 when I write this code:

string in = GetString();
char a = in[0];
if(isupper(in[0])) printf("Gotcha\n");

I input string "Be sure" and I expected "Gotcha" to be printed out but it was not. When I write this code instead:

if(isupper(a)) printf("Gotcha\n");

Surprisingly, "Gotcha" was printed out! Why didn't it print out before?

  • What was the output in the first time?
    – user2477
    Oct 1, 2014 at 12:05
  • You have probably gotten an error that "a" is not used. if you try using it somewhere later in the code, it should also print "Gotcha"
    – user2477
    Oct 1, 2014 at 12:07

1 Answer 1


The compiler gives you a warning of unused variable and does not execute the code. If you use your a somewhere in the code or remove it completely, then it should print your Gotcha.

You must log in to answer this question.

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