Creation of two character arrays-one initialized and the other not. - C Array

C examples for Array:Array Value

Description

Creation of two character arrays-one initialized and the other not.

Demo Code

#include <stdio.h> 
int main() /* w  w w. ja  v  a 2  s .  c  om*/
{ 
   int x; 
   char cArray[5]; 
   char cName[] = "this is a test"; 
   printf("\nCharacter array not initialized:\n"); 
   
   for ( x = 0; x < 5; x++ ) 
      printf("Element %d's contents are %d\n", x, cArray[x]); 
   
   printf("\nInitialized character array:\n"); 
   
   for ( x = 0; x < 6; x++ ) 
      printf("%c", cName[x]); 
}

Result


Related Tutorials