C언어 배열 길이 구하기

1 개요[ | ]

C언어 배열 길이 구하기
#include<stdio.h>
void main() {
   int nums[5];
   printf("length = %d", sizeof(nums)/sizeof(nums[0]));
}
#include<stdio.h>
void main() {
   int nums[] = {1,2,3,4};
   printf("length = %d", sizeof(nums)/sizeof(nums[0]));
}
#include<stdio.h>
void main() {
   char *weekdays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
   printf("length = %d", sizeof(weekdays)/sizeof(weekdays[0]));
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}