|
-
Aug 29th, 2002, 05:14 PM
#1
Thread Starter
Ya ya Baby!!!Me is Back
char* problem
How can I do that witout having an error, I want to put a char* to char[30].
Example :
Code:
char sNom[30];
//************This is somewhere else
string s = sTexteAnalyser.substr(0,sTexteAnalyser.find('\n',0));
sNom = s.c_str() ;
Error : cannot convert from "const char*" to "char[30]"
Tell me what to do please
-
Aug 29th, 2002, 05:41 PM
#2
Fanatic Member
Try:
Code:
#include <cstring>
using namespace std;
//...
strcpy(sNom, s.c_str());
Beware, you can crash your program if the .c_str() returns a string longer than 30 characters.
Alcohol & calculus don't mix.
Never drink & derive.
-
Aug 29th, 2002, 05:47 PM
#3
Thread Starter
Ya ya Baby!!!Me is Back
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|