标签:color c语言 bsp amp 字符串查找 ++ index end printf
main.c
#include<stdio.h> #include<string.h> #include <stdlib.h> #include <stdio.h> int main(){ char* str = "123,456,789,0123456,123456,0,09,10"; char sub[3]; int count = 0, index = 0; for (index = 0; index < strlen(str); ++index){ if (str[index] == ‘,‘) ++count; if (count == 6) break; } strncpy(sub, &str[index+1], 2); sub[2] = ‘\0‘; printf(sub); //123,456,789 int n = atoi(sub); printf("string = %s integer = %d\n", sub, n); }
end
标签:color c语言 bsp amp 字符串查找 ++ index end printf
原文地址:http://www.cnblogs.com/dong1/p/6215772.html