Advertisement
RicardasSim

typedef char name[x]

Dec 29th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define MAX_MESSAGE_LENGHT 64
  6.    
  7. typedef char Message[MAX_MESSAGE_LENGHT];
  8.  
  9. int main (int argc, char **argv){
  10.    
  11.     Message messages[3];
  12.    
  13.     strcpy( messages[0], "first\n" );
  14.     strcpy( messages[1], "second\n" );
  15.     strcpy( messages[2], "third\n" );
  16.    
  17.     for(unsigned int i = 0; i < sizeof(messages)/sizeof(messages[0]); i++)
  18.     {
  19.         printf( "%s",messages[i] );
  20.     }
  21.  
  22.     return 0;
  23.    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement