c-canf()vs get()vs fget()
scanf()
, gets()
fgets()
#include <stdio.h>#define MAX 100int CharToInt(const char *);int main(){ char str[MAX]; printf(" Enter some numbers (no spaces): "); gets(str);// fgets(str, sizeof(str), stdin);// scanf("%s", str); printf(" Entered number is: %d\n", CharToInt(str)); return 0;}int CharToInt(const char *s){ int i, result, temp; result = 0; i = 0; while(*(s+i) != '\0') { temp = *(s+i) & 15; result = (temp + result) * 10; i++; } return result / 10;}
gets()
fgets()
fgets()
scanf()
gets()
fgets()
scanf()
慕哥6287543
摇曳的蔷薇
相关分类