-
need your help!
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
-
2 Things........
First of all please use code tags in the future...I added them for you this time, but in the future you do it....people are much more likely to help you if you do.
Second of all I'd like to appologize, I aaccidently deleted this thread. I've put it back now obviously..sorry.
Info on code tags:
http://www.cprogramming.com/cboard/s...threadid=13473
-
Code:
b = passwd_check(passwd[]); /* <------- this is where I get the error */
try passwd instead of passwd[]