need your help!

This is a discussion on need your help! within the C++ Programming forums, part of the General Programming Boards category; Hi all, I'm new to C and I have a little problem. I have been trying to figure out for ...

  1. #1
    k3n
    k3n is offline
    Registered User
    Join Date
    Sep 2002
    Posts
    1

    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. #2
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    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
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  3. #3
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    Code:
    b = passwd_check(passwd[]);         /* <-------  this is where I get the error */
    try passwd instead of passwd[]

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21