等级考试上机题目(上课用)(2)

时间:2026-01-17

{FILE *fp; int i;

STYPE s[10];

if((fp=fopen("myfile5.dat","rb"))==NULL)

{printf("Fail !!\n"); exit(0);}

printf("\nRead file and output to screen :\n");

printf("\n num name tel\n");

for(i=0; i<N; i++)

{fread(&s[i],sizeof(STYPE),1, fp);

printf("%6d %s %s\n",s[i].num, s[i].name,s[i].tel);

}

fclose(fp);

}

2.改错题

#include <stdio.h>

#include <string.h>

void fun (char *s, char *t)

{int i, sl;

sl = strlen(s);

/************found************/

for(i=0; i<=s1; i ++)

t[i] = s[i];

for (i=0; i<sl; i++)

t[sl+i] = s[sl-i-1];

/************found************/

t[sl] = '\0';

}

main()

{char s[100], t[100];

printf("\nPlease enter string s:"); scanf("%s", s);

fun(s, t);

printf("The result is: %s\n", t);

}

2

等级考试上机题目(上课用)(2).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:4.9 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:19元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219