##疑問
おなじみのsizeof(str)/sizeof(str[0])でその配列の要素数が求められるはずですが、
自作関数に渡して計算すると違う値が出てきます。
その過程で何が起こっているのかどうか教えてください。
##コード
#include <stdio.h> #include<time.h> int noname(int*); int main() { char str[]="ABCDE"; int suuti= sizeof(str)/ sizeof(str[0]); printf("%s\n%d\n\n",str,suuti); noname(str); return 0; } int noname(int *str) { int suuti= sizeof(str)/ sizeof(str[0]); printf("%s\n%d",str,suuti); }
#結果
ABCDE
6
ABCDE
2
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/03/15 15:48