Thread: Reading individual strings from an array.

  1. #1
    Registered User Baaaah!'s Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    23

    Reading individual strings from an array.

    If I have an array containing a string:

    Code:
    char line[] = "My name happens to be Foo.";
    Is there a way to read each string from the array i.e 'My' then 'name' etc? Or can I only grab individual characters.

    I've tried using 'sscanf' but I can only get that to read the first string in the array, so I repeatedly get 'My'. I guess I just assumed, incorrectly, that 'sscanf' would function in the same manner as 'fscanf'.

    Thanks.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User Baaaah!'s Avatar
    Join Date
    Oct 2005
    Location
    UK
    Posts
    23
    Cool. Thanks Dave. Something new to learn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Swapping strings in an array of strings
    By dannyzimbabwe in forum C Programming
    Replies: 3
    Last Post: 03-03-2009, 12:28 PM
  2. problem in reading value of 2 D array
    By libra in forum C Programming
    Replies: 11
    Last Post: 09-27-2008, 02:24 AM
  3. remove strings from array
    By ipe in forum C Programming
    Replies: 2
    Last Post: 01-12-2003, 04:53 AM
  4. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 10:48 AM
  5. multidimentional array of strings ???
    By null in forum C Programming
    Replies: 2
    Last Post: 09-27-2001, 12:20 AM
Website Security Test