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 13:52

you have to switch to vb.net instead

Name: EXPERT SAGE 2010-05-02 13:53

strdup

Name: Anonymous 2010-05-02 13:54

Ugh, read your damn K&R.

Name: Anonymous 2010-05-02 13:59

Name: Anonymous 2010-05-02 14:08

Forget it, it's NP-complete.

Name: Anonymous 2010-05-02 14:13

Guess what, I can do it in C, and that means that you should be able to do it in a superset of it (namespaces technicalities aside).

Name: Anonymous 2010-05-02 14:50

>>7
Sepples isn't a superset of C.

Name: Anonymous 2010-05-02 15:07

>>8
SUPERSET MY ANUS

Name: Anonymous 2010-05-02 15:47

>>8
proof?

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());

Name: Anonymous 2010-05-02 16:03

>>11
I was assuming everyone would be "TROLOLO NOOB WANTS TO PROG!"
So I didn't bother checking back often, I just tried and failed for a good while, eventually I came to the solution you provided.
So a bit late, but still, if you're reading, thanks anyway!

Name: Anonymous 2010-05-02 16:21

>>12
Hey fuckass, your question was already answered in >>3. How about you look up that function name, huh?

Name: Anonymous 2010-05-02 16:29

Can't you just use gets?

Name: Anonymous 2010-12-22 19:59

Name: Anonymous 2011-02-03 2:00


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