#### Archived

This topic is now archived and is closed to further replies.

# How can you read a specific line from a file (C++)

This topic is 5240 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Is there a way of using I/O streams (fstream, ostream, ect.) to read a certain line from a text file? Like, say I use the following random number generating code:
int x;
srand(GetTickCount());
x = rand()%10;

If x = 9 for instance, since the random numbers start at 0 and I''m guessing the lines in a .txt file would start at 0 as well, can I read line 10 and print it to the screen or save it to an array?
There''s no town drunk here, we all take turns. Velocity Gaming Force

##### Share on other sites
d00D j00 C0UlD L1Ke 4DD 5pEci4l CH4r4C+ER\$ +O 3@CH liNE In TeH tEX+ fiL3 L00P THR0u9h PHoR e@cH oNe @ND d0 that m@tH th4+ W@Y. eV3n 83+t3R Why n0+ nUM83R EAcH LINE +0 wHeN j00 rEcE1V3 +he RaNdOm NUMb3r J00 L00p +HROu9H +0 F1nD +H4T 4c+U4L nuM8ER.