errors on structures

This is a discussion on errors on structures within the C Programming forums, part of the General Programming Boards category; void records(struct drivers_license *record[15]); void changes(struct drivers_license *record[15]); int main() { struct drivers_license record[15]; sprintf(record[0].lastname,"Daniel"); printf("%12s",record[0].lastname); records(*record[]);//expression syntax error right ...

  1. #1
    cwd
    cwd is offline
    Registered User
    Join Date
    Sep 2001
    Posts
    9

    errors on structures

    void records(struct drivers_license *record[15]);
    void changes(struct drivers_license *record[15]);

    int main()
    {
    struct drivers_license record[15];
    sprintf(record[0].lastname,"Daniel");
    printf("%12s",record[0].lastname);
    records(*record[]);//expression syntax error right here
    changes(*record[]);//expression syntax error right here

    return 0;
    }

    void records(struct drivers_license *record[15])
    {
    printf("%s",record[0]->lastname);
    }

    void changes(struct drivers_license *record[15])
    {
    }

    I get an expression syntax error in main when trying do declear the records and changes functions.

  2. #2
    Registered User *pointer's Avatar
    Join Date
    Oct 2001
    Posts
    74
    I had to recreate the structure to keep from getting a slew of errors, but the two errors you got can be eliminated by just passing the array name, without the dereference operator and [] operators. Like so:
    Code:
    #include <stdio.h>
    
    void records(struct drivers_license record[15]);
    void changes(struct drivers_license record[15]);
    
    struct drivers_license{
    	char lastname[1024];
    };
    
    int main(void){
    	struct drivers_license record[15];
    
    	sprintf(record[0].lastname,"Daniel");
    	printf("%12s",record[0].lastname);
    	
    	records(record); /*array name only*/
    	changes(record); /*array name only*/
    
    	return 0;
    }
    
    void records(struct drivers_license record[15]){
    	printf("%s",record[0].lastname); /*no pointer, no ->*/ 
    }
    
    void changes(struct drivers_license record[15]){
    	/*placeholder*/
    }
    pointer = NULL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Structures within structures for a database
    By Holtzy in forum C Programming
    Replies: 2
    Last Post: 04-30-2008, 07:06 AM
  2. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  3. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  4. Header File Errors...
    By Junior89 in forum C++ Programming
    Replies: 5
    Last Post: 07-08-2007, 12:28 AM
  5. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 12:43 PM

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