![mario code]https://i.sstatic.net/BvxYj.jpg

I am having trouble figuring out how to fix the error I am getting on one of my variables. I'm trying to express my 'hashtag' variable (h) in terms of my space variable (s). I am wondering how to address the undeclared identifier error message. I think the issue is a self-reflexive thing where I need to change the terms of how I'm defining 'hashtag', but I don't know what that needs to be changed to. Feeling kind of stuck on this at the moment. Any help would be great. Thank you

2 Answers 2


When you're working with variables (in just about any programming language, not only in C) it may be helpful for you to remember that declaring a variable is separate and distinct from initializing a variable, even though both things may be done on the same line of code.

// declaring an integer
int foo;

// initializing the integer after declaration
foo = 27;

// declaring and initializing on the same line
int bar = 42;

In this situation, you might benefit from declaring your integers before initializing their values.

By the way, if you are able to resolve your problem, please remember to come back here and close your question by marking it as answered. Only you can do this, by clicking the green check mark next to the answer you found the most helpful. Otherwise, it will remain marked as "unanswered" and clutter up the question lists. I don't care whether you pick my answer or Cliff B's answer; I'm mainly trying to prevent this from becoming a Zombie Question that haunts the forums forever!

  • 1
    Thanks for the reminder. I appreciate your help. Commented Sep 8, 2016 at 15:58

Any var must be declared before it is used. Otherwise, it generates the undeclared identifier error. The code tries to use s on the line before it is declared.

There's a more serious logic problem here. The code is trying to use circular logic. Simply put, it's trying to do this. With neither a or b having had a value assigned, it's trying to do this:

a = b;
b = a;

You need to give this part of your code a little work. ;-)

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

You must log in to answer this question.

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