Mar 26, 2002 #1 Guest_imported New member Joined Jan 1, 1970 Messages 0 Can any body let me know how to write a atoi conversion of string into integer programm in C++ Thanks for ur help. IA Khan
Can any body let me know how to write a atoi conversion of string into integer programm in C++ Thanks for ur help. IA Khan
Mar 26, 2002 #2 butthead Programmer Joined Feb 24, 2002 Messages 545 Location US see help example for "atoi" #include <stdlib.h> #include <stdio.h> int main(void) { int n; char *str = "12345.67"; n = atoi(str); printf("string = %s integer = %d\n", str, n); return 0; } Upvote 0 Downvote
see help example for "atoi" #include <stdlib.h> #include <stdio.h> int main(void) { int n; char *str = "12345.67"; n = atoi(str); printf("string = %s integer = %d\n", str, n); return 0; }
Mar 27, 2002 #3 Zyrenthian Programmer Joined Mar 30, 2001 Messages 1,440 Location US on the example above the output will be 12345 because atoi will stop at the decimal. If you want to get the full decimal value, use atof. Matt Upvote 0 Downvote
on the example above the output will be 12345 because atoi will stop at the decimal. If you want to get the full decimal value, use atof. Matt
Apr 3, 2002 #4 butthead Programmer Joined Feb 24, 2002 Messages 545 Location US I didnt see the decimal when I copied and pasted. My fingers are quicker than my brain. Upvote 0 Downvote