c
1#include <stdio.h> 2 3int main(void) 4{ int i ; 5 char tume[5] = {0}; 6 7 printf("tume[5]に任意の文字列を入力して。\n"); //tumeの内容 8 scanf("%s",tume); 9 10 putchar('\n'); 11 12 //tumeを表示 13 printf("tume[5]:"); 14 for(i=0;tume[i] != '\n' ; ++i) 15 printf("%c",tume[i]); 16 putchar('\n'); 17 18 return 0; 19} 20/*tume[5]に任意の文字列を入力して 21kubomi 22 23tume[5]:kubota 24*/ 25
このような結果になったのですが、
配列tume[5]には
4文字分+ヌル文字のみ
が格納されていると考えられます。
それならばなぜ4文字以上表記できるのでしょうか?
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。