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.
(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])
Jump to Post
First 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';
Or you can use atol() to convert a string …
All 7 RepliesReply to this topic
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.