How to find the length of a string without using the Built-in function in C

2 Answers

0 votes
#include <stdio.h> 

int main(void)
{   
    char s[30] = "c c++ c# java";
    int i = 0;
    
    for (i = 0; s[i] != '\0'; i++);

    printf("%d", i);
     
    return 0;
}
  
        
/*
run:
     
13

*/

 



answered Mar 31, 2017 by avibootz
0 votes
#include <stdio.h> 

int main(void)
{   
    char s[30] = "c c++ c# java";
    int i = 0;
    
    while (s[i]) i++;

    printf("%d", i);
     
    return 0;
}
  
        
/*
run:
     
13

*/

 



answered Mar 31, 2017 by avibootz

Related questions

1 answer 346 views
1 answer 429 views
2 answers 295 views
1 answer 206 views
206 views asked Aug 23, 2017 by avibootz
1 answer 191 views
1 answer 286 views
1 answer 407 views
...