C Programming - Library Functions - Discussion

5. 

scanf() or atoi() function can be used to convert a string like "436" in to integer.

[A]. Yes
[B]. No

Answer: Option A

Explanation:

scanf is a function that reads data with specified format from a given string stream source.
scanf("%d",&number);

atoi() convert string to integer.
var number;
number = atoi("string");


Ankur said: (Jul 30, 2010)  
I am not able to understand how scanf is used here. Can anyone elaborate on this.?

Praveen said: (Jan 1, 2012)  
Question is not interpreted correctly.

Bobby said: (Feb 21, 2012)  
scanf("%c",&number);//char value
scanf("%d",&number);//int value
becoz these value are stored in ASCII value...
as same is atoi()

Maithili said: (Sep 14, 2016)  
How does scanf convert a string into an integer?

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.