看板 C_and_CPP 關於我們 聯絡資訊
C 的 strto?? 我覺得也滿好用的 #include <stdio.h> #include <stdlib.h> #include <string.h> int main (void) { char str[80]; char *endptr; int i; printf("Enter a string for long int conversion: "); gets(str); i = strtol(str, &endptr, 2); if (endptr == str) printf("That is not a valid string\n"); else { printf("The converted int is %d\n", i); if (strlen(endptr) != 0) printf("The remaining string from your input is \"%s\"\n", endptr); } return 0; } Reference: http://www.digitalmars.com/rtl/stdlib.html#strtol -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.120.46.89
Dannvix:推! 05/08 18:55
loveme00835:似層相似的感覺 囧> 05/08 18:57
VictorTom:還真的不認識這個函數XD 05/08 23:04