Hàm ATOI

#include<iostream> using namespace std; #include<stdio.h> #include<stdlib.h> #include<conio.h> #include<string.h> #include<math.h> int ATOI(char *s) { int tong=0; int dodai=strlen(s); int tem=dodai; for(int i=0;i<dodai;i++) { tong+=(s[i]-48)*pow(10.0,--tem); } return tong; } int main() { char s[]="a563657"; int so= atoi(s); printf(" so bang %d", so); int so1= ATOI(s); printf(" so bang %d", so1); getch(); return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.