PUTWGETW.C
资源名称:C.rar [点击查看]
上传用户:qq5388545
上传日期:2022-07-04
资源大小:29849k
文件大小:1k
源码类别:
界面编程
开发平台:
C/C++
- #include <stdio.h>
- #include <stdlib.h>
- void main(void)
- {
- FILE *fp;
- int word;
- if ((fp = fopen("DATA.DAT", "wb")) == NULL)
- {
- printf("Error opening DATA.DAT for outputn");
- exit(1);
- }
- else
- {
- for (word = 1; word <= 100; word++)
- putw(word, fp);
- fclose(fp);
- }
- if ((fp = fopen("DATA.DAT", "rb")) == NULL)
- {
- printf("Error opening DATA.DAT for inputn");
- exit(1);
- }
- else
- {
- do {
- word = getw(fp);
- if ((word == EOF) && (feof(fp)))
- break;
- else
- printf("%d ", word);
- } while (1);
- fclose(fp);
- }
- }