| | |
first cannot conver std::string to const char, now runtime error!
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
> cout << copier;
Why didn't this appear to output anything?
> system(copier);
If the string is garbage in any way, then you'll get that error message.
> string my_copy = "copy" ;
> my_copy += " " + lectut_loca + " " + lectut_name ;
Starting with a string constant is perhaps a bad idea. + is oveloaded for both char * pointer addition (the type of " ") and std::string concatenation (your strings). The compiler might pick the wrong one.
Try
Why didn't this appear to output anything?
> system(copier);
If the string is garbage in any way, then you'll get that error message.
> string my_copy = "copy" ;
> my_copy += " " + lectut_loca + " " + lectut_name ;
Starting with a string constant is perhaps a bad idea. + is oveloaded for both char * pointer addition (the type of " ") and std::string concatenation (your strings). The compiler might pick the wrong one.
Try
string my_copy = "copy " ;
my_copy += lectut_loca + " " + lectut_name ; salem,
after i use your code
http://files.asmuiiazfar.com/error.png
i may forgot the slash "/" but i hv tried with slash.. got the same error.
after i use your code
http://files.asmuiiazfar.com/error.png
i may forgot the slash "/" but i hv tried with slash.. got the same error.
Last edited by n3st3d_l00p; Sep 24th, 2006 at 4:14 pm.
Windows works with backslashes "\" and forward slashes "/" but you better use Backslashes.
And also looking at your "command string" dump i can clearly see the problem. YOu are passing something like "copyA.txt B.txt" which is not the correct syntax fro the DOS copy command.
The actual syntax is "copy source dest" with spaces present in between. You can find the syntax for all commands here
http://www.easydos.com/copy.html
For testing purpose try out inputting
YServer.txt as the first input and server.txt as the second input and watch what output is displayed.
And also looking at your "command string" dump i can clearly see the problem. YOu are passing something like "copyA.txt B.txt" which is not the correct syntax fro the DOS copy command.
The actual syntax is "copy source dest" with spaces present in between. You can find the syntax for all commands here
http://www.easydos.com/copy.html
For testing purpose try out inputting
YServer.txt as the first input and server.txt as the second input and watch what output is displayed.
Last edited by ~s.o.s~; Sep 24th, 2006 at 4:28 pm.
I don't accept change; I don't deserve to live.
C++ Syntax (Toggle Plain Text)
copy c:\yserver.txt c:\documents and settings\luffy-san\desktop\tcp1241_assignment3\lecture notes\server.txt
C++ Syntax (Toggle Plain Text)
copy c:\yserver.txt c:\temp\server.txt
Well judging from the colour scheme from your output examples, my guess is you're using some crusty old Turbo C compiler on a nice new XP based system.
Problem number 1
Turbo C knows nothing about long filename, nor filenames with spaces.
It should be paying attention to the COMSPEC environment variable (which should be say
And this is only one of many possible compatibility problems you'll face with this compiler.
Get a modern 32-bit compiler, one which is far more compatible with your operating system.
Problem number 1
Turbo C knows nothing about long filename, nor filenames with spaces.
It should be paying attention to the COMSPEC environment variable (which should be say
ComSpec=C:\WINDOWS\system32\cmd.exe but I guess your compiler sets it to the far inferior command.com (because that's the historic answer for the historic compiler. Command.com didn't know anything about long filenames or space in filenames either.And this is only one of many possible compatibility problems you'll face with this compiler.
Get a modern 32-bit compiler, one which is far more compatible with your operating system.
There is nothing wrong with your program, it is the command which is incorrect. Do some research on the DOS Copy command to find out the valid commands and the format of the command. Look at the link which i had given in my 4th or 5th post on the previous page.
Hope it helped, bye.
@Mr. Salem : What is the difference if the compiler is 16 bit or 32 bit since the "copy" command which is executed in DOS mode runs in 16 bit. Try out the commands written by the guy in the DOS window without the program, jsut type it and still it doesnt work so i guess no mistake of teh compiler.
But then again maybe i am wrong somewhere, please let me know where it is?
Hope it helped, bye.
@Mr. Salem : What is the difference if the compiler is 16 bit or 32 bit since the "copy" command which is executed in DOS mode runs in 16 bit. Try out the commands written by the guy in the DOS window without the program, jsut type it and still it doesnt work so i guess no mistake of teh compiler.
But then again maybe i am wrong somewhere, please let me know where it is?
Last edited by ~s.o.s~; Sep 25th, 2006 at 2:43 pm. Reason: added for Mr. salem
I don't accept change; I don't deserve to live.
![]() |
Similar Threads
Other Threads in the C++ Forum
- Previous Thread: Newbie in need of help!!!
- Next Thread: setprecision
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






