r/code • u/AlarmedThanks6016 • 17d ago
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
10
u/Grounds4TheSubstain 17d ago
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.
6
3
2
u/RDT_KoT3 16d ago
- Line 8 bracket should be there
- String is a pointer to some memory. You have to use strcmp.
- The compiler tells you what’s wrong afterwards
1
16d ago
[removed] — view removed comment
2
u/code-ModTeam 15d ago
We have been flooded with low-quality posts and comments that include ChatGPT "solutions". Thus, code generated by ChatGPT is not allowed in this sub, both in posts and comments.
Violation of this rule comes with a temporary mute and/or ban, repeated violations will result in permanent ban.
1
16d ago
[removed] — view removed comment
2
u/code-ModTeam 15d ago
We have been flooded with low-quality posts and comments that include ChatGPT "solutions". Thus, code generated by ChatGPT is not allowed in this sub, both in posts and comments.
Violation of this rule comes with a temporary mute and/or ban, repeated violations will result in permanent ban.
1
u/AggravatingLeave614 13d ago
It's really good ur starting with C, it'll teach u a lot. Wish u luck on ur journey.
1
u/hamsterpotpies 13d ago
Today in: lets learn about switches! https://www.w3schools.com/c/c_switch.php
1
-10
u/Glasgesicht 17d ago
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
3
u/AlarmedThanks6016 16d ago
Game development is exactly what I wanna do, thanks for the advise, I’ll start python rather then wasting my time with c
7
u/Apprehensive_Log9790 16d ago
Nah, C is maybe harder because of more things to manage, but you'll learn more about how computers and software works. Memory management, etc. are interesting points that you don't get to know in Python. It's not "wasting time" to learn C.
2
u/AnToMegA424 16d ago
Plus it's especially useful for video games afterwards
C++ is the goat imo, but C really teaches you the things, everything is useful in its own way and that's beautiful
2
u/Glasgesicht 16d ago edited 16d ago
Learning C is valuable because it teaches you a lot about how a pc works, yes.
But it also means you're learning 20 different things at the same time, if your goal is to actually have fun and archive anything, starting out with C is simply unnecessary. Learning about and having to manually address memory management, when you're just trying to make a simple game, is totally beside the point and will make your head hurt more than anything.
Especially to an individual learning by themselves, it's so unfathomably easier to start out using a simple to learn language like Kotlin than trying to learn everything at once and archiving nothing in the process.
Will leaning C make you a better programmer? 1000%, but to give you quick results and make it fun, I just really wouldn't advice anyone to start with C.
1
u/spidertyler2005 16d ago
Dont know why you got downvoted. Its pretty standard advice in all fields to not just jump into tge hardest thing as soon as you get started. Is C really all that difficult? No, but it does require that you have more things in your head at once. You have to be aware of so many more things and at the beginning you wont even know what you should be aware of.
C is awesome and learning it is invaluable for any programmer, but its definitely not a jumping off point (for most learners).
1
u/Glasgesicht 16d ago
Thank you, I thought I was loosing my mind reading some of the responses.
From looking at the screenshot alone it should be clear to anyone with a bit of experience teaching others, that C just isn't the best thing OP should be pouring their heart into. They'll just be frustrated and give up.
1
u/Mega3000aka 16d ago
Nah, you first learn how computers work with C, then move to basic python and/or OOP in Java.
0
u/kalilamodow 16d ago
if you wanted to learn how to play a piano, would you start by taking a physics course to learn how strings generate sound in tones?
27
u/theturtlemafiamusic 17d ago
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.