#include <stdio.h> #include <string.h> int custom_strlen(const char *str) { // Your logic here int len = 0; for(int i=0; i<100; i++) { if(str[i] == '\0') { return len; } len++; } } int main() { char str[101]; fgets(str, sizeof(str), stdin); // Remove newline if present int i = 0; while (str[i] != '\0') { if (str[i] == '\n') { str[i] = '\0'; break; } i++; } printf("%d", custom_strlen(str)); return 0; }
Test Cases
Test Results
Input
Embedded
Expected Output
8