Thread: Multiple char strings into one string

  1. #1
    Registered User
    Join Date
    Oct 2010

    Multiple char strings into one string

    I need to read a file with lines like this:
    LastName, FirstName MiddleName ID# (integers)

    I want to be able to scan the LastName, FirstName, and MiddleName into one string without scanning the ID# and various integers after them.

    What is the best way to do this? I've though about scanning each name individually but I need to print the names out in a 26-digit space, for example:

    Griffin, Peter Lowenbrau 123456789 5 7 3 4 6 4
    would be the input and I want to later print out:

    Griffin, Peter Lowenbrau  123456789 5 7 3 4 6 4
    notice the left-justified string with 26-spaces available.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Katy, Texas
    I would use either a formatted scanf() pattern, or just read the whole string and then parse at the commas and whitespace.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  4. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  5. String sorthing, file opening and saving.
    By j0hnb in forum C Programming
    Replies: 9
    Last Post: 01-23-2003, 01:18 AM