Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Read line from .txt, store in char*

Name: Anonymous 2010-05-02 13:51

This! Is! C++!
Is this impossible?
I'm only able to store stuff in strings. But strings cannot be converted to char*, only const char*. And const char* can't be used in place of char*.

Can't I just do something like getline(char* text,256,' ')? Or will have I have to copy data from a string into a char*?

Name: Anonymous 2010-05-02 15:54

// assuming s is the String
char* char_s = new char[(s.length()+1)];
// char* char_s = (char*)malloc( sizeof(char)*(s.length()+1) );
strcpy(char_s, s.c_str());

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List