Why can't I get this to compile
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.
[ code ] This is code [ /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.
void showColorCodes() { int32_t nccodes; uint8_t i; nccodes = pixy2_getBlocks(CC_MAP, MAX_BLOCKS); if (nccodes < RESULT_OK) showError(nccodes); else { print("%d color codes detected\n\n", nccodes); if (nccodes > 0) { for (i = 0; i < nccodes; i++) { pixy2_extractBlock(i, &b.signature); // printf required for octal printf("ccode: %3o x: %3d y: %3d ", b.signature, b.xpos, b.ypos); printf("w: %3d h: %3d a: %+3d\n", b.width, b.height, b.angle); } print("\n"); } } }
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.#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[i] = getChar(); putChar('*') if(text[i] == '\r' || text[i] == '\n') { putChar('\n'); text[i] = 0; break; } } if(!strcmp(pass, text)) { print("(pass does match text)\n"); } else { print("(pass word does NOT match text)\n"); } }
OK
for(int i = 0; i < 16; ++i );
Remove the semicolon and see what happens.Also
putChar('*')
Needs a semicolon.
putChar('*');
thank you
It works now.