André123
asked on
easy one -file I/O - 300 points
Hi, I have a file of this structure:
1$data
2$aadad
;this is a comment line
3$azdfadad
;here is another one
5$6
6$azd
and I want to do the following:
(a)
read in the file, and display all the lines which aren't comment:
1...data
2...aadad
3...azdfadad
5...6
6...azd
where the ... is a \t (it isn't possible to post a sequence of spaces here)
(b)
every line which isn't comment should be red in as an integer and a string (and, the integer can be >9 , so I think I should work with something like " fscanf (Fp, "%d$%s",&dd, aaa); ". They should be (temporarily) saved in variables (int tempint; and char tempchar[100]; for example)
(c)
I prefer NOT to read in the integer as a character and convert it with atoi (because I hate using atoi).
this question is allso asked here:
http://oldlook.experts-exchange.com/questions/21406661/fscanf-easy.html
HOWEVER: I misformulated the question at first, so please read the whole thread if you can replie there (because , I have about 10 versions which do the wrong thing now (my fault, I didn't asked it correct ) )
Thanks in advance.
1$data
2$aadad
;this is a comment line
3$azdfadad
;here is another one
5$6
6$azd
and I want to do the following:
(a)
read in the file, and display all the lines which aren't comment:
1...data
2...aadad
3...azdfadad
5...6
6...azd
where the ... is a \t (it isn't possible to post a sequence of spaces here)
(b)
every line which isn't comment should be red in as an integer and a string (and, the integer can be >9 , so I think I should work with something like " fscanf (Fp, "%d$%s",&dd, aaa); ". They should be (temporarily) saved in variables (int tempint; and char tempchar[100]; for example)
(c)
I prefer NOT to read in the integer as a character and convert it with atoi (because I hate using atoi).
this question is allso asked here:
http://oldlook.experts-exchange.com/questions/21406661/fscanf-easy.html
HOWEVER: I misformulated the question at first, so please read the whole thread if you can replie there (because , I have about 10 versions which do the wrong thing now (my fault, I didn't asked it correct ) )
Thanks in advance.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Any doubt
ASKER
I used the code of smpoojary, this one does exactly what I needed
sunnycoder -> didn't gave the int's as int
grg99->allso needed further processing to convert the numbers to an int ...
Thanks all.
sunnycoder -> didn't gave the int's as int
grg99->allso needed further processing to convert the numbers to an int ...
Thanks all.
ASKER
PS: smpoojary, if you drop a line here http://oldlook.experts-exchange.com/questions/21406661/fscanf-easy.html I give you some more points.
Thanks a lot
-Mahesh
-Mahesh
I have put comment in that link.
-Mahesh
-Mahesh