Input of items in C++
C++ provides streams as a much more flexible mechanism than C++ files. Ths following example
gives the flavour of this.
Thus the program
#include<iostream.h>
int main()
{
int i1;
char c1;
float f1;
char s1[6];
cin >> i1 >> c1 >> f1 >> s1;
return 0;
}
will input the line
3e3.4yes
and store the value 3 in i1, 'e' in c1, 3.4 in f1 and "yes" in s1.
Next note in series
Back to index