Posted on Leave a comment

‘C’ using structures in C programming

‘C’ using structures in C programming

  1. #include <stdio.h>
  2. #include <string.h>
  3. struct game
  4. {
  5.   char game_name[50];
  6.   int number_of_players;
  7. };  // Note the semicolon
  8. int main()
  9. {
  10.   struct game g;
  11.   strcpy(g.game_name, “Cricket”);
  12.   g.number_of_players = 11;
  13.   printf(“Name of game: %s\n”, g.game_name);
  14.   printf(“Number of players: %d\n”, g.number_of_players);
  15.   return 0;
  16. }
Leave a Reply

Your email address will not be published. Required fields are marked *