#include #include #include int a = 0; int l = 0; int main() { char copu [10][100]; char str[100]; char ooo[100]; printf_s("请输入你想分割的字符串,且用分号分割开\n"); puts(str); int sz = 0, fh = 0, fhq = 0; //sz是分组,fh是有几个分号,fhq是分号之间的数目 int n = 0; while (str[n]!='\0') //当str不为0的时候 { if (str[n] == ';') //出现分号时 n为分号的数字 { if (fh == 0) //出现第一个分号 { fhq = n; //fhq=分号前的数字 memcpy(ooo, str, fhq+1); //复制str前的fhq的数给ooo数组 ooo[fhq + 1] = '\0'; //令ooo数组分号之后的那个数为休止符 for (int e = 0;e < fhq + 1;e++) { copu[sz][e] = ooo[e]; }; sz++; //多了一组 n++; //n变大 fh++; //分号+1' a = n; } else { int i = n; int p = n - fhq; memcpy(ooo, str + fhq + 1, p + 1); for (int e = 0;e < p + 1;e++) { copu[sz][e] = ooo[e]; }; sz++; n++; fh++; a = n; } } n++; if (str[n] == '\0') //到最后出现\0的时候,首先要计算分号之间的个数,然后将+1变成;,+2变成\0 { int w = n - a; int z = n - fhq; memcpy(ooo, str + a + 1, w + 1); for (int e = 0;e < w + 1;e++) { copu[sz][e] = ooo[e]; }; copu[fh][w-1] = ';'; copu[fh][w + 2] = ';'; l = fh; n++; fh++; } } for (int s = 0;s < l-1;s++) { printf("%s\n", copu[s]); }; return 0; } 这是我写的代码,可以编译,但是输入后无法运行,不知道有什么问题,会出现烫烫的乱码