#need help figuring out the first c problem itself

32 messages · Page 1 of 1 (latest)

frozen wolf
#

well i am lost as i am a complete beginner and the way i know is
#include <stdio.h>
int main(){
printf("Hello, World!");
return 0;
}

mighty verge
#

Did you watch that video?

frozen wolf
#

i did

#

apparently i should not delete the given code and only make a single change

#

which i do not at all know

#

eh

#

so i just had to change bye to hello and mars to world

#

but now i have no idea how the function works

mighty verge
#

Which part of the function do you not understand?

#

If you copy/paste your code here, and spell out your confusion, someone may be able to explain things to you

frozen wolf
#

well the code in itself is something i don't get, in the end i did this:
#include "hello_world.h"
const char *hello(void)
{
return "Hello, World!";
}

#

as to the change a single string reference but how the code works is a different thing and the part i don't get

pseudo drumBOT
mighty verge
#

Do you understand any of the lines? Most of the lines? None of the lines?

#

@frozen wolf ?

frozen wolf
#
//why are we accessing that?
const char *hello(void) // const char cause we are returning a constant character? but no idea about the next part
return part makes sense```
pseudo drumBOT
#

👋🏼 Hello!
Exercism is designed for people who have some experience in programming. If you are new to coding, we recommend joining our Beginners Bootcamp, starting in January: https://bootcamp.exercism.org

There are many other great resources online, that can kickstart your journey in computer science.

  • Harvard's CS50x course is great for a wide understanding.
  • Code in Place is a great intro to coding course which will teach you Python using their browser-based environment.
  • For a focus on web development, try The Odin Projects. It is a long-term commitment that will guide you to through some projects and will leave you with a nice portfolio by the end.
  • For web development, The MDN web docs are a valuable resource.
mighty verge
#

const char * is a "string" in C. void means this function takes no arguments.

#

Did I miss any part?

frozen wolf
#

i get the void part so is hello the function name and since by default strings don't exist in c

#

we use the *

#

as a pointer to move to each character

mighty verge
#

* says we are dealing with a pointer to chars, which is how strings work in C, yes

frozen wolf
#

okay i see

#

what about when we include stdio.h is that sort of inbuilt header thats there

mighty verge
#

stdio is part of the ... standard library that does IO stuff. Most languages come with a library of helpful functions you might want to use.

frozen wolf
#

i see thank you so much

#

for your help and time

mighty verge
#

You're very welcome