I am trying to compile a small bank program in C in visual studio 2012 express. It shows me this error \"undeclared identifier\" for almost all variables and this one too \"synt
Regarding the unidentified variables, try putting all declarations of variables at the top of the main block, something like:
int main()
{
int deposit, withdraw, kbalance, decash, wicash, wibal;
char option;
printf("Welcome to skybank\n");
Older variants of C frown upon mixing variable declarations with code. To my knowledge the C standard of Microsoft's C implementation is pre-C99 so perhaps this could be the issue.
A few other issues that you should look into:
scanf_s("%c",option);
- option
should be &option
as you are taking a pointer to that variable.
Also here: case 1:
You want '1'
(as in case '1'
) instead of plain 1
as it is a char
, not an int
you want.
Same for the other case
checks.
With regards to the scanf_s problems, try compiling with warnings, it should have been pointed out by the compiler.
Finally, you might want to rid your code of the variables you're not using such as kbalance
, withdraw
and deposit
.