Thread: populate an array struct

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    The subscripting should be here:
    Code:
    strncpy(students[i]->firstName, input_string, MAX_SIZE);
    Those other lines you added are meaningless.

    Also, since you changed the prototype:
    Code:
    int get_info(struct student_data  *studentPtr )
    int get_info( struct student_data students[MAX_STUDENTS] )
    You won't be able to use indirect notation (->); so you might as well change it back (as I said, with structs, *studentPtr could be a single struct or an array of structs, you don't need students[MAX]). The only place the subscripting is relevant is the red bit, above.
    Last edited by MK27; 04-17-2009 at 03:01 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 12-03-2008, 03:10 AM
  2. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 03:55 AM
  3. array of pointers of a struct
    By paulur in forum C Programming
    Replies: 18
    Last Post: 04-14-2006, 07:17 AM
  4. Writing an array of struct to file
    By stellastarr in forum C Programming
    Replies: 10
    Last Post: 03-25-2006, 06:59 PM
  5. Array of struct pointers - Losing my mind
    By drucillica in forum C Programming
    Replies: 5
    Last Post: 11-12-2005, 11:50 PM