Skip to content

Commit 7d67f38

Browse files
authored
Update length_string.c
1 parent f84e401 commit 7d67f38

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

programs/C/length_string.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
#include <stdio.h>
22

33
//Created a function to calculate length of string.
4-
int LengthOfString(char string[50])
5-
{
4+
int LengthOfString(char StringInput[50]){
65
int length = 0, i;
7-
scanf("%[^\n]" , string); //Input of the string
6+
scanf("%[^\n]", StringInput); //Input of the string
87

9-
for(i=0; string[i]!='\0'; i++)
10-
{
11-
length++;
12-
}
8+
for(i = 0; StringInput[i] != '\0'; i++)
9+
10+
length++;
1311

1412
return length;
1513
}
1614

17-
int main(void)
18-
{
19-
char string [50];
15+
int main(void){
16+
char sentence [50];
2017
int length;
2118

22-
length = LengthOfString(string); // Using the function
23-
printf("%d \n" , length); // Printing the length
19+
length = LengthOfString(sentence); // Using the function
20+
printf("%d \n", length); // Printing the length
2421

2522
return 0;
2623
}

0 commit comments

Comments
 (0)