IT
C언어 문자열 개수 카운트 예시
agnusdei1207
2023. 5. 3. 01:58
반응형
SMALL
#include <stdio.h>
// 글자 개수를 count 하는 예시
int main(void){
char input[1001]; // 길이만큼 채우지 않을 경우 나머지 공간은 자동으로 null 이 들어감
gets(input);
int count = 0;
while(input[count] != '\0'){ // '\0' : null 을 의미함
count++;
}
printf("count : %d", count);
printf("입력한 문자열 : %s", input); // %s : 문자열을 출력할 때 사용
}
반응형
LIST