[英]how to save output file in C drive for C++
Ive been able to succesfully create a file, rename it, and then save it, however I need help in trying to save it in the C:\ drive but no luck.我已经能够成功地创建一个文件,重命名它,然后保存它,但是我需要帮助来尝试将它保存在 C:\ 驱动器中,但没有运气。
string filename, newfile;
ifstream wordInFile(filename);
cout << "Please enter filename to open" << endl;
cin >> filename;
cout << "Please enter the name for your new file" << endl;
cin >> newfile;
ofstream tempFile(newfile); //Creating and opening a temporary file to store the needed words
wordInFile.close(); //Close the input file
tempFile.close(); //Close the temp output file
Try switching the order:换个顺序试试:
string filename, newfile;
cout << "Please enter filename to open" << endl;
cin >> filename;
ifstream wordInFile(filename);
In general, you want to have valid content in your variables before you use them.通常,您希望在使用变量之前在变量中包含有效内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.