c语言switch语句char
问题描述:
写函数switch(chars1,chars2),将两个数组中的数据进行互换。
答
你题目的解答代码如下:(如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮)
#include <stdio.h>
#include <string.h>
void swap(char s1[],char s2[])
{
char buff[100];
strcpy(buff,s1);
strcpy(s1,s2);
strcpy(s2,buff);
}
int main(){
char s1[100] = "abc";
char s2[100] = "123";
swap(s1,s2);
printf("s1=%s\n", s1);
printf("s2=%s\n", s2);
return 0;
}