-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7690164
commit 3a68ac2
Showing
1 changed file
with
8 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
//Created a function to calculate length of string. | ||
int LengthOfString(char string[50]) | ||
{ | ||
int length = 0, i; | ||
scanf("%[^\n]" , string); //Input of the string | ||
|
||
scanf("%[^\n]" , string); //Input of string with blank spaces | ||
int length = strlen(string); | ||
for(i=0; string[i]!='\0'; i++) | ||
{ | ||
length++; | ||
} | ||
|
||
return length; | ||
} | ||
|
||
|
||
int main(void) | ||
|
||
{ | ||
char string [50]; | ||
int length; | ||
|
||
length = LengthOfString(string); // Using the function | ||
|
||
printf("Length %d \n" , length); // Printing the length | ||
printf("%d \n" , length); // Printing the length | ||
|
||
return 0; | ||
} | ||
} |