From 5430e1fdd57777e565234df6ea90710b156a88da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B3=D0=BE=D1=80=20=D0=97=D0=B8=D0=BC=D0=BA=D0=B8?= =?UTF-8?q?=D0=BD?= Date: Tue, 26 Nov 2024 19:55:37 +0400 Subject: [PATCH] commit 3 --- main/main.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/main/main.cpp b/main/main.cpp index 5f28270..3ac1d90 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1 +1,23 @@ - \ No newline at end of file +#include + +int strlen(char s[]) { + int len = 0; // счетчик + + // Перебираем символы строки + while (s[len] != '\0') { + len++; + } + + return len; // Возвращаем длину +} + +int main() { + char str1[] = "Hello, world!"; + char str2[] = "C programming"; + + printf("Длина строки \"%s\" = %d\n", str1, strlen(str1)); + printf("Длина строки \"%s\" = %d\n", str2, strlen(str2)); + + return 0; +} +