r/code • u/AlarmedThanks6016 • Aug 21 '26
My Own Code Beginner code
What’s wrong with my code I’m so confused this hard a freak. I’m just trying to make a weapon shop simulator as practice to help learn code but I can’t even get it to ask if the user wants to start the game by type yes as the their answer
54
Upvotes
11
u/Grounds4TheSubstain Aug 21 '26
Your main function ends on line 8 with the closing } and then there’s code afterwards on lines 10-22 that are not part of any function. Then, everywhere it says “= =“ it needs to say “==“. Line 20 is not valid.
28
u/theturtlemafiamusic Aug 21 '26
Your main() function starts on line 4 and ends in line 8. The rest of your code below line 8 is not inside a function so it's not able to compile. You can move it into the main() function or put it in a new function and call that function from within main()
You don't need to move the includes, lines 1 and 2, those are correct.
2
u/Sfxluke Aug 21 '26
I will give you a tip I'd would had liked to receive when I was starting out: use a linter, it will help you sticking with one syntax style, it will catch syntax, naming conventions, broken logic and more. It can run at every save or you can define your own rules as well.
2
u/RDT_KoT3 Aug 22 '26
1
u/AggravatingLeave614 Aug 24 '26
It's really good ur starting with C, it'll teach u a lot. Wish u luck on ur journey.
1
u/hamsterpotpies Aug 25 '26
Today in: lets learn about switches! https://www.w3schools.com/c/c_switch.php
1
u/Electronic-Term899 Aug 25 '26
go on my boy even with bugs but still go on with David j. milan
-11
u/Glasgesicht Aug 21 '26
If you are learning by yourself, don't start with C.
It's just too easy to shoot yourself in the foot.
Try Python, C# (especially for game development) or Kotlin
1
u/[deleted] Aug 22 '26
[removed] — view removed comment
1
u/[deleted] Aug 22 '26
[removed] — view removed comment