Use char pointer to access string constants - C String

C examples for String:char array

Description

Use char pointer to access string constants

Demo Code

#include <stdio.h>
#include <string.h>

char *p = "hello world";

int main(void)
{
   register int t;

   /* print the string forward and backwards */
   printf(p);/*  w  w w. j  a v  a2  s  .  co m*/
   for (t = strlen(p) - 1; t>-1; t--) printf("%c", p[t]);

   return 0;
}

Result


Related Tutorials