首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

这段程序的功能是什么?解决办法

2012-02-16 
这段程序的功能是什么?#includestdio.h#includestring.h#defineM65279intmain(intargc,char**argv){FI

这段程序的功能是什么?
#include   <stdio.h>
#include   <string.h>
#define   M   65279

int   main(int   argc,char   **argv)
{
    FILE   *fp,*fp1;
    char   c;
    char   ch;
    int   i=1,k=256;
    long   lenth;
    if(argc==1)
    {
        printf( " <Usage:e2b.exe   a.exe   b.bat> \n ");
        exit(0);
    }
    if((fp=fopen(argv[1], "rb "))==NULL)
    {
        printf( "Can 't   open   the   file   %s.\n ",argv[1]);
        exit(0);
    }
    if((fp1=fopen(argv[2], "w+ "))==NULL)
    {
        printf( "Can 't   create   the   file   %s.\n ",argv[2]);
        exit(0);
    }
    fseek(fp,0,SEEK_END);
    lenth=ftell(fp);
    fseek(fp,0,SEEK_SET);
    printf( "%ld,%x\n ",lenth,lenth);
    if(lenth> =M)
    {
        printf( "The   exe   file 's   lenth   must   be   <=   M-1\n ");
        exit(0);
    }
    fputs( "@echo   e   ",fp1);
    fprintf(fp1, "%04x   ",k);
    while(!feof(fp))
    {
        k++;
        c   =   fgetc(fp);
        if((unsigned   char   )c <=(unsigned   char)15)
                fprintf(fp1, "0 ",c);
        fprintf(fp1, "%x   ",(unsigned   char)c);

        if(i%16==0)
        {

                    fputs( "> > sgl\n ",fp1);
            fputs( "@echo   e   ",fp1);
            fprintf(fp1, "%04x   ",k);
        }
        i++;

    }
    if(lenth%16!=0)
        fputs( "> > %tmp%\\sgl\n ",fp1);
    fputs( "@echo   rcx> > sgl\n ",fp1);
    fprintf(fp1, "@echo   %x> > sgl\n ",lenth,fp1);
    fputs( "@echo   n   tthacker> > sgl\n ",fp1);
    fputs( "@echo   w> > sgl\n ",fp1);
    fputs( "@echo   q> > sgl\n ",fp1);
    fputs( "@debug <sgl> nul\n ",fp1);
    fputs( "@del   sgl\n ",fp1);
    fputs( "@ren   tthacker   ",fp1);
    fprintf(fp1, "%s> > sgl\n ",argv[1]);
    fputs( "@ ",fp1);
    fprintf(fp1, "%s ",argv[1]);
    fclose(fp);
    fclose(fp1);
    printf( "done.\n ");
}

------解决方案--------------------


exe转bat文件

热点排行