Language: C

#include<stdio.h> #define COUNT_RESET 0 #define LOOP_RESET 0 unsigned short serch_word(unsigned char * word, unsigned char * sent); unsigned short s_scan_word(unsigned char * str, unsigned short length_max); int main(){ unsigned char word[10]; unsigned char sent[1000]; unsigned short word_length, sent_length; unsigned short count = 0; unsigned char sentence_end[] = {"END_OF_TEXT\n"}; unsigned short i; for(i = 0;i < 10;i++){ word[i] = 0; } for(i = 0;i < 1000;i++){ sent[i] = 0; } word_length = s_scan_word(word, 1000); while(1){ sent_length = s_scan_word(sent, 1000); if(serch_word(sentence_end, sent) == 1){ break; } for(i = 0;i < word_length;i++){ word[i] |= 0x60; } for(i = 0;i < sent_length;i++){ sent[i] |= 0x60; } if(word_length == sent_length){ count += serch_word(word, sent); } for(i = 0;i <= sent_length;i++){ sent[i] = 0; } } printf("%d\n", count); return 0; } /* 関数名：文字列入力 */ /* 概要：文字列を入力する。入力された文字列の長さを返す */ /* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */ /* 戻り値：入力された文字列の長さ */ unsigned short s_scan_word(unsigned char * str, unsigned short length_max) { unsigned short usW_C_count_text = COUNT_RESET; /* 文字列長カウンタ */ unsigned short usW_C_i; /* ループ変数 */ /* 文字列の入力 */ for(usW_C_i = LOOP_RESET;usW_C_i < length_max;usW_C_i++){ scanf("%c", str + usW_C_i); /* 入力終了の処理 */ if((*(str + usW_C_i) == ' ') || (*(str + usW_C_i) == '\n')){ break; } /* 文字数をカウント */ usW_C_count_text++; } /* 文字列長を返す */ return usW_C_count_text; } unsigned short serch_word(unsigned char * word, unsigned char * sent) { unsigned int frg = 0; unsigned int i = 0; while(1){ if(*(word + i) == '\n'){ frg =1; } if(*(word + i) != *(sent + i)){ break; } i++; } return frg; } 


Compiler output:
main.c:1:19: warning: extra tokens at end of #include directive
    1 | #include<stdio.h> #define COUNT_RESET 0 #define LOOP_RESET 0 unsigned short serch_word(unsigned char * word, unsigned char * sent); unsigned short s_scan_word(unsigned char * str, unsigned short length_max); int main(){ unsigned char word[10]; unsigned char sent[1000]; unsigned short word_length, sent_length; unsigned short count = 0; unsigned char sentence_end[] = {"END_OF_TEXT\n"}; unsigned short i; for(i = 0;i < 10;i++){ word[i] = 0; } for(i = 0;i < 1000;i++){ sent[i] = 0; } word_length = s_scan_word(word, 1000); while(1){ sent_length = s_scan_word(sent, 1000); if(serch_word(sentence_end, sent) == 1){ break; } for(i = 0;i < word_length;i++){ word[i] |= 0x60; } for(i = 0;i < sent_length;i++){ sent[i] |= 0x60; } if(word_length == sent_length){ count += serch_word(word, sent); } for(i = 0;i <= sent_length;i++){ sent[i] = 0; } } printf("%d\n", count); return 0; } /* 関数名：文字列入力 */ /* 概要：文字列を入力する。入力された文字列の長さを返す */ /* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */ /* 戻り値：入力された文字列の長さ */ unsigned short s_scan_word(unsigned char * str, unsigned short length_max) { unsigned short usW_C_count_text = COUNT_RESET; /* 文字列長カウンタ */ unsigned short usW_C_i; /* ループ変数 */ /* 文字列の入力 */ for(usW_C_i = LOOP_RESET;usW_C_i < length_max;usW_C_i++){ scanf("%c", str + usW_C_i); /* 入力終了の処理 */ if((*(str + usW_C_i) == ' ') || (*(str + usW_C_i) == '\n')){ break; } /* 文字数をカウント */ usW_C_count_text++; } /* 文字列長を返す */ return usW_C_count_text; } unsigned short serch_word(unsigned char * word, unsigned char * sent) { unsigned int frg = 0; unsigned int i = 0; while(1){ if(*(word + i) == '\n'){ frg =1; } if(*(word + i) != *(sent + i)){ break; } i++; } return frg; }
      |                   ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status