Example of input:
I 67 85 49
R 4
D 4
G 65 97
/end input.txt
So I’m sure this is a elementary programming question but i’ve been playing with code and tried looking it up in books. But I need a way to keep reading in numbers after the I because theoretically the numbers could be endless. Now the D,G,R I can just code it to read in one number for D and R and two for G because that will never change.
By the way, I stands for Insert, R for Rank, D for delete, and G for Range. It’s a program on BSTs. Got most of my code done except for parts of my main and little things here and there.
I was thinking of a while() loop in my switch to do this feat, but I’m pretty I’ll have to change up my coding a bit inside the while loop.
I got it working so it reads in the operations perfectly.
Thanks for any suggestions!
Code:
inFile >> oper; //prime the while loop
while(!inFile.eof())
{
switch(oper)
{
case 'I': while(//something to stop at /n)
{
inFile >> value; //tests to see if it
outFile << value; //is working correctly
MainInsert(value);
}
break;
case 'D':
break;
case 'R':
break;
case 'G':
break;
case 'F':
break;
case 'S':
break;
default: outFile << "\n Invalid Operation!" << endl;
exit (0);
}
inFile >> oper;
}
1 Answer