Hi everybody.
How can I put a variable in this example
where filename is a variable.Code:remove("C:\\example\\filename");
bye
Hi everybody.
How can I put a variable in this example
where filename is a variable.Code:remove("C:\\example\\filename");
bye
Last edited by pitkini; 06-26-2005 at 03:21 AM.
Code:#include<iostream> #include<string> using namespace std; int main() { string path; cout << "enter the desired path: "; cin >> path; remove(path.c_str()); return 0; }
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
Code:#include <iostream> #include <string> using namespace std; int main() { string myDirectory = "C:\\example\\"; string filename = "input.txt"; string myPath = myDirectory + filename; remove(myPath.c_str()); return 0; }
Code:#include <iostream> #include <string> using namespace std; int main() { string myDirectory = "C:\\example\\"; string filename; cout << "File Name: "; getline(cin, filename, '\n'); string myPath = myDirectory + filename; remove(myPath.c_str()); return 0; }
Thanks everybody
nothing of these worked. Was an error on:
Code:remove(myPath.c_str());
maybe i'm not sure what's wrong the other samples worked fine.Code:#include<iostream> #include<string> using namespace std; int main() { char path[81]; cout << "Enter the desired path:"; cin >> path; //remove(path.c_str()); remove(path); return 0; }