coonfused?! array of strings.

This is a discussion on coonfused?! array of strings. within the C Programming forums, part of the General Programming Boards category; i think im confused on declaring an array of strings. char station[MAX]={0}; char str[MAX]={0}; int count=0; station[count]=gets(str); i use "gets" ...

  1. #1
    Unregistered
    Guest

    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;

    station[count]=gets(str);

    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
    Unregistered
    Guest
    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
    Posts
    14,826
    > 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'.

    Quzah.
    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, 04: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

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