first cannot conver std::string to const char, now runtime error!

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Sep 2006
Posts: 20
Reputation: n3st3d_l00p is an unknown quantity at this point 
Solved Threads: 0
n3st3d_l00p's Avatar
n3st3d_l00p n3st3d_l00p is offline Offline
Newbie Poster

Re: first cannot conver std::string to const char, now runtime error!

 
0
  #11
Sep 24th, 2006
run time error

after i input the lecture notes/tutorials name..
(getline(cin,lectut_name);

it show>>> The syntax of the command is incorrect.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 20
Reputation: n3st3d_l00p is an unknown quantity at this point 
Solved Threads: 0
n3st3d_l00p's Avatar
n3st3d_l00p n3st3d_l00p is offline Offline
Newbie Poster

Re: first cannot conver std::string to const char, now runtime error!

 
0
  #12
Sep 24th, 2006
http://files.asmuiiazfar.com/error.gif

that's the error.. hhuhuhuhu...
Last edited by n3st3d_l00p; Sep 24th, 2006 at 2:51 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: first cannot conver std::string to const char, now runtime error!

 
1
  #13
Sep 24th, 2006
> 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
string my_copy = "copy " ;
my_copy += lectut_loca + " " + lectut_name ;
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 20
Reputation: n3st3d_l00p is an unknown quantity at this point 
Solved Threads: 0
n3st3d_l00p's Avatar
n3st3d_l00p n3st3d_l00p is offline Offline
Newbie Poster

Re: first cannot conver std::string to const char, now runtime error!

 
0
  #14
Sep 24th, 2006
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.
Last edited by n3st3d_l00p; Sep 24th, 2006 at 4:14 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,615
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 466
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: first cannot conver std::string to const char, now runtime error!

 
0
  #15
Sep 24th, 2006
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.
Last edited by ~s.o.s~; Sep 24th, 2006 at 4:28 pm.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 20
Reputation: n3st3d_l00p is an unknown quantity at this point 
Solved Threads: 0
n3st3d_l00p's Avatar
n3st3d_l00p n3st3d_l00p is offline Offline
Newbie Poster

Re: first cannot conver std::string to const char, now runtime error!

 
1
  #16
Sep 24th, 2006
yah.. it's work with backslash.. hahaha.. pity me..

because no dest so the file copied to current folder which program is running..

thanks you guys!!!
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,615
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 466
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: first cannot conver std::string to const char, now runtime error!

 
0
  #17
Sep 24th, 2006
Glad we could be of assistance and most of the credit of this problem solved goes to Mr. Salem for pointing out that it was actually the command string which was getting messed up, I just picked up his idea and completed it for you.

Best of luck.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 20
Reputation: n3st3d_l00p is an unknown quantity at this point 
Solved Threads: 0
n3st3d_l00p's Avatar
n3st3d_l00p n3st3d_l00p is offline Offline
Newbie Poster

Re: first cannot conver std::string to const char, now runtime error!

 
0
  #18
Sep 25th, 2006
  1. copy c:\yserver.txt c:\documents and settings\luffy-san\desktop\tcp1241_assignment3\lecture notes\server.txt
not working...

  1. copy c:\yserver.txt c:\temp\server.txt
working... what is the problem?
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: first cannot conver std::string to const char, now runtime error!

 
1
  #19
Sep 25th, 2006
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 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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,615
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 466
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: first cannot conver std::string to const char, now runtime error!

 
0
  #20
Sep 25th, 2006
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?
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC