To write your own game from scratch, use this:
int main(void) { return 0; }
Now you will have to add your own code to it, and turn it into a game.
I'm Sorry but this comment made me grin from Ear to Ear lol! As all the others said it's best to start small and move forward. my very first game was a text based CYOA ( Choose Your Own Adventure) , which eventually gave way to a text based RPG, which eventually gave way to a basic platformer, and etc. etc. and I definitely think looking at someone else's code and dissecting it can help but there are some principles you won't understand until you play with them yourself like the game loop . and how to best set up a basic game progress. any how goodluck!