Stupid pointer problems

  • 11 years ago
    I haven't done C programming in AGES and for some reason, I can't seem to recall how to handle stuff like this.

    In my .h file, I have a struct defined as:

    struct tagCLIENT
    {
        char * advertisedIPAddr;
        char* actualIPAddr;
        char * clientID;
        int udpPort;
        time_t age;
    }  CLIENT;

    I then have a function:

     CLIENT** LoadClientsFile(char* filename);
     

    I'm getting an error on this last line. I assume, for some, it doesn't like the CLIENT**.

     
    I'm actually compiling with gcc, so the error message is a bit differen than I'd probably get with MS C/C++ compiler. The error message is simply, "syntax error before '*' token"

     
    What am I doing wrong?

     
    If I change the return type to void* it works fine. 

     Thanks.
     

  • 11 years ago

    CLIENT is a variable of type tagCLIENT , you can't use a variable for return type of a function (if do that, will be assumed as a definition statement, by the compiler), instead you should use a type .

    => I think you mean this one :

    tagCLIENT** LoadClientsFile(char* filename);

    ======================================= 

    => or you can do the following method (typedef statement), then CLIENT will be equivalent to tagCLIENT.

    typedef struct tagCLIENT
    {
        char * advertisedIPAddr;
        char* actualIPAddr;
        char * clientID;
        int udpPort;
        time_t age;
    }  CLIENT;

    CLIENT** LoadClientsFile(char* filename);

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC. As potential programmers, they are mentally mutilated beyond hope of regeneration.” - E. W. Dijkstra