愚問をてってれーするの楽しすぎるでしょβ

ESRのエッセイに唆されてPythonする初心者が半端な勉強ログを書き散らす場所 ICT文化にどうしても住みたいという遠大な啓示が下った人の住処/気持ちよさのためだけに/お客様のお忘れになった恥の概念が母胎に届いているようです

Counting Characters in C

MacOS上のUbuntu使ってて、言語設定を変更できなかったので、無理矢理英語で書いてたやつ。

As always, it's done online. (IDEs never behave well!!!!)

http://codepad.org(よく考えたら、paizaとかのエディタも同じ機能か!機能の上ではオンラインエディタ=オンラインコンパイラですよね)

#include <stdio.h> /* Display character frequents in a file*/



#define LIST_MAX 300 //What is this pre-processor??#defineは文字列を他の文字列等に変換する働き.This function on a compilar!?!? 



//Line2 means, LIST_MAX gonna be changed into 300.



//the 2 has no data type...











int main(){//I know it's the beginning of this scoop, everything is mainly defined here.



    int i, CHcount[LIST_MAX];//i and CHcount is given as int, and its value is 300



    char ch, CHlist[LIST_MAX];//why is it char? though it's defined 300



    FILE *textin;//what is this about??







    for(i=0; i<LIST_MAX; i++)



        CHcount[i]=0; /* count 0 for each char */



        CHlist[i]=0; /* default character */



    }







    textin = fopen("test.txt", "r");



    do{



        ch+fgetc(textin);



        for(i=0; ((i<LIST_MAX) && (CHlist[i] !=0)); i++){



            if(ch==CHlist[i])//&& means logical conjunction



                break;



        }



        if(CHcount[i]>0){



            00000000000000;



        }else{



            00000000000000;



            00000000000000;



        }



    }while((ch 1= EOF));







    for(i=0; ((0000000000) && (0000000000)); i++){



        printf("%c = %d 

", CHlist[i], CHcount[i]);



        }



    fclose(textin);



}/* end of chcount.c */

 

 Output:

1



2



3



4



5



6



7



8



9



10



11



12



Line 14: warning: data definition has no type or storage class



Line 14: warning: initialization makes integer from pointer without a cast



Line 14: error: initializer element is not constant



Line 15: error: expected identifier or '(' before 'do'



Line 27: error: expected identifier or '(' before 'while'



Line 29: error: expected identifier or '(' before 'for'



Line 29: error: expected identifier or '(' before numeric constant



Line 29: error: expected ')' before '&&' token



Line 29: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token



Line 32: warning: data definition has no type or storage class



Line 32: warning: parameter names (without types) in function declaration



Line 33: error: expected identifier or '(' before '}' token