前提
テキストファイルにある英文をabc順にソートを行うものを前回自分がした質問を参考に作成しましたが,text[i][4096]の列にあたる箇所がなぜ4096バイトという情報を持つのかが手元の参考書など見ても理解できませんでした.
実現したいこと
前提に記述したことの理解
発生している問題・エラーメッセージ
試したこと
前回した質問で指摘されたのでそのソースコードの確認や手元の教科書,インターネットで二次元配列について調べてみたのですが理解できませんでした.
該当のテキストファイル
tactile graphics are adaptations of visual graphics in which lines have been raised and areas elevated or textured to make them accessible to touch.
該当のソースコード
ソースコード
#include <stdio.h> #include <string.h> #define N 148 int main(void) { FILE *fp = fopen("data12.txt", "r"); int i = 0, j; char text[N][4096], c, tmp[4096]; while ((c = fgetc(fp)) != EOF) { text[i][4096] = c; i++; } for (i = 1; i < N; i++) { for (j = 1; j < N; j++) { if (strcmp(text[j - 1], text[j]) > 0) { strcpy(tmp, text[j - 1]); strcpy(text[j - 1], text[j]); strcpy(text[j], tmp); } } } fp = fopen("result12.txt", "w"); for(i=0;i<N;i++) if(*text[i] != ' ') fprintf(fp,"%s", text[i]); fclose(fp); return 0; }
回答4件
あなたの回答
tips
プレビュー