/* C program: atoi function use Description: atoi function convert string to integer representation of integral numbers. Example 1: string "02302" converts to number 2302 Example 2: string "abcd" returns 0 Example 3: string "-0234" converts to number -234 Example 4: string "0023ABCD" converts to number 23 Example 5: string "12abc45g" converts to number 12 Example 6: string "--0123" returns 0 Example 7: string "" (NULL) returns 0 Example 8: string " 234a" converts to number 234 Example 9: string "+ 239b" returns 0 Example10: string "+239" converts to number 239 Example11: string " +12" converts to number 12 Example12: string " -12" converts to number -12 Compiler: Turbo C++ 3.0 Author: Mangilal Sharma Date: September 12, 2015 Program for: world-of-c-programming.blogpost.com Program number: 101 */ #include<stdio.h> //for printf and gets #include<conio.h> //for clrscr and getch #include<stdlib.h> //for atoi #include<string.h> //for strcpy void main() { char string[] = "02302"; clrscr(); printf("String value = %s, Int value = %d\n",string,atoi(string)); strcpy(string,"C Program"); printf("String value = %s, Int value = %d\n",string,atoi(string)); printf("Press y for try your strings to atoi function.\n"); printf("Press any other key to exit.\n"); while(getch() == 'y') { printf("Enter String and press enter:"); gets(string); printf("String value = %s, Int value = %d\n",string,atoi(string)); } }
This is a try to put the solutions of each possible problem related to C and C++. You can find here C basic lab, C++ basic Lab, Data Structure Lab, DAA Lab, Operating System Lab, Graphics Lab, Compiler Lab, Network Lab, and other problems.
Saturday, 12 September 2015
C Program to Demonstrate use of atoi Function
Subscribe to:
Post Comments (Atom)
nice article for beginners.thank you.
ReplyDeletec tutorial
java tutorial