Why can't I get this to compile
Blake Koch
Posts: 39
I can't seem to get this to compile, can someone point out why the compiler keeps telling me "var (i) is undeclared"?
#include "simpletools.h" // Include simple tools
char text[16];
char pass[7] = {"abc 123"};
int main() // Main function
{
__print("Enter Password: ");
__for(int i = 0; i < 16; ++i );
__{
_____text = getChar();
_____putChar('*')
_____if(text == '\r' || text == '\n')
_____{
_________putChar('\n');
_________text = 0;
_________break;
_____}
__}
__if(!strcmp(pass, text))
__{
_________print("(pass does match text)\n");
__}
__else
__{
_________print("(pass word does NOT match text)\n");
__}
}
SimpleIDE Version 1.1.2
C:/Users/SimpleIDE/ Updated on: 2020-08-31
Password Check.c: In function 'main':
Password Check.c:13:14: error: 'i' undeclared (first use in this function)
Password Check.c:13:14: note: each undeclared identifier is reported only once for each function it appears in
Password Check.c:15:9: error: expected ';' before 'if'
Done. Build Failed!
Click error or warning messages above to debug.
the ____ are just Blank spaces to show the indent.
Thanks.
#include "simpletools.h" // Include simple tools
char text[16];
char pass[7] = {"abc 123"};
int main() // Main function
{
__print("Enter Password: ");
__for(int i = 0; i < 16; ++i );
__{
_____text = getChar();
_____putChar('*')
_____if(text == '\r' || text == '\n')
_____{
_________putChar('\n');
_________text = 0;
_________break;
_____}
__}
__if(!strcmp(pass, text))
__{
_________print("(pass does match text)\n");
__}
__else
__{
_________print("(pass word does NOT match text)\n");
__}
}
SimpleIDE Version 1.1.2
C:/Users/SimpleIDE/ Updated on: 2020-08-31
Password Check.c: In function 'main':
Password Check.c:13:14: error: 'i' undeclared (first use in this function)
Password Check.c:13:14: note: each undeclared identifier is reported only once for each function it appears in
Password Check.c:15:9: error: expected ';' before 'if'
Done. Build Failed!
Click error or warning messages above to debug.
the ____ are just Blank spaces to show the indent.
Thanks.
Comments
You shouldn't use the ___ to maintain indents.
Just push the C button above, and THEN paste your code.
normally there are no spaces in the code tag, but I had to add them, like JohnnyMac shows below.
You can edit your first post and put the code inside the code tags.
BTW... If you click on C on the forum entry toolbar you'll get code tags that will make reading your code easy without you having to insert padding. Copy and paste your code between the [ code ] and [ /code ] tags.
OK
Also
Needs a semicolon.
thank you
It works now.