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

This is a discussion on NEED GUIDANCE: Loading String from a .txt/.dat file into Arrays within the C Programming forums, part of the General Programming Boards category; This is what's inside the .txt/.dat file : 1534891, John Doe 6686914, Jane Mary 5854916, Kenny Wang First, I created ...

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    29

    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
    Posts
    14,826
    Try fgets combine with sscanf to split the string into its three parts.


    Quzah.
    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, 10:40 AM
  2. Replies: 26
    Last Post: 06-11-2009, 12:27 PM
  3. Loading ints specified in a string into an array
    By Curtster in forum C Programming
    Replies: 1
    Last Post: 03-15-2009, 03:19 AM
  4. Looking for guidance for file I/O... databases...
    By Sparrowhawk in forum C++ Programming
    Replies: 2
    Last Post: 03-07-2009, 09:10 PM
  5. Loading a bmp from a string?
    By Blackroot in forum Windows Programming
    Replies: 5
    Last Post: 09-02-2006, 01:59 AM

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