53 เปลี่ยนข้อความตัวเลขให้เป็นตัวเลข


  • ฟังก์ชั่นพวกนี้อยู่ใน stdlib.h
  • int atoi (const char *strNumber ) ; / / array to interger เปลี่ยนอักษรให้เป็น int
  • long atol (const char *strNumber ) ; / / array to interger เปลี่ยนอักษรให้เป็น long
  • long long atoll (const char *strNumber ) ; / / array to interger เปลี่ยนอักษรให้เป็น long long
  • float atof (const char *strNumber); / / array to float เปลี่ยนอักษรให้เป็น float

#include <stdio.h>
#include <stdlib.h>
int main(void) {
printf("%d\n" , atoi("34")+1);
printf("%ld\n" , atol("34")+1);
printf("%lld\n" , atoll("34")+1);
printf("%f\n" , atof("35.345"));
return 0;
}
view raw B53_atoi_atof.c hosted with ❤ by GitHub