-
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
-
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.
-