0 votes
in C Plus Plus by
How can a string be converted to a number?

1 Answer

0 votes
by

The function takes the string as an input that needs to be converted to an integer.

int atoi(const char *string)

Return Value:

  • On successful conversion, it returns the desired integer value
  • If the string starts with alpha-numeric char or only contains alpha-num char, 0 is returned.
  • In case string starts with numeric character but is followed by alpha-num char, the string is converted to integer till the first occurrence of alphanumeric char.

Related questions

0 votes
asked Jan 11 in C Plus Plus by GeorgeBell
0 votes
asked Jan 12 in C Plus Plus by GeorgeBell
...