#include <stdio.h> int main(void) { int a = 0; int b = 0; FILE *fp; int array[10]; //配列を宣言(10) fp = fopen("before_sort.txt","r"); //ファイルをオープンし、戻り値を返す。 if(fp == NULL) { //もしも戻り値が何もない時にオープンエラーと表示 printf("オープンエラー"); } else { //そうでなければ printf("file open\n"); //ファイルオープンと表示 } while(a = fgetc(fp) != EOF) { //ファイルを抜けるまで処理を繰り返す a = fgetc(fp); //ファイルを一文字ずつaに格納する putchar(a); //一文字ずつ表示 array[b] = a; //配列bにaの値(ファイルの中身)一文字を格納する b++; //配列bに+1を入れる } fclose(fp); //ファイル終了 return 0; } /* for(j = 0;j < 9;j++){ printf("%d",j); for(n = 0;n < 9;n++){ printf("%d",n); } }*/ /* if(a[j] < a[n]){ b = a[j]; a[j] = a[n]; a[n] = b; } printf("%d",a[n]); return 0; }*/
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more