parsing c code
Firstly apologies for the long post. I just want to try to make clear what i'm doing. i'm trying to read in values from two files then perform an operation on them later to ouput to another file. The files i'm reading from have data like this look like this :
Packet No.: 1
Bytes Sent: 21
The code i've developed so far deals with reading line by line, performing the required operations i.e. malloc and atoi. I'm not certain i'm attacking this the right way though the only error i get is with getline. Have tried to use fgets, fgetc and others. From reading through (many) posts i gather that i might read line using fgets and then parse it using sscanf. Is there a way i can use getline/fgetline? At the moment the error says that fgetline can't take 3 parameters. Should i make wholesale changes to code and try a different method? Any help would be appreciated, it's been driving me crazy.
Here's a sample of some of the code:
Re: parsing c code
I could not understand where the problem is. getline does take 3 parameters.
istream& getline (char* s, streamsize n, char delim );
s » A pointer to an array of characters.
n » The maximum number of characters to store, including the ternimating null character.
delim » The delimiter. The operation of extracting succesive characters is stopped when delimiter is read. This parameter is optional, if not specified the function considers '\n' the delimiter.
|All times are GMT +5.5. The time now is 20:06.|