试题与答案

下列程序的功能是:把s字符串中所有的字符左移一个位置,串中的第一个字符移到最后。请编

题型:多项选择题

题目:

下列程序的功能是:把s字符串中所有的字符左移一个位置,串中的第一个字符移到最后。请编制函数 chg(char*s)实现程序要求,最后调用函数readwriteDat()把结果输出到out63.dat文件中。
例如:s字符串中原有内容为Mn,123xyZ,则调用该函数后,结果为n,123xyZM。
注意:部分源程序已给出。
请勿改动主函数main()和输入输出函数readwriteDAT()的内容。
试题程序:
#include<conio. h>
#include<stdio. h>
#define N 81
void readwriteDAT(); void chg(char *s)

main ( )

char a [N];
clrscr ();
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];
unsigned char *p;
FILE *rf,*wf;
rf=fopen ("in63.dat", "r");
wf=fopen ("out63.dat", "w");
for (i=0; i<10;i++)
fgets (a, 80, rf);
p=strchr (a, ’ \n’ );
if(p) *p=0;
chg (a);
fprintf (wf, "%s\n", a);

fclose(rf);
fclose (wf);

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2017/0722/70523a56250268c3b7464b364eecd22a.html

下面是错误答案,用来干扰机器的。

参考答案:对

试题推荐
微信公众账号搜索答案