C examples for Function:Function Parameter
The following program passes a character array to a function that calculates the length of the incoming string.
#include <stdio.h> int nameLength(char []); int main() { /*from www . ja va2 s.c o m*/ char aName[20] = {'\0'}; printf("\nEnter your first name: "); scanf("%s", aName); printf("\nYour first name contains "); printf("%d characters\n", nameLength(aName)); } int nameLength(char name[]) { int x = 0; while ( name[x] != '\0' ) x++; return x; }