본문 바로가기
코스웨어/13년 스마트컨트롤러

hexaview로 파일 내용 출력 _ 진종영

by 알 수 없는 사용자 2013. 5. 3.
728x90
반응형

_________________________________main_________________________________

#include <stdio.h>
#include <process.h>
#include "hexaview.h"

int main(int argc, char *argv[])
{
    FILE *fp;
    unsigned char RData[512]={0};
    unsigned int count = 0;
    unsigned int count2 = 0;
    unsigned int iSum = 0;
    

  

    if(argc != 2)
    {
         printf("Conmmand parameter not correct!\n");
         exit(-1);
    }
    if((fp = fopen (argv[1], "r")) == NULL)
    {
         printf("Can not open file %s\n", argv[1]);
         exit(-1);
    }
    fflush(stdin);
   

    //while((RData[count] = getc(fp)) != EOF)//255
    while0 == feof(fp))
    {
         RData[count] =  getc(fp);
 
    
         ++count;
         ++iSum;
         if(count >= sizeof(RData))
         {
             hexaview(RData, count);
             count = 0;
             printf("계속하려면아무키나 누르시오...\n");
             getchar();
             fflush(stdin);
         }
    
     }
     if(iSum > 512)
     {
         count2 = count;
         while(count < sizeof(RData))
         {
             RData[count-1] = 0;
             ++count;
         }
    
         hexaview(RData, count2);
         printf("file %s contains %d characters.\n", argv[1], iSum);
     }
     else
     {
         RData[count-1] = 0;
         hexaview(RData, count);
         printf("file %s contains %d characters.\n", argv[1], count);
     }
 
    

     fclose(fp);

     return 0;
}

 

______________________________________________________________________

 

실행결과

 

 

 

 

 

 

___________________test2.dat__________________________

Good Great Amazing Marvellous Excellent Awesome
Attractive Qurious Fantastic Elegant Astonishing
Gorgeous Fascinating Lovesome Sensational Qurious
Fancy Pitapatting pi pitapatting Tremble Tremble
Tremble I I I love you I I I love you
Attractive Qurious Qurious
Good Great Amazing Marvellous Excellent Awesome
Attractive Qurious Fantastic Elegant Astonishing
Gorgeous Fascinating Lovesome Sensational Qurious
Fancy Pitapatting pi pitapatting Tremble Tremble
Tremble I I I love you I I I love you
Attractive Qurious Qurious
Good Great Amazing Marvellous Excellent Awesome
Attractive Qurious Fantastic Elegant Astonishing
Gorgeous Fascinating Lovesome Sensational Qurious
Fancy Pitapatting pi pitapatting Tremble Tremble
Tremble I I I love you I I I love you
Attractive Qurious Qurious
Good Great Amazing Marvellous Excellent Awesome
Attractive Qurious Fantastic Elegant Astonishing
Gorgeous Fascinating Lovesome Sensational Qurious
Fancy Pitapatting pi pitapatting Tremble Tremble
Tremble I I I love you I I I love you
Attractive Qurious Qurious
Good Great Amazing Marvellous Excellent Awesome
Attractive Qurious Fantastic Elegant Astonishing
Gorgeous Fascinating Lovesome Sensational Qurious
Fancy Pitapatting pi pitapatting Tremble Tremble
Tremble I I I love you I I I love you
Attractive Qurious Qurious
Good Great Amazing Marvellous Excellent Awesome
Attractive Qurious Fantastic Elegant Astonishing
Gorgeous Fascinating Lovesome Sensational Qurious
Fancy Pitapatting pi pitapatting Tremble Tremble
Tremble I I I love you I I I love you
Attractive Qurious Qurious END OF FILE.

____________________________________________________ 

 

728x90