This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
0
Is this a bad way to initialise a struct in C?
Post Flair (click to view more posts with a particular flair)
Post Body
In my C program, I have a function that looks like this:
GameState cc_newGame(void) {
// Create a new game state
GameState* game = (GameState*)NULL;
// Set the fields to their default values
game->tick = 0;
return *game;
}
Will creating a struct this way cause issues in my program?
EDIT: Thanks to a comment by u/whyeventrymore, I was able to figure out how to do this using malloc
.
Author
Account Strength
60%
Account Age
6 months
Verified Email
Yes
Verified Flair
No
Total Karma
664
Link Karma
200
Comment Karma
464
Profile updated: 22 hours ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 4 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/AskProgramm...