how can i read a files with array of String contents??

This is a discussion on how can i read a files with array of String contents?? within the C Programming forums, part of the General Programming Boards category; how can i read from a files with an array formatted, for examples : 1) content of the files ( ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    1

    Question how can i read a files with array of String contents??

    how can i read from a files with an array formatted, for examples :

    1) content of the files ( "files.txt" ) :

    read 100 loop
    begin start next

    2) explaination :
    for the first lines :

    "read" assign to one of the variable ( names "var1" ) - this variable have a maximum 8 character.

    from "var1" variable to another variable, its seprated with another 2 blank character.

    "100" assign to another variable ( names "var2" ) - this variable have a maximum 6 character.

    from "var2" variable to another variable, its seprated with another 2 blank character.

    "loop" assing to another ones variable ( names "var3" ) - this variable have a maximum 5 character.

    ** for the next lines it's formatted same as the first lines explaination.

    my, questions : " how can i read this files from the array with string character, should i using an array to read this files, or have another ways to settle this problems. please reply me...?"

    thanks..

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You could read the file in one line at a time into a buffer, which would be a char array. From there, you can process it as you wish.

    Lookup:
    fgets() - read line from file
    strchr() - find a character within a string.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

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, 05:30 PM
  2. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 01:56 PM
  3. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 08:48 PM
  4. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 09:31 AM

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