1.

How can a string be converted to a number?

Answer»

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.
Converting String to NUMBER


Discussion

No Comment Found