Ok...here is the problem:
"Write an interactive C++ program to prompt the user for a folder name, echoing the response to the display. Your program must store the folder name in a single variable. Show the results of running your program with the following inputs, as shown below,
[run]
Where is the input data file (example: c:\home\john\ )? c:\home\fred\
The data file is located in the folder: c:\home\fred\
[run]
Where is the input data file (example: c:\home\john\ )? c:\home\tom\
The data file is located in the folder: c:\home\tom\"
I worked on it, and I have a program that prints what he asked....
Is this right? My only issue is this...it says "Your program must store the folder name in a single variable". Is "char" classified as a variable? If it is, then I'm done. Does he mean that I'm supposed to fit all of that text into an actual variable, as in "int"? My delightfully vague teach..Code:#include <iostream> #include <stdlib.h> #include <cstring> using namespace std; int main(int argc, char *argv[]) { char f[50]; //this is the variable, which is a "char" type cout << "Where is the input data file (example: c:\\home\\john\\)? \n"; cin >> f; cout << "The data file is located in the folder: " << f << "\n"; system("PAUSE"); return 0; }
Thanks



LinkBack URL
About LinkBacks



And if you run a good compression algorithm, you might be able to fit in even more. And if you use a double, you get 8 bytes instead of 4, so you can fit in at least double the information
But that's rather advanced, and hardly good coding technique; more of a mind-twister type thing. I would suggest going with the char[] or std::string, since that's what you'll be doing in real life situations.