Char pointer as the function parameter : Function Parameters « Function « C / ANSI-C






Char pointer as the function parameter

  

#include <stdio.h>

void f(char *p);

int main(void)
{
  f("this is a test");

  return 0;
}

void f(char *p)
{
  while(*p) { /* loop as long as p does not point to the
                 null which is the string terminator*/
    printf("%c", *p);
    p++;       /* go to next character */
  }
  printf("\n");
}


           
       








Related examples in the same category

1. Calculating an average using variable argument lists Calculating an average using variable argument lists
2.Computes the area of three triangles
3.Demonstrate the use of pointers and parameter passing
4.Pass value
5.Pass reference
6.A function to increase your salaryA function to increase your salary
7.Pass array with different dimension into function
8.Pass Array into a function
9.Use function with pointer parameters
10.Define int pointer parameter for a function
11.Pass reference of an int value into function
12.Pass char pointer into function
13.Passing the data type addess into the functionPassing the data type addess into the function
14.Length of the function parameters
15.Return value though parameterReturn value though parameter
16.Pass return value through function parameter
17.Pass array value into function: by array, by empty array and by pointer
18.Define constant function parameter
19.Passing parameter by pointer
20.Pass double value into functionPass double value into function