Thread: coonfused?! array of strings.

  1. #1

    coonfused?! array of strings.

    i think im confused on declaring an array of strings.

    char station[MAX]={0};
    char str[MAX]={0};
    int count=0;


    i use "gets" to scan in a sting(such as a sentence)
    and i want to store it to an array of strings??

    can someone give me advice or help?? thanks

  2. #2
    never mind.. i solved it on my own..i need a "*" infront of station.. thanks for looking.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    > station[count]=gets(str);

    This is wrong. You array of strings will have no memory allocated to it. You need to read into 'str', then malloc and strcpy from str for each string in 'station'.

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. intializing an array of strings
    By doubty in forum C Programming
    Replies: 4
    Last Post: 06-19-2009, 12:59 PM
  2. Replies: 1
    Last Post: 03-19-2009, 10:56 AM
  3. Build an array of strings dynamically
    By Nazgulled in forum C Programming
    Replies: 29
    Last Post: 04-07-2007, 09:35 PM
  4. Array of strings in C
    By szill in forum C Programming
    Replies: 10
    Last Post: 02-22-2005, 05:03 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM