Question: (C++) Need to import the text from a notepad document including a space. I already have the program, but it is skipping spaces. here is
(C++) Need to import the text from a notepad document including a space. I already have the program, but it is skipping spaces. here is the program and input.
PROGRAM
| #include #include #include #include #include using namespace std; ifstream in_stream; string iarray[201]; int s = 0; void readFromFile() { in_stream.open("Input7.txt"); if (in_stream.fail()) { cout << "failed to open. "; exit(1); } while (!in_stream.eof()) { in_stream >> iarray[s]; s++; } } int main() { readFromFile(); for (int i = 0; i < s; i=i++) { cout << iarray[i]; } return 0; } |
INPUT "Input7.txt"
| Th is i s a se nt en ce . |
CURRENT OUTPUT
| Thisisasentence. |
EXPECTED OUTPUT
| This is a sentence. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
