I have a file:
P 0.5 0.6 0.3
30 300
80 150
160 400
200 150
250 300
T
r 45 0 0
s 0.5 1.5 0 0
t 200 –150
.
.
.
When I read in \'P\' I know that
I think you can use standard streams
to check "P" and "T"
use get(char &ch);
and putback(ch) to push it back to stream
and
yourstream >> x >> y >> endl;
http://www.cplusplus.com/reference/iostream/istream/putback/
// Example
// istream putback
#include
using namespace std;
int main () {
char c;
int n;
char str[256];
cout << "Enter a number or a word: ";
c = cin.get();
if ( (c >= '0') && (c <= '9') )
{
cin.putback (c);
cin >> n;
cout << "You have entered number " << n << endl;
}
else
{
cin.putback (c);
cin >> str;
cout << " You have entered word " << str << endl;
}
return 0;
}