Uses pointer to print the ASCII values associated with the characters contained in a string. - C String

C examples for String:char array

Description

Uses pointer to print the ASCII values associated with the characters contained in a string.

Demo Code

#include <string.h>

#include <stdio.h>

int main(void)
{
   char *p1;//from   w w w.j a v a 2s  .c om

   char s[80];

   do {
      p1 = s; /* reset p1 to beginning of s */
      gets_s(s); /* read a string */

               /* print the decimal equivalent of each
               character */
      while (*p1) printf(" %d", *p1++);

   } while (strcmp(s, "done"));


   return 0;
}

Result


Related Tutorials