前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
| ファイル名 | 説明 | 
|---|---|
| Main.cpp | メインプログラムのファイル | 
| Text.cpp | 関数を記述したファイル | 
/*★ GetText Main Program    前田 稔 ★*/
#include <stdio.h>
#include <conio.h>
char    buf[10000];
extern  unsigned  int GetText(char *file, char *buf, unsigned int siz);
extern  void PutMsg(char *buf, unsigned int siz);
//Main Program
void  main()
{   char    file[256];
    printf("入力ファイル名をタイプして下さい\n");
    scanf_s("%s",file,256);
    GetText(file,buf,10000);
    PutMsg(buf,200);
    _getch();
}
 | 
/*★ GetText Function     前田 稔 ★*/
#include <stdio.h>
unsigned int  GetText(char *file, char *buf, unsigned int siz)
{   FILE    *FI;            //FILE の定義
    unsigned int len;       //入力長
    if (fopen_s(&FI,file,"rb")!=0)
    {   printf("INPUT FILE open error[%s]\n",file);
        return 0;
    }
    len= fread(buf,1,siz,FI);
    *(buf+len) = '\0';
    fclose(FI);
    return len;
}
void  PutMsg(char *buf, unsigned int siz)
{   char wk;
    wk = *(buf+siz);
    *(buf+siz) = '\0';
    printf("%s\n",buf);
    *(buf+siz) = wk;
}
 | 
![]()