| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 514 人关注过本帖, 1 人收藏
标题:关于文件复制问题代码
取消只看楼主 加入收藏
泪水清痕
Rank: 1
等 级:新手上路
帖 子:17
专家分:1
注 册:2011-4-22
结帖率:100%
收藏(1)
 问题点数:0 回复次数:0 
关于文件复制问题代码
// l10_1.2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 10
int _tmain(int argc, _TCHAR* argv[])
{
    FILE*fp;
    char ch1[SIZE];
    char ch2[SIZE];
    char ch3[SIZE];
    printf("请输入三个字符串:\n");
    gets(ch1);
    gets(ch2);
    gets(ch3);
    if((fp=fopen("string.txt","w"))==NULL)
    {
        printf("Cannot open file strike any key exit!");
        exit(-1);
    }
    fputs(ch1,fp);
    fputs(ch2,fp);
    fputs(ch3,fp);
    fclose(fp);
    char ch4[SIZE*3]={0};
    if((fp=fopen("string.txt","r"))!=NULL)
    {
        
        fgets(ch4,SIZE*3,fp);
        printf("您输入的字符串为:");
        puts(ch4);
        fclose(fp);
    }
    char ch5[SIZE*3];
    if((fp=fopen("string2.txt","w"))==NULL)
    {
        printf("Cannot open file strike any key exit!");
        exit(-1);
    }
    strcpy(ch5,ch4);
    fputs(ch5,fp);
    fclose(fp);
    if((fp=fopen("string2.txt","r"))==NULL)
    {
        printf("Cannot open file strike any key exit!");
        exit(-1);
    }
    fgets(ch5,SIZE*3,fp);
    fclose(fp);
    _getch();
    return 0;
}

红色的字体是复制已有的文件内容
搜索更多相关主题的帖子: include 字符串 file 
2012-08-06 17:27
快速回复:关于文件复制问题代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017909 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved