Chinaunix首页 | 论坛 | 博客
  • 博客访问: 816807
  • 博文数量: 321
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 936
  • 用 户 组: 普通用户
  • 注册时间: 2013-02-23 11:25
文章分类

全部博文(321)

文章存档

2017年(1)

2016年(10)

2015年(61)

2014年(187)

2013年(62)

分类: C/C++

2014-06-20 10:37:15

#include <stdio.h>
#include <stdlib.h>


int main(int argc, char *argv[])
{
    FILE *fp;
    char str[80];
    int i;
    if((fp = fopen("test","w")) == NULL)
    {
        printf("不能打开文件。\n");
        exit(0);
    }

    printf("Please enter a string and a number:\n");
    fscanf(stdin, "%s %d", str, &i);
    fprintf(fp, "%s %d",str, i);
    fclose(fp);

    if((fp = fopen("test","r")) == NULL)
    {
        printf("不能打开的文件.\n");
        exit(0);
    }

    fscanf(fp, "%s %d", str, &i);
    fprintf(stdout, "%s %d\n", str, i);
    fclose(fp);

    system("pause");
    return 0;
}


阅读(370) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~