Dev C++ Very Basic C Console program - Parse error ????

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HollyStyles
    New Member
    • Aug 2007
    • 2

    Dev C++ Very Basic C Console program - Parse error ????

    Why does this program - when compiled using Dev C++ on windows - produce a "parse error before `int' " on line 14 ?????

    Code:
    #include <stdio.h>
    
    int main(int argc, char *argv[])
    {
      char last_name[6];
    
      last_name[0] = 'H';
      last_name[1] = 'e';
      last_name[2] = 'l';
      last_name[3] = 'l';
      last_name[4] = 'o';
      last_name[5] = '\0';
    
      int c = 0;
    
      return 0;
    }
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    what is the name of the file?

    Comment

    • gpraghuram
      Recognized Expert Top Contributor
      • Mar 2007
      • 1275

      #3
      Hi,
      U can declare variables only at the beginning of the function in a C program.
      Move the declaration int c = 0; to the beginning of the function.
      The error will be gone
      Raghuram

      Comment

      • HollyStyles
        New Member
        • Aug 2007
        • 2

        #4
        Originally posted by gpraghuram
        Hi,
        U can declare variables only at the beginning of the function in a C program.
        Move the declaration int c = 0; to the beginning of the function.
        The error will be gone
        Raghuram
        This forum rocks. Thank you very much for the correct answer.

        Comment

        Working...