Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.