parse error before `char'

This is a discussion on parse error before `char' within the C Programming forums, part of the General Programming Boards category; Hey guys, I am trying to get part of my assignment to work and I once again get the above ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    38

    parse error before `char'

    Hey guys,
    I am trying to get part of my assignment to work and I once again get the above mentioned error message. I just cant see what it is complaining about. I am still a bit on thin ice in this topic area (pointers with using structs and linked lists ) and am having trouble to get through the errors so that I can get on with my programs. Its a huge assignment and I still got lots to do, so if someone could give me a direction in terms of what I did wrong this time, that would just be great.
    Thanks a lot guys.
    Johannes
    Code:
    createmaster.c: In function `CreateMaster':
    createmaster.c:39: parse error before `char'
    createmaster.c:41: `dataptr' undeclared (first use in this function)
    createmaster.c:41: (Each undeclared identifier is reported only once
    createmaster.c:41: for each function it appears in.)
    createmaster.c:44: warning: assignment makes pointer from integer without a cast
    
    createmaster.c: In function `ExtractData':
    createmaster.c:82: warning: assignment makes pointer from integer without a cast
    
    createmaster.c:88: parse error before `*'
    createmaster.c:95: `boatptr' undeclared (first use in this function)
    createmaster.c:96: parse error before `['
    createmaster.c:98: `i' undeclared (first use in this function)
    createmaster.c:98: warning: passing arg 1 of `strlen' makes pointer from integer
     without a cast
    createmaster.c:101: `ptrdata' undeclared (first use in this function)
    createmaster.c:105: warning: passing arg 1 of `strstr' makes pointer from intege
    r without a cast
    createmaster.c:108: warning: passing arg 1 of `strstr' makes pointer from intege
    r without a cast
    createmaster.c:111: warning: passing arg 1 of `strstr' makes pointer from intege
    r without a cast
    createmaster.c:121: parse error before `['
    createmaster.c:122: `j' undeclared (first use in this function)
    createmaster.c:125: `Participant' undeclared (first use in this function)
    createmaster.c:125: warning: passing arg 1 of `fprintf' from incompatible pointe
    r type
    createmaster.c: At top level:
    createmaster.c:138: warning: type mismatch with previous implicit declaration
    createmaster.c:58: warning: previous implicit declaration of `InitialiseTime'
    createmaster.c:138: warning: `InitialiseTime' was previously implicitly declared
     to return `int'
    createmaster.c:139: parse error before `{'
    createmaster.c:141: invalid initializer
    createmaster.c:142: invalid initializer
    createmaster.c:144: parse error before `}'
    Sorry for the long list of errors, but you can see how much I need to fix.
    I have attached the code that throws the above error messages.
    Cheers.
    Attached Files Attached Files

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Code:
    test.c 28: Unable to open include file 'regatta.h'
    test.c 38: Undefined symbol 'Boats' in function CreateMaster
    Code:
    ifp = fopen( Boats, "r" ); /*open for reading*/
    What is Boats?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    38
    Sorry, Boats and Operations and their like are #defines in 'regatta.h' - for 'boats.dat' and 'operations.dat' where the former contains the boats number, name, and boat type; and the latter the kind of operation to be carried out.

    Cheers,
    Johannes
    Last edited by Yourhighness; 06-13-2003 at 05:35 PM.

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    38
    Hey guys, I had a crack at the file and got most of the 'errors' out. There are still some warnings tho.
    I dont quite understand the last warning but. Here the struct related to the warning:
    Code:
    typedef struct Time{
    unsigned short Hour;
    unsigned short Minute;
    unsigned short Seconds;
    } TIME;
    I am trying to initialise those in a funct called InitialiseTime - and declare them as follows:
    Code:
    TIME Hour = MAX /*#define of maximum value for unsigned*/ 
    TIME Minutes = 0;/*short*/
    TIME Seconds = 0;
    Gathering from the error messages, this is wrong. Not sure why tho.
    attached the new errors.

    Thanks everybody,
    Johannes
    Attached Files Attached Files

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    TIME Hour = MAX /*#define of maximum value for unsigned*/ 
    TIME Minutes = 0;/*short*/
    TIME Seconds = 0;
    You haven't actually created an object called "TIME". You have created three objects:

    "Hour", "Minutes and "Seconds".

    See, you fell into a common problem. You used typedef which creates a new data type, not an instance of said type.

    To do so, you want:

    TIME myTime;

    myTime.Hour = MAX;
    myTime.Minutes = 0;
    myTime.Seconds = 0;

    This creates an instance of the data type 'TIME', called 'myTime', and then initializes its three member varaibles.

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User
    Join Date
    May 2003
    Posts
    38
    Thanks for that. I should have realised that one, now that you pointed it out. The Time TIME etc gets to me. I ll have a go at it straight away.
    Ta,
    Johannes

    - I did the changes, but it still complains. This time it says:
    Code:
    usr/.../.../ /*something*/ : undefined reference to winmain@16
    collect2: Id returned 1 exit status
    No I dea what that means.

    Thanks,
    Johannes
    Last edited by Yourhighness; 06-13-2003 at 11:23 PM.

  7. #7
    Registered User
    Join Date
    May 2003
    Posts
    38
    Ta for that. Never came across a message like that. How do i get it to be in cygwin then. Sorry I meant as a console application. Because I used the normal 'gcc' command.
    But Ta for that.
    Johannes

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 06:59 PM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  3. string ?
    By cogeek in forum C Programming
    Replies: 27
    Last Post: 12-05-2004, 10:45 PM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 07:49 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 07:51 PM

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