下列程序的功能是:把s字符串中的所有字符左移一个位置,字符串中的第一个字符移到最后。请编写函数chg(char*s)实现程序要求,最后调用函数readwriteDAT()从in.dat文件中读取50组数据,分别得出结果,且把结果输出到out.out文件中。
例如:s字符串中原有内容为:Mn.123xyZ,调用该函数后结果为:n.123xyZM。
注意:部分源程序已经给出。
请勿改动主函数main()和输出数据函数readwriteDAT()的内容。
#include<string.h>
#include<stdio.h>
#define N 81
void readwriteDAT();
void chg(char*s)
main()
char a[N];
printf("Enter a string:");
gets(a);
printf("The original string is:");
puts(a);
chg(a);
printf("The string after modified:");
puts(a);
readwriteDAT();
void readwriteDAT()
int i;
char a[N];
FILE *rf,*wf;
rf=fopen("in.dat","r");
wf=fopen("out.dat","w");
for(i=0;i<50; i++)
fscanf(rf,"%s",a);
chg(a);
fprintf(wf,"%s\n",a);
fclose(rf);
fclose(wf);