hi!!!! i'd like to ask if anyone knows how could i possibly use a string as a number...i mean:
i've got something like cin>>word;
but if that word is a number(like 1,2,3... etc) i have to use that number for going in that line.
if user types ''hello'' its ok.but if he types ''4'' i heve to use that number for going at ARRAY[4].
HOOOOOOOOOOOOOW????
(I am using a vector in which the user types words.if he types a number i have to go at that line of vector and begin wgiting all over again from line 4[example])
Ninoaoe
0
Newbie Poster
Recommended Answers
Jump to PostFirst step is to check if the first character is a numeric digit or an alpha character. If its a digit then just subtract '0' to make it binary
char input[]= "4"; int x = input[0] - '0';
Or you can use atol() to convert a string …
Jump to PostIt will not be a simple thing to do.
std::string word = "i want to go to line 2 and begin all over again.so line 2 is going to be replaced just like 3,4,5"; // search word for the first occurence of a digit for(int i = …
All 7 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Ninoaoe
0
Newbie Poster
Ninoaoe
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
vijayan121
1,152
Posting Virtuoso
Ninoaoe
0
Newbie Poster
Ninoaoe
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.