I'm writing a simple program in c, that prints all elements of an array. The array is
char op[2][50] = {"option1", "option2"};
the program is
int main(int argc, char * argv[])
{
char spaces[6] = " ";
int choice;
char op[2][50] = {"option1", "option2"};
printf("\n\n\t=========== OPTIONS ===========\n\n\t");
for (int i;i<sizeof(op)/sizeof(op[0]);i++) {printf("%s[%d]: %s\n\t",spaces,i+1,op[i]);}
printf("\n\t\t%s[?]: ",spaces);
scanf("%d",&choice);
if (choice==1) {firstFunction();} //i've declared this function, but here isn't important
return 0;
}
So, the problem is that the options arent printed. output:
=========== VIDEO TOOLS ===========
[?]:
the problem is essentially that if statement, because i've tried to add other printf up and down it and them works. Also, that if statement worked before some changes to the program, so the problem can be other lines of code(?)
i'm a beginner with c, so please not expose complex solutions. thanks