-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathStringLength.c
31 lines (30 loc) · 1 KB
/
StringLength.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/******************************************************
* File : StringLength.c
* Description : C Program to find the length of the given string
* with and without using built-in functions
* Author : Sarju S
* Version : 1.0
* Date : 31/08/2021
* ***************************************************/
#include<stdio.h>
#include<string.h>
int main(){
char inputString[20];
int charCount=0,i=0;
printf("Enter the string:");
gets(inputString);
//without using built-in function
/*while(inputString[i]!='\0'){
charCount++;
i++;
}
printf("\nThe Number Characters in the given String:%d",charCount);
*/
//without using built-in function
for(i=0;inputString[i]!='\0';i++);
printf("\nThe Number Characters in the given String:%d",i);
//with using built-in function
charCount = strlen(inputString);
printf("\nThe Number Characters in the given String using strlen():%d",charCount);
return 0;
}