Results 1 to 10 of 10

Thread: Reading some file using C language

  1. #1
    Join Date
    Dec 2010
    Posts
    39

    Reading some file using C language

    I have a small project where I has to create script which can read a file on C platform. I need help to make the same. I am bit confused with some codes here. I downloaded a ready script but that does not worked. What is a easier way of doing this.

  2. #2
    Join Date
    Aug 2009
    Posts
    2,881

    Re: Reading some file using C language

    Heard about fscanf(). Try this out. It will work. It is a kind of field oriented function which is quiet enough for file reading. It works fine. I do not have samples here. You can search the same on web to collect information on it.

  3. #3
    Join Date
    Apr 2010
    Posts
    76

    Re: Reading some file using C language

    Try some software development forums. There are ample of custom scripts available. They also guide you how to use the fscanf reference making your work a bit more easier. fscanf in C# works quiet fine but with certain limitations. First of it is necessary that you are aware about the data layout. This should be exact what you are trying to read. The layout here matters the most. You need to rewrite the stuff back again if there is another layout in the same text. This makes the job a bit more complicated in using fscanf. One more issue that is more common is spaces.

    Its a bit difficult for fscanf to read the text that has spaces. There is no way you can differentiate the same with other scripts. The backend process of writing script is time consuming. As you had mentioned that you had downloaded a script edit that and check the reference. I am sure you just need to do minor modification and your job will be done. Do not forget to define the layout in proper way and also the space thing. If you are still confused you can try to check some video tutorial. Creating everything from scratch is a long process. There are ample of things you have to check and ensure. I had seen a number of guides on web that show us the way how to do that.

  4. #4
    Join Date
    Jul 2010
    Posts
    30

    Re: Reading some file using C language

    Try msdn. It will help you a lot on the same. The article that I saw was about reading the text file through static methods. There were two things involved in it. First of ReadAllText and second of ReadAllLines. It can give you a bit highlight on what you are doing.

  5. #5
    Join Date
    Jan 2011
    Posts
    57

    Re: Reading some file using C language

    That would be a bit out of topic I think. Stick with fscanf that will be better. The common parameters used here is int fscanf ( FILE * stream, const char * format, ... );. This are just for references. This will read the data as per the format provided by parameters based on location point. So you need a comprehensive tutorial for that. You need to arrange number of parameters properly making it a bit better job for your work. I will just give you a small glimpse of parameter used in the same. Lets begin with stream. This is a pointer. It will point a file object which allows to read data.

    It will help to identify the object to read files. The second comes format. This has more number of elements inside the same. You need to understand each of them properly one by one. Lets being with spaces. They are normally ignored but as some places due to different format this thing can create a issue. It includes spaces, tabs, etc. The other characters which are close to spaces. They are link or blank area. This is used to define a paragraph or simply used between list. This is also ignored. The last and important thing is format specifier. This is the most vital element here. You need to properly specify the format of data and its type. If you ignore this part you might not get results.

  6. #6
    Join Date
    Jul 2010
    Posts
    24

    Re: Reading some file using C language

    I was stuck on that last time. I did all stuff well but did not properly specified the data format which make my work failure. I had collected information on Format specifier from web and found it very effective solution.

  7. #7
    Join Date
    Jul 2010
    Posts
    82

    Re: Reading some file using C language

    It is correct. Ample of people who are trying to read a text file through fscanf get stucked on format specifier. I can help you out to put a bit more highlight on the same. A format specify comprise of following parameters - [=%[*][width][modifiers]type=]. In this the % act as a sequence which shows the type and format of a data. * tells the script what data has to be read. It is just the starting point. Width here tells the program which data needs to be read. Ti provides the size and data point based on some additional arguments if needed. There are more additional stuff in the same like h, I, and L.

    The last is type which shows the type of content. It is not easy to get all stuff explain in some points here. That needs a more detailed work. You have to get a nice reference sheet to work on the same. I had seen ample of tutorials with script download link that tells a quiet better way of performing the same thing. I hope to get some automated way, but that is too complicated. You need to be choosy with what you are doing or else your ample of time will be wasted.

  8. #8
    Join Date
    Sep 2010
    Posts
    43

    Re: Reading some file using C language

    For me this language is a big headache. From last couple of days I am trying to the same thing. The issue here is that I have a quiet large text files and I have to integrated them properly. I hope this will help to work in a better way.

  9. #9
    Join Date
    Nov 2009
    Posts
    61

    Re: Reading some file using C language

    I and my friend has tried to do that on C and we were quite succeeded. It starts with a process of first opening the file. This connects the program with the OS and then you can go with number of changes. Now the parameter used for the same is FILE*fp ;. This will make the file to open in it is own structure. I am not going to explain all the variables here. You need to find that on your own as it consumes a bit long time to note down each of them.

    The second step is reading a fiel. The parameter used are ch = fgetc ( fp ) ;. It worked and I can get the result here. I am just posting this as sample yet it is not related to your query. But it can provide you help on reading process.

  10. #10
    Join Date
    Nov 2009
    Posts
    1,142

    Re: Reading some file using C language

    There are number of scripts available for C I think. But not sure about C#. I was just searching on web to find the sample code and found many C code. It looks people are not really working on C#.

Similar Threads

  1. Reading XML file with ASP
    By Dharamsi in forum Software Development
    Replies: 4
    Last Post: 10-03-2010, 10:47 PM
  2. Reading a file in loop
    By Xmen in forum Software Development
    Replies: 5
    Last Post: 09-01-2010, 02:23 PM
  3. Reading file bit by bit
    By John Wilson in forum Software Development
    Replies: 4
    Last Post: 14-12-2009, 01:49 PM
  4. Java reading from a file
    By xqc72 in forum Software Development
    Replies: 1
    Last Post: 20-11-2009, 08:20 AM
  5. Reading a file docx
    By Erskine in forum Tips & Tweaks
    Replies: 0
    Last Post: 26-11-2008, 06:37 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,728,039.99057 seconds with 17 queries