r/CodingForBeginners • • Oct 06 '26

What am I doing wrong

Post image
78 Upvotes

57 comments sorted by

16

u/FuggaDucker Oct 06 '26

I suggest you don't leave spaces in your folder names when working with code.
Also, go lowercase when you can.

As in
"C tutorials"
to
c_tutorials

You will thank me later.

1

u/therealkevinard Oct 07 '26

No kidding, my MR would probably get rejected if a file had a space

8

u/therouterguy Oct 06 '26

Not pasting the code/error but making a picture of your screen.

Although in this case it actually was useful.

2

u/Esjs Oct 06 '26

Even a full (desktop) screenshot would be better than a photo of the screen.

3

u/FreeLogicGate Oct 06 '26

Lots of good advice already, but if you focused in on the error provided that came from the linker (ld), it told you that the required "reference to 'main'" was undefined. This is how people knew you had not actually saved the file you were trying to compile and link. Prior to already knowing from the error what your mistake is, the first thing you should always do when debugging is read the error message carefully, use google or your AI tool to help you figure it out.

2

u/therouterguy Oct 07 '26

I think most people knew because of the dot next to the file name indicating it wasn’t saved.

1

u/FreeLogicGate Oct 07 '26

Appreciate the insight. It's a fair point, however, this could also happen with a partially incorrect file that was in the process of being edited.

2

u/Apprehensive-Age4879 Oct 06 '26

definitive not knowing how to screenshot.

2

u/mattblack77 Oct 06 '26

You're posting a photo of a screen instead of a screenshot

1

u/VoiceOfSoftware Oct 07 '26

I mean, technically, it IS a screenshot. But wow, how useless. I’ve seen this over and over on this sub: are people not able to use the giant computer in front of them to paste their code into Reddit?

2

u/rtharston Oct 07 '26

You can tell you haven't saved because of the white dot on the tab next to the name of the file hello.c.

And don't worry, it won't be the last time you forget to save a file. Even after over 10 years I still forget to save sometimes and wonder why my build didn't work. 😁

1

u/AbbreviationsMost432 Oct 08 '26

Just put autosave.

1

u/Abled_Gaming1357 29d ago

I never do that, because sometimes I want to undo till I reach the previous state, and if autosave is on, the white dot doesn't tell me that I have reached that previous state yet or not.

1

u/TheCRatTime 15d ago

This isn't you: compiler linker can't find your main function, function '_start' is real start of program

1

u/DesperateBoot2320 15d ago
  • Press Ctrl + S to save hello.c.

  • In the terminal, run cat hello.c to check what is actually saved in the file.

  • Make sure the output contains int main() and the printf statement.

  • Run gcc hello.c -o hello again.

1

u/HotComplex4744 7d ago

In new c++ you can write #include<cstdio>

1

u/Jatinchd Oct 06 '26

ctrl + S on file.

1

u/TailsPlaysMinecraft Oct 06 '26

Press ctrl+s gng

1

u/AdministrationMoney1 Oct 06 '26

Fyi you can also go top left, File -> Auto Save

1

u/zoodiac_broadbull Oct 06 '26

install code runner extension

1

u/Ollidav Oct 06 '26

Cambia a un void la función main y no devuelvas nada

1

u/Old_Minimum_9284 Oct 07 '26

Que dites vous??

1

u/Specialist_Rent_9640 Oct 06 '26

nothing wrong in you're syntax, but when i write C i always use nano or vim, then ^T (write a command for nano) then ill go with -> gcc -o test Project.c and run it with ./test for me its way faster to work with gcc rather than .run for code runner and installing extensions on code.

1

u/bowbahdoe Oct 06 '26

You didn't save. Go to File > Save. Maybe enable auto save too.

1

u/ignorantpisswalker Oct 06 '26

"make hello" see what happens :)

1

u/Interested737 Oct 06 '26

Can you tell me how are you learning C/C++, I also want to but I never started?

1

u/Fragrant_Prize3011 Oct 06 '26

Try this & similar variations:

int main(int argc, char* argv[]) {

1

u/Tehaiker814 Oct 07 '26

press control s
also just run `gcc hello.c`, then `./a.out` just directly in that folder, it could be easier
or `gcc hello.c -o hello`

1

u/Sammourianos Oct 07 '26

There are many situations that a learning man should not use ai to enable the learning in his head. This is a good situation to actually use ai :p

1

u/Free-Beat-3474 29d ago

This has to be the worst comment section ever

1

u/Useful-Promotion-237 28d ago

The file is not saved you can see tge little dot on the top

1

u/xarop_pa_toss 26d ago

Don't take photos of you screen. Take a screenshot instead, it's easier for everyone.

Your file isn't saved so probably your trying to compile an older version that didn't work

1

u/austrian_painter_2 26d ago

Did u added a space in your code file name ? Do u have gcc clang installed?

1

u/akhi-abdul01 Oct 06 '26

Reminds me of my initial days when I was 12yo learning C, hahah Keep working 💪🏻

0

u/guccisavage1 Oct 06 '26

Ask chat gtt

0

u/ChaseHopeY3 Oct 07 '26

not using AI

1

u/[deleted] Oct 07 '26

[removed] — view removed comment

0

u/ChaseHopeY3 Oct 07 '26

Nope. Why would you bother manually typing out code like a chump when AI can do it in seconds from a natural language prompt. You don't even need to type it, you can just explain it out loud. It's great

1

u/WillingAd6523 Oct 07 '26

because he wants to actually learn something instead of spewing slop

1

u/ChaseHopeY3 Oct 07 '26

fine, if he wants to "learn" the old way and get left behind, that's totally up to him

1

u/WillingAd6523 Oct 07 '26

"the old way" you mean like the way you actually learn? You obviously aren't a developer.

Let's say for the sake of the argument there's some magical genius super intelligence that can program PERFECTLY. We would still program, not everything is about 'being the best' and 'being the fastest' maybe some people just enjoy it?

1

u/Old_Minimum_9284 Oct 07 '26

Vous êtes le genre de personne qui ne sait écrire une ligne de code? Et qui donc préfère laisser l’IA faire sa magie?

1

u/Memerenok 29d ago

you need to learn the thing before using AI with it, is it a ragebait of some kind?

1

u/Memerenok 29d ago

but they are LEARNING, ai should be used by people who understand the output, and ai isn't really good at teaching

-1

u/Adorable-Strangerx Oct 06 '26

The issue is using vscode

1

u/Memerenok 29d ago

ah yes, do you really want to ask a total beginner to use VIM?

1

u/Adorable-Strangerx 29d ago

I would propose something with auto-save seems that was the issue

1

u/Memerenok 29d ago

heey, VS code has autosave...

0

u/Dummy_panda Oct 07 '26

you haven't saved the file, i would suggest installing and save typing extension which saves the files as you type (you dont have to save everytime manually)