-
String Conversions
Hai guys,
I have to enter a file name from the command prompt. So this file name will go into the program as a string. Now, how can I convert this string into a filename, so that my program will understand that it will have to read from the file name that has been entered on the command line?
eg:
..\debug>program.exe file.txt
Thanks Guys.
-Vijay
-
Code:
int main ( int argc, char *argv[] ) {
// filename is in the string which is argv[1]
}
-
More Information
Hai Salem,
Perhaps it would be interesting to know a new piece of Information. The string that gets read in is just a string. This string needs to be converted into a char *[]. So we should use
string tempFileName = argv[1];
string fileName = tempFileName.c_str();
So this fileName is the one that we should be interested in.
Thanks for your reply though. I just found out this info from my super.
-Vijay