⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 copyit.c

📁 里面包含很多c语言的源码
💻 C
字号:
/* Copying a file. */

#include <stdio.h>

int file_copy( char *oldname, char *newname );

int main( void )
{
    char source[80], destination[80];

    /* Get the source and destination names. */

    printf("\nEnter source file: ");
    gets(source);
    printf("\nEnter destination file: ");
    gets(destination);

    if ( file_copy( source, destination ) == 0 )
        puts("Copy operation successful");
    else
        fprintf(stderr, "Error during copy operation");
    return(0);
}
int file_copy( char *oldname, char *newname )
{
    FILE *fold, *fnew;
    int c;

    /* Open the source file for reading in binary mode. */

    if ( ( fold = fopen( oldname, "rb" ) ) == NULL )
        return -1;

    /* Open the destination file for writing in binary mode. */

    if ( ( fnew = fopen( newname, "wb" ) ) == NULL  )
    {
        fclose ( fold );
        return -1;
    }

    /* Read one byte at a time from the source; if end of file */
    /* has not been reached, write the byte to the */
    /* destination. */

    while (1)
    {
        c = fgetc( fold );

        if ( !feof( fold ) )
            fputc( c, fnew );
        else
            break;
    }

    fclose ( fnew );
    fclose ( fold );

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -