Skip to main content
gamedev.net
🔒 Locked

string help please?

Started by Arbz Jun 12, 2002 at 4:50 PM 3 replies 150+ views
Original Post
Arbz
Arbz
hi. i dunno if this has been answered before, but the search function didnt seem to be working for me. ok, what i want to do, i want to get a single letter out of a c++ string object by using the substr() function and storing it in a pre prepared (dynamic) int (but still just one character) to get the ASCII code, or whatever it is when ''56'' is 8. (hold down ALT and type 56). What i tried doing was: iSomeArray[1] = sSomeString.substr(5); *(piSomeArray+1) = sSomeString.substr(5); but it doesnt seem to work, saying something about conversion! how can i get a single character out of a string and store its value in an int? (it works with single CHARS). Thanks Arbz btw, im using VC++ 6 on winXP pro
felonius
felonius
Have you tried just taking it out with an array index:

int myint = int(sSomeString[5]);

Jacob Marner, M.Sc.Console Programmer, Deadline Games
fallenang3l
fallenang3l
char letter = sSomeString[index]?
Arbz
Arbz
thanks for all the replies. the answer was simpler than i thought.

arbz

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.