Mega Code Archive

 
Categories / C / Function
 

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"); }