字符串的分割
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<cstdio>
using namespace std;
int main()
{
char str[105], s1[20], s2[20], num1[15], num2[15];
memset(str, 0, 105);
memset(s1, 0, 20);
memset(s2, 0, 20);
memset(num1, 0, 15);
memset(num2, 0, 15);
int i = 0, j = 0;
fgets(str, 104, stdin);
while (str[i] != '=') {
s1[j++] = str[i++];
}
j = 0;
while (str[i] != ',') {//从等号开始
num1[j++] = str[i++];
}
j = 0;
while (str[i] != '=') {//从逗号开始
s2[j++] = str[i++];
}
j = 0;
while (str[i] != '\0'&&str[i]!='\n') {//从等号开始
num2[j++] = str[i++];
}
cout << s1 << num2 << s2 << num1 << endl;
return 0;
}
#include<string.h>
#include<stdio.h>
#include<cstdio>
using namespace std;
int main()
{
char str[105], s1[20], s2[20], num1[15], num2[15];
memset(str, 0, 105);
memset(s1, 0, 20);
memset(s2, 0, 20);
memset(num1, 0, 15);
memset(num2, 0, 15);
int i = 0, j = 0;
fgets(str, 104, stdin);
while (str[i] != '=') {
s1[j++] = str[i++];
}
j = 0;
while (str[i] != ',') {//从等号开始
num1[j++] = str[i++];
}
j = 0;
while (str[i] != '=') {//从逗号开始
s2[j++] = str[i++];
}
j = 0;
while (str[i] != '\0'&&str[i]!='\n') {//从等号开始
num2[j++] = str[i++];
}
cout << s1 << num2 << s2 << num1 << endl;
return 0;
}