What does the following program print? string operation - C String

C examples for String:char array

Description

What does the following program print? string operation

Demo Code


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

#define M1   "this is a test? " 
char M2[40] = "test test test."; 
char * M3  = "chat"; 

int main(void) { 
     char words[80]; 
     printf(M1); //w  w  w  .  j a v  a2  s.  c om
     puts(M1); 
     puts(M2); 
     puts(M2 + 1); 
     strcpy(words,M2); 
     strcat(words, " Win a toy."); 
     puts(words); 
     words[4] = '\0'; 
     puts(words); 
     while (*M3) 
        puts(M3++); 
     puts(--M3); 
     puts(--M3); 
     M3 = M1; 
     puts(M3); 
     return 0; 
}

Result


Related Tutorials