정의
strlen - calculate the length of a string. string 의 길이를 계산한다.
시놉시스
#include <cs50.h>
#include <string.h>
int strlen(string s)
리턴 value
this function returns the number of characters in s, excluding the terminating NUL byte (i.e., '\0').
예시
#include <cs50.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
string s = get_string("Input: ");
printf("Output: ");
for (int i = 0, n = strlen(s); i < n; i++)
{
printf("%c", s[i]);
}
printf("\n");
}
'<프로그래밍 언어> > [C 언어]' 카테고리의 다른 글
[C 언어] Syntactic Sugar 문법적 설탕 (0) | 2022.02.28 |
---|---|
[C 언어] 탐욕 알고리즘 (Greedy algorithm) (0) | 2022.02.27 |
[C 언어] Datatype in C: int float double char bool long string (0) | 2022.02.27 |
[C 언어] \n, escape sequence (0) | 2022.02.26 |
댓글