Don't know why I am getting a syntax error

This is a discussion on Don't know why I am getting a syntax error within the C Programming forums, part of the General Programming Boards category; I am working on a project using structures and when I compile my program I get a syntax error, in ...

  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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,659
    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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,659
    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, 02:07 AM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 03:09 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01: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, 04:27 AM

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