|

楼主 |
发表于 2020-3-8 10:59:12
|
显示全部楼层
- #define _CRT_SECURE_NO_WARNINGS
- #include "stdio.h"
- #include "string.h"
- #include "stdlib.h"
- void getStr(char* myp, char c, char buf[10][20]) //问题 为啥这里char*myp 用一级指针?啥时候用二级的?
- {
- int i;
- if (myp == NULL)
- {
- return;
- }
- int count = 0;
- int e = 0;
- for (i = 0; myp[i]; i++)
- {
- if (myp[i] != c)
- {
- buf[count][e++] = myp[i];
- buf[count][e] = '\0';
- }
- else
- {
- count++;
- e = 0;
- }
- }
- }
- void main()
- {
- int i;
- int j;
- char* p = "abcdef,acccd,eeee,aaaa,e3eeeee,sssss";
- char c = ',';
- char buf[10][20];
- getStr(p, c, buf);
- for (i = 0; i < 6; ++i)
- {
- printf("%s\n", buf[i]);
- }
- system("pause");
- }
复制代码 |
|