Why, oh why, am I getting this error? Please help.

This is a discussion on Why, oh why, am I getting this error? Please help. within the C Programming forums, part of the General Programming Boards category; Hello, This question is about a uni assignment, but I am NOT asking help on how to do it. I've ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    5

    Why, oh why, am I getting this error? Please help.

    Hello,

    This question is about a uni assignment, but I am NOT asking help on how to do it.

    I've come across an error and I cannot, for the life of me, figure out what's wrong.

    My project contains a few files, but my error is occuring in "file.c" so I will show you "file.h" and "file.c". I hope that's all you need!

    file.h:
    Code:
    #ifndef _FILE_H_
    
    #include <stdlib.h>
    #include <stdio.h>
    #include <ctype.h>
    #include <string.h>
    
    typedef char * string;
    
    void increaseBuffer(string *buffer, size_t *length);
    
    #endif
    file.c
    Code:
    void increaseBuffer(string *buffer, size_t *length) {
    
    	string tempB = *buffer;
    	size_t tempL = *length;
    	string tempS;
    	size_t newLength = 2*tempL+1;
    	
    	tempS = realloc(tempB, newLength);
    	if(tempS == NULL) {
    		fprintf(stderr, "Could not increase buffer size\n");
    		exit(EXIT_FAILURE);
    	}
    	tempB = tempS;
    	tempL = newLength - 1;
    	
    	*buffer = tempB;
    	*length = tempL;
    }
    The error I'm getting is
    file.c:1: error: expected ')' before '*' token
    Any ideas?

    Thank you for your time!

    G.

    P.S. My compiler is GCC 4.1.2 running on linux inpus lite (Fedora)

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You need to include file.h in file.c

    --
    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.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    5
    OMG! I cannot believe I missed that!!

    haha, thank you very much.

Popular pages Recent additions subscribe to a feed

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