Thread: NEED GUIDANCE: Loading String from a .txt/.dat file into Arrays

  1. #1
    Registered User
    Join Date
    Apr 2009

    NEED GUIDANCE: Loading String from a .txt/.dat file into Arrays

    This is what's inside the .txt/.dat file :

    1534891, John Doe
    6686914, Jane Mary
    5854916, Kenny Wang
    First, I created 3 arrays,

    employeeID int array
    employeeFirstName char array size 30
    employeeLastname char array size 30

    and we're required to load the data (Strings) from the file into the arrays created. I'm attempting the question now, started off with fopen and other functions to load the file.

    I know:
    - need loops to do this
    - id and name is seperated with ', '
    - next person is in next line, seperated by 'lf' or x0A in Hex from ASCII table

    need some advise.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Try fgets combine with sscanf to split the string into its three parts.

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. loading 2 character arrays in a row
    By rivkyfried1 in forum C Programming
    Replies: 4
    Last Post: 12-09-2010, 09:40 AM
  2. Replies: 26
    Last Post: 06-11-2009, 11:27 AM
  3. Loading ints specified in a string into an array
    By Curtster in forum C Programming
    Replies: 1
    Last Post: 03-15-2009, 02:19 AM
  4. Looking for guidance for file I/O... databases...
    By Sparrowhawk in forum C++ Programming
    Replies: 2
    Last Post: 03-07-2009, 08:10 PM
  5. Loading a bmp from a string?
    By Blackroot in forum Windows Programming
    Replies: 5
    Last Post: 09-02-2006, 12:59 AM