Quantcast
Channel: Active questions tagged filereader - Stack Overflow
Viewing all articles
Browse latest Browse all 104

Reading lines with different data types from txt file in c

$
0
0

How can I read multiple lines from a txt file if I want to store the data in different variables? Each line contain the same data type order: int string string char string, separated with tabs.

For example a line in the txt file look like:

11 \t I would like an apple \t What is your favourite car brand? \t b \t elephant 

Thanks for help in advance.

I tried to read it with fscanf(“%d\t%s\t%s\t%c\t%s\n”,..); but I can’t read the strings because %s cut my sentence at the first space and it reads only the first line, I can’t move to the next lines.


Viewing all articles
Browse latest Browse all 104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>