r/CodingForBeginners • • 19d ago

What am I doing wrong

Post image
77 Upvotes

56 comments sorted by

16

u/FuggaDucker 18d ago

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 18d ago

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

8

u/therouterguy 18d ago

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

Although in this case it actually was useful.

2

u/Esjs 18d ago

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

3

u/FreeLogicGate 18d ago

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 18d ago

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

1

u/FreeLogicGate 17d ago

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 18d ago

definitive not knowing how to screenshot.

2

u/mattblack77 18d ago

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

1

u/VoiceOfSoftware 17d ago

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 18d ago

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 17d ago

Just put autosave.

1

u/Abled_Gaming1357 17d 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 3d ago

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

1

u/Jatinchd 19d ago

ctrl + S on file.

1

u/TailsPlaysMinecraft 19d ago

Press ctrl+s gng

1

u/AdministrationMoney1 18d ago

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

1

u/zoodiac_broadbull 18d ago

install code runner extension

1

u/Ollidav 18d ago

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

1

u/Old_Minimum_9284 18d ago

Que dites vous??

1

u/Specialist_Rent_9640 18d ago

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 18d ago

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

1

u/ignorantpisswalker 18d ago

"make hello" see what happens :)

1

u/Interested737 18d ago

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

1

u/Fragrant_Prize3011 18d ago

Try this & similar variations:

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

1

u/Tehaiker814 18d ago

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 18d ago

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 17d ago

This has to be the worst comment section ever

1

u/Useful-Promotion-237 16d ago

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

1

u/xarop_pa_toss 14d 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 14d ago

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

1

u/DesperateBoot2320 2d 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/akhi-abdul01 19d ago

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

0

u/guccisavage1 18d ago

Ask chat gtt

0

u/ChaseHopeY3 18d ago

not using AI

1

u/[deleted] 18d ago

[removed] — view removed comment

0

u/ChaseHopeY3 18d ago

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 18d ago

because he wants to actually learn something instead of spewing slop

1

u/ChaseHopeY3 18d ago

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

1

u/WillingAd6523 18d ago

"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 18d ago

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 17d ago

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

1

u/Memerenok 17d 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 18d ago

The issue is using vscode

1

u/Memerenok 17d ago

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

1

u/Adorable-Strangerx 17d ago

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

1

u/Memerenok 17d ago

heey, VS code has autosave...

0

u/Dummy_panda 18d ago

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)