-
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
f84e401
commit 7d67f38
Showing
1 changed file
with
9 additions
and
12 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,23 @@ | ||
#include <stdio.h> | ||
|
||
//Created a function to calculate length of string. | ||
int LengthOfString(char string[50]) | ||
{ | ||
int LengthOfString(char StringInput[50]){ | ||
int length = 0, i; | ||
scanf("%[^\n]" , string); //Input of the string | ||
scanf("%[^\n]", StringInput); //Input of the string | ||
|
||
for(i=0; string[i]!='\0'; i++) | ||
{ | ||
length++; | ||
} | ||
for(i = 0; StringInput[i] != '\0'; i++) | ||
|
||
length++; | ||
|
||
return length; | ||
} | ||
|
||
int main(void) | ||
{ | ||
char string [50]; | ||
int main(void){ | ||
char sentence [50]; | ||
int length; | ||
|
||
length = LengthOfString(string); // Using the function | ||
printf("%d \n" , length); // Printing the length | ||
length = LengthOfString(sentence); // Using the function | ||
printf("%d \n", length); // Printing the length | ||
|
||
return 0; | ||
} |