Menu

[Solved]Need Code Written C Given Code Structh Pragma Include Include Include Include Typedef Stru Q37081835

Need this Code written in C

Given Code for struct_h

——

#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

typedef struct
{
char *name;
char *publisher;
int publish_year;
} Game;

Game *createGame (char *name, char *publisher,
       int publish_year);
void printGame (Game * game);
void destroyGame(Game** game);
void changePublishYear(Game* game, int new_year);
void changePublisher(Game* game, char* new_publisher);
void lowercaseName(Game* game);
Game* getEarliestYear(Game** games, int size);
Game* getLastGameName(Game** games, int size);

Given Code for stretch_c

—–

#include “struct_utils.h”

Game *createGame(char *name, char *publisher, intpublish_year)
{
//A hint for how to approach this
Game *new_game = (Game *)malloc(sizeof(Game *) * 1);
new_game->name = (char *)malloc(sizeof(char) * (strlen(name) +1)); //Allocate enough memory to copy the name (plus 1 for thenull-termination character)!
strcpy(new_game->name, name); //Copy the name into the Gamestruct. This is done instead of new_game.name = name because itwill become read-only otherwise.

return new_game;
}

void changePublishYear(Game *game, int new_count){}
void changePublisher(Game *game, char *new_publisher){}
void lowercaseName(Game *game){}
void printGame(Game *Game){}
void destroyGame(Game **Game)
{
free((*Game)->name);//A hint for how to approach this
}
Game *getEarliestYear(Game **games, int size){}
Game* getLastGameName(Game** games, int size){}
int main()
{
//Feel free to use this as your testbed.
return 0;
}

Expert Answer


Answer to Need this Code written in C Given Code for struct_h —— #pragma once #include #include #include #include typedef stru… . . .

OR


Leave a Reply

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