Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
atoi
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
askcq
New Member
Join Date:
Mar 2007
Posts:
63
#1
atoi
Jun 22 '07, 10:34 AM
main() {
int i;
char* ptr ="str";
printf("%d",ato i(ptr));
}
no output is produced ...
pls tell me the problem ...
DeMan
Top Contributor
Join Date:
Nov 2006
Posts:
1799
#2
Jun 22 '07, 10:40 AM
where are you running this program from?
Comment
Post
Cancel
askcq
New Member
Join Date:
Mar 2007
Posts:
63
#3
Jun 22 '07, 01:19 PM
no error it shows while compilation , but after run there is no output ...
iam running this program using VI editor in linux
Comment
Post
Cancel
Silent1Mezzo
New Member
Join Date:
Feb 2007
Posts:
208
#4
Jun 22 '07, 01:25 PM
Originally posted by
askcq
no error it shows while compilation , but after run there is no output ...
iam running this program using VI editor in linux
When I run this it prints out 0 for me.
Comment
Post
Cancel
weaknessforcats
Recognized Expert
Expert
Join Date:
Mar 2007
Posts:
9214
#5
Jun 22 '07, 02:11 PM
Are you really trying to convert the letters s t and r to an int? atoi() returns 0 if the characters in the string do not represent an int value.
A better choice is a string with "123".
Comment
Post
Cancel
svlsr2000
Recognized Expert
New Member
Join Date:
Feb 2007
Posts:
181
#6
Jun 22 '07, 03:01 PM
atoi converts till it encounters ant non numerical characters, ie till someting other then 0 to 9, is encountered. here a is not integer so atoi stops conveerting hence returns zero
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment