Thread: simple C question

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    14

    simple C question

    I don't code in C very much, so I have a simple question for you all gurus out there. Whats wrong with the following code? I can do it in C++ by passing a class instead of struct...

    Code:
    typedef struct{
        FILE *controller_param;
    }Files;
    
    void open_files( Files& my_files){
    }
    
    int main(){
        Files my_files;
        open_files( my_files);
    	return 0;
    }
    Thanks!

  2. #2
    Registered User
    Join Date
    Aug 2006
    Posts
    14
    Oh yea, the error it gives me is:

    error: syntax error before '&' token

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    There are no references in C, so trying to pass a reference of a Files doesn't make much sense, does it? In C that operator can only mean 'address of' or 'bitwise AND'.
    Sent from my iPadŽ

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    14
    "There are no references in C" Ahh, I see. I used a pointer and it worked fine. Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  4. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM