PROBLEM WITH READING THE FILE IN C - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

PROBLEM WITH READING THE FILE IN C

sukhmindersukhminder Posts: 19Member
hi folks ...
i have to read a .txt file and convert all the details in a circular linklist and this structure have five members. The file which is to be read is written by the user in txt format. I have to read that information and use it in the link list and i need to use a structure for each entry of the text file which has at least five fields. How can i read that file so that i can store the information and then use it accordingly for operations of link list....
please advise accordingly...
thanks in advance...


Comments

  • ivanbalenivanbalen Posts: 4Member
    : hi folks ...
    : i have to read a .txt file and convert all the details in a circular linklist and this structure have five members. The file which is to be read is written by the user in txt format. I have to read that information and use it in the link list and i need to use a structure for each entry of the text file which has at least five fields. How can i read that file so that i can store the information and then use it accordingly for operations of link list....
    : please advise accordingly...
    : thanks in advance...
    :
    :
    :there are a lot of ways this could be achived given the compiler you're using. For instance, users working in C++Builder environment might want to use the VCL class TFileStream which is pretty easy to use. If you're using older compilers then you might want to use certain file input/output classes which are integral part of C++ runtime library. If you're an inexperienced programmer then it'll take some effort to code. I can help you though if you need additional assistence.
    regards ivan

  • job4csejob4cse Posts: 29Member
    : hi folks ...
    : i have to read a .txt file and convert all the details in a circular linklist and this structure have five members. The file which is to be read is written by the user in txt format. I have to read that information and use it in the link list and i need to use a structure for each entry of the text file which has at least five fields. How can i read that file so that i can store the information and then use it accordingly for operations of link list....
    : please advise accordingly...
    : thanks in advance...
    :
    :
    :

    hi,
    Save the file as multiple lines, each line giving the structure members, separated by a blank or tab space.
    For example, one line looks like this
    ROB 10 2 3 4
    Here the first member is ROB, second 10 and so on.

    Once u've setup a file like this, u can use standard C routines to read a file line by line ( fgets ) and parse them into tokens ( index ).
    For more details, look at the man/help pages.

    Have fun ....
Sign In or Register to comment.