![]() |
| | #1 |
| Registered User Join Date: Nov 2005 Location: Canada
Posts: 80
| reading the nth item from a txt file lets say the txt is as follows: Code: 2 3 4 5 6 7 8 9 0 1 2 11 4 55 6 1 9 0 35 4 2 2 1 the other questions is, how would you only count the number of items on the first row of the txt file? in the above case, it should be 9 since the 1st line has 9 items. thanks. |
| Opel_Corsa is offline | |
| | #2 |
| Registered User Join Date: Jan 2005
Posts: 7,250
| Read in a line into a string, then parse the line. Since those are integers, the easiest way to parse a line would probably be to create a stringstream with the string and then use a loop to read each integer from the stringstream. Use a counter to find the third one and to identify the total number. |
| Daved is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Newbie homework help | fossage | C Programming | 3 | 04-30-2009 04:27 PM |
| Immediate programming help! Please! | xMEGANx | C++ Programming | 6 | 02-20-2008 12:52 PM |
| gcc link external library | spank | C Programming | 6 | 08-08-2007 03:44 PM |
| Dikumud | maxorator | C++ Programming | 1 | 10-01-2005 06:39 AM |
| Unknown Memory Leak in Init() Function | CodeHacker | Windows Programming | 3 | 07-09-2004 09:54 AM |