Explain the concept of pointer to an array. Using this write an interactive program in "C" to find out the string length of a given string, as input ?
Answers
Answered by
1
#include<stdio.h>#include<conio.h> int string_ln(char*); void main() { char str[20]; int length; clrscr(); printf("\nEnter any string : "); gets(str); length = string_ln(str); printf("The length of the given string %s is : %d", str, length); getch();} int string_ln(char*p) /* p=&str[0] */{ int count = 0; while (*p != '\0') { count++; p++; } return count;}
Similar questions