★ Inferno provides Programming Tutorials in a variety of languages. Join our Programming Forums. ★
Actually on windows you can use single or double slashes, and it will still work.
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
Hah, thanks for making it incredibly clear .
★ Inferno provides Programming Tutorials in a variety of languages. Join our Programming Forums. ★
Yay! Everything is working now except one thing.
I added a code that finds out from what path my exe was executed in and the path is stored in a string. But, when I tell it to copy from that path, and that path includes spaces like so: "C:\Program Files\" instead of "C:\ProgramFiles\" it returns: "C:\Program could not been found."
So how do I tell it to include the spaces in the path when it copys? Anyone?
Extra quotes around the file name. Of course, this indicates you're still using system().
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
Ok great thanks!
Yet one thing xD
My program lets users input a string, which is then used to copy the files to. But, if the user types f.x: "c:\program files\" instead of "C:\Program Files\" it doesn't work because the user inputted lower case. So, can I make the program stop being case-sensitive when copying?
Thanks!
Windows file systems are always case insensitive by default (although you can make it case sensitive). I've never seen anyone who actually enables case sensitivity of a Windows file system, so I doubt that would be a problem.
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
If I let the program copy, after the copying it returns either: "1 file(s) copied" or "The system cannot find the file specified". So, can I make the program find out either was returned?
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
Why not just be platform-agnostic about it?
No error checking in the actual copy op, of course.Code:#include <string> #include <fstream> #include <iterator> #include <algorithm> bool copyfile(const std::string &source, const std::string &dest) { std::ifstream in(source); std::ofstream out(dest); if(!in || !out) return false; in >> std::noskipws; std::copy(std::istream_iterator<char>(in), std::istream_iterator<char>(), std::ostream_iterator<char>(out)); return true; }
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
Except of course you can.
Code:#include <stdlib.h> #include <stdio.h> int main(void) { printf("%d\n", system("copy temp.c temp.d")); printf("%d\n", system("copy temp.garbage temp.d")); return 0; }Code:>temp 1 file(s) copied. 0 The system cannot find the file specified. 1
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010