🔴 Class 69 : Program to calculate length of string with help of function and pointer

Опубликовано: 28 Октябрь 2024
на канале: Eagles Tech
215
9

#include stdio.h
int calculateLength(char*);
int main()
{
char str1[25];
int l;
printf("\nCalculate the length of the string :\n");
printf(" Input a string : ");
gets(str1);
l = calculateLength(str1);
printf("string length %s is : %d ", str1, l); // Display the length of the string
printf("\n\n");
}
int calculateLength(char* ch)
{
int ctr = 0;
while (*ch != '\0')
{
ctr++;
ch++;
}
return ctr;
}

🔴 Class 69 : Program to calculate length of string with help of function and pointer #viralvideo


#clanguage #clanguageprogramming #cprogramming