Thread: Don't know why I am getting a syntax error

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    13

    Question Don't know why I am getting a syntax error

    I am working on a project using structures and when I compile my program I get a syntax error, in main before char. My code so far is:
    Code:
    #include <stdio.h>
    #include <stdbool.h>   
    #define SIZE 30
    
     typedef  struct   //student records
    {
       char fName[20];
       char lName[20];
       int gLevel;
       char ssn[11];
       int month;
       int day;
       int year;
    }STUDENT;
    
    void fillStruct(char argv,STUDENT* sarr[]);
    
    
    int main(int argc,char* argv[])
    {
       STUDENT* stud[SIZE];
     
       fillStruct(char argv,stud);
     
     
     
      return 0;
    }
    if any one could please tell me what I am doing wrong I would greatly appreaciate it.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You don't use types when passing an argument.
    fillStruct takes a single char as argument and not a string.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
    fillStruct(char argv,stud);

    I expect this is also somewhat wrong, as I expect you want the char *, not char:
    Code:
    void fillStruct(char argv,STUDENT* sarr[]);
    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    13
    Ok I changed my declaration to:
    Code:
    void fillStruct(char *argv,STUDENT* sarr[]);
    and the function call in main to:
    Code:
     fillStruct(argv,stud);
    and now when I compile it says " warning: passing arg 1 of `fillStruct' from incompatible pointer type"

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    argv is char**, not char*.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, because argv is an array of pointers, you probably don't want to pass the entire array, but one of the elements in argv - although of course, I'm just guessing what your function actually wants.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    13
    Thanks a lot guys my program is compiling now. I can now get on to the bulk of the project. Thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM