Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
static char* theFruit[] = { "lemon", "orange", "apple", "banana" };
この配列を見ると、サイズが 4 であることがわかります。Cでこの配列のサイズをプログラムで見つけるにはどうすればよいですか? サイズをバイト単位で指定したくありません。
sizeof(theFruit) / sizeof(theFruit[0])
sizeof(theFruit[0]) == sizeof(char *)、定数であることに注意してください。
sizeof(theFruit[0]) == sizeof(char *)