tags:

views:

116

answers:

3

HI all. I am trying to make little program that reads data from file which has name of user and some data for that user. I am new on C , and how can i calculate this data for its user?line by line reading and adding each char in array? And how can I read line? is there any function?

And how can I use this each line users like object?I will make calculation for specific user.

A: 

Everything you need is in stdio.h. (Link is to a C++ website but the entire C i/o system is usable in C++; hence the documentation)

Billy ONeal
+2  A: 

You can use fgets to read a line at a time from the file.

Then you can parse the fields out and add them to an array or some other data structure. Just keep in mind if you use an array then you need to know ahead of time how many entries the file may contain - for example, no more than 1000. Otherwise you will need to use a data structure that can dynamically allocate memory such as a linked list, vector, etc.

Justin Ethier
+1  A: 

Try this site, i often use it for reference.

http://www.cprogramming.com/tutorial/cfileio.html

Play around with file i/o and get use to the functions and then you will be able to make what you want.

Darxval