How do you find the length of a string without using strlen?

How do you find the length of a string without using strlen?
Answer
String length in C without strlen
  1. int main() { char s[1000]; int c = 0;
  2. printf(“Input a stringn”); gets(s);
  3. while (s[c] != ‘’) c++;
  4. printf(“Length of the string: %dn”, c);
  5. return 0; }
 

Tìm kiếm

Back
Top