Converting String to Int

Hey guys ,

Just wondering if there is any method to convert a string to an int.

Like convert "hello" into int or double.

The thing i want to do is to check for spaces new lines and other punctuations within a text file.

Thanks in advance.
Well...you could convert a 'numerical' string to an integer, but I have no idea how you would convert something like "hello" to a number of any sort.
theonealone wrote:
The thing i want to do is to check for spaces new lines and other punctuations within a text file.


loop through each character in the string, and call isalnum() on each character

http://www.cplusplus.com/reference/clibrary/cctype/isalnum/

or, write your own bool is_a_char_that_i_want(char c) function
Thanks alot. I shall try and implement that strategy.
will this also work for white spaces and newlines ??
Using by atoi(string) function to achieve it
Topic archived. No new replies allowed.