|
|
#1 |
|
input file with multiple types of data types
Hi
I have an input file that I need to infile into my program: Joe smith 23 alice west 45 bob MILLS 82 * 45 182 210 43 170 301 -1 82 150 97 -220 178 223 300 -1 I can get the names and the numbers after the names in, but when I get to the asterisk, the computer thinks * is a string instread of a char, and then it skips 45 and 182 and then I can get 210, 43, etc as int data types, but the 45 and 182 are coming up as string data types. Here is how I am doing it: while(infile) { if (firstname != "*") { infile >> firstname >> lastname >> leagueIDnum; cout << firstname << lastname << leagueIDnum << endl; } if(firstname == "*") { infile >> bowlingscores; cout << bowlingscores << endl; } } |
|
|
|
0
|
|
|
#2 | |
|
Quote:
If you can change the input data, replace "*" with "* * *"? This would be the easiest fix. Otherwise, you could change the code to something like: Code:
firstname = "" ;
while (firstname != "*")
{
infile >> firstname ;
if (firstname != "*")
{
infile >> lastname >> leagueIDNum ;
cout << firstname << lastname << leagueIDnum << endl;
}
}
.
.
.
Hope this helps!
__________________
Mac <- Macintosh <- McIntosh apples <- John McIntosh <- McIntosh surname <- "Mac an toshach" <- "Son of the Chief" |
||
|
|
0
|
|
|
#3 |
|
Thank you so much! This helps me so much. This is exactly what I was looking for.
Take care, Beckie |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| Framerate problem with XSplit, League of Legends, & BOOTCAMP on 2011 Macbook Pro | superkrups20056 | Mac and PC Games | 0 | Oct 11, 2011 06:42 PM |
| Typing Paratroopers - typing games can't get more addictive than this | sparkso | iPhone and iPod touch Apps | 1 | Aug 6, 2011 09:56 AM |
| How can I view the amount of space each type of data is taking up? | dvader123 | MacBook Pro | 1 | Sep 5, 2010 03:17 PM |
| Installing multiple types of OS on one disk | BreuerEditor | OS X | 4 | Sep 9, 2009 12:45 PM |
| Multiple Types of Bullets & Numbering in One List | rs7 | Mac Applications and Mac App Store | 0 | Jan 15, 2009 04:59 PM |
All times are GMT -5. The time now is 07:54 PM.







Linear Mode

