atoi

i know what is the use of atoi function....
converts string to int.

but whenever i use that it gives me 0....
could any one help in this issue..

eg.
int i;
char str[20];
str="name";
i=atoi(str);
i gives me 0. why?

bankpro, the function atoi just recognises
1) An optional string of tabs or spaces
2) An optional sign &
3) A string of digits

And upon recognising it converts it to int otherwise on failure it returns 0.
So if u try to convert a string like "name" u'll b getting 0 as it doesn't recognise it. If u try something like "22" or "-22" or even " -22" it would return int (here 22 or -22 as the case be).
I hope this clears ur doubt

The standard for atoi is to read along a string from a given starting point until it encounters a space, a nul, or a non-numeric character. "name" starts with an "n" which is non-numeric. atoi is finsihed before it starts. By definition, atoi returns 0 in that case.

what is the purpose that is aimed for in converting a string literal "name" to an integer?