Hi all,
I'm new to C and I have a little problem. I have been trying to figure out for more than 2 days why I get this error : parse error before `]' (with linux gcc compiler) because of this line of code : b = passwd_check(passwd[]); . Anyone knows why?
thanks...
Code:#include <stdio.h> #define MAX 100 int passwd_check(char passwd[]); /*fonction to check if password is right or not*/ main() { char passwd[MAX]; int a, b; for (a = 0; a != MAX && passwd[a - 1] != '\n'; a++) { passwd[a] = getchar(); } b = passwd_check(passwd[]); /* <------- this is where I get the error */ if (b == 1) { printf("\nRight Password\n"); return 0; } else { printf("\nWrong Password\n"); return 0; } } int passwd_check(char passwd[]) { int c; if (passwd[0] == 'k' && passwd[1] == '3' && passwd[2] == 'n' && passwd[3] == '\n') c = 1; else c = 0; return c; }
Code tags added by Kermi3



LinkBack URL
About LinkBacks


