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 246 views
1 answer 328 views
1 answer 147 views
1 answer 145 views
1 answer 121 views
121 views asked Aug 23, 2017 by avibootz
2 answers 182 views
...