Thread: Multiple char strings into one string

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    4

    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:

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

    Code:
    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
    Location
    Chappell Hill, Texas
    Posts
    2,332
    I would use either a formatted scanf() pattern, or just read the whole string and then parse at the commas and whitespace.
    Mainframe assembler programmer by trade. C coder when I can.

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