NO

Author Topic: absolute beginners question  (Read 4514 times)

Offline kaffepause

  • Member
  • *
  • Posts: 4
absolute beginners question
« on: December 27, 2020, 09:54:58 PM »
Hey! I've decided to get into programming, and i'm using a book called "C Programming - absolute beginners guide" to walk me through it, but my knowledge of programming is currently below the very basics. what i currently know is that i use an IDE to write source code, and use a compiler to run the code as a program and that's basically it, and that's why i found Pelles, because it says it is both an IDE and a compiler? I also have the latest Codeblocks installed because i figured i'd run everything i do twice to help hammering everything in, and not being dependant on one system.

However, i've just written my very first piece of code, but i've already run into a technical problem; i can't seem to figure out how to compile it in neither Pelles or in codeblocks as i don't understand how exactly i compile the script.

what i've written until now is this:

/* prints a message on the sceen*/
#include <stdio.h>
main ()
{
    printf ("this is my first")
    printf ("program! \n")
    return 0;

}

I don't know if this is correct, but from my limited understanding it seems to be correct, so my question is as follows: how exactly do i compile this in Pelles compiler? everything under the "project" button is just greyed out so i'm assuming i'm missing some basic info about how all of this works.
In Codeblocks there is a "debugging" button and a "run" button, but nothing happens when i click them

I know it might be a stretch asking about a different ide\compiler here, so please disregard codeblocks if necessary, i'll find out about that another place.

thanks a lot!
« Last Edit: December 27, 2020, 09:56:29 PM by kaffepause »

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 189
    • Bcx Basic to C/C++ Translator
Re: absolute beginners question
« Reply #1 on: December 28, 2020, 12:22:48 AM »
Here is my advice.

1) Open Pelles IDE ( Integrated Development Environment )

2) On the Main Menu, Click HELP

3) Click CONTENTS

4) Click the SEARCH tab

5) in the ... Type in the keyword box, type HELLO then press ENTER

6) Click IDE: Your first project

7) Work through the illustrated "Your first project: Hello, World"


Extra Credit:

Forget about using Code Blocks until you have 6 months of successful experience using Pelles C.
At the end of 6 months, ask yourself, "Why do I want/need to use Code Blocks?"
« Last Edit: December 28, 2020, 12:47:56 AM by MrBcx »
Bcx Basic to C/C++ Translator
https://www.BcxBasicCoders.com

Offline John Z

  • Member
  • *
  • Posts: 860
Re: absolute beginners question
« Reply #2 on: December 28, 2020, 11:16:44 AM »
Hi Kaffepause,

MrBcx is giving you good advice - follow the example in the help file, step by step to getting something going.
Once you have that working make small changes and test the results after each change to see the effects.

Another good resource for sample programs that are PellesC ready is at
http://smorgasbordet.com/pellesc/sourcecode.htm

In your example (partial) screen shot you added a new source file put some code in it but it looks like you never saved the source file. Looks like you are running two instances of PellesC as well.

If you don't save the source file when created the for the first time it is not added to the project, when saving you will be asked if the file should be added, answer yes of course.  Once added it will show in the righthand source files (not shown in your screen shot).

If you are not using a project wizard you will need to go to 'project options' to tell the IDE how to process your code.
Using project wizards is the best way to get started, they will establish the initial settings for you.
 
The first step in for any program determine what environment it will run in windows or a console.  If you run a console program, which it appears the sample is in the screen shot you should execute the program from inside an open command window otherwise you likely will not see the results as the console may close when the program completes. After you get a working skeleton you can enter code from the book to learn.  Be sure your skeleton code is the right environment for the examples.

Be persistent if you really want to learn.  Every mistake adds to your knowledge.  If starting  with C is too big of a hurdle try starting with Basic, there are many free versions out there, then move up to C.

Don't give up

John Z

P.S. Don't call a C program a 'script'  :)

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 189
    • Bcx Basic to C/C++ Translator
Re: absolute beginners question
« Reply #3 on: December 28, 2020, 04:03:29 PM »
Quote

Posted by: kaffepause
« on: Yesterday at 09:54:58 pm »
what i currently know is that i use an IDE to write source code, and use
a compiler to run the code as a program and that's basically it,


Kaffepause,

Telling a computer what to do requires accurate and precise communication. 

Let's start with these corrections:

We use an EDITOR to write source code.  All IDE's contain an editor, along with other tools.

We use a COMPILER and a LINKER to convert our source code into an EXECUTABLE file.

We use an OPERATING SYSTEM, like Windows 10, to RUN the executable file.

Bcx Basic to C/C++ Translator
https://www.BcxBasicCoders.com

Offline kaffepause

  • Member
  • *
  • Posts: 4
Re: absolute beginners question
« Reply #4 on: December 28, 2020, 04:59:51 PM »
Hey guys, thanks a lot for getting back to me.
It appears that i downloaded only the editor the first time around, and when i figured that out and got the IDE + compiler\linker, it turned out i had to select a template (the win64 exe) from the wizard, as what i was doing at first was just hitting ctrl+n and writing in that source code thing there.

Thanks a lot for helping me understand the terminology. It's a lot to wrap ones head around.

I'm using both Codeblocks because the guide book i have uses that, and Pelles C, with the aim of doing everything twice as i go about it to speed up the learning process a bit. I'm a musician and we have this saying that talent is 1% and practice is 99% of skill, and that you have to do something 10.000 times before you know it, so i'm just wading into this with that mindset i guess.

also i think C is pretty straight forward, i just wrote a very simple cost calculation exe that accepted my input which was thrilling!
But, i'm doing this because i want to get into infosec and pen testing, and i just figured that C was the most fundamental to learn how computers work, and it'd be a good springboard for getting into SQL and Python down the line, which is what my noob research came up with as the "best" languages to learn as a beginner.
But i'm literally just stumbling around in the dark at the moment, so any advice and input is greatly appreciated!



ps: i'm not running two instances of the editor, i just made a screenshot, but it didn't include something so i did a new one with the old one still open in the photo editor in the back;)

Offline kaffepause

  • Member
  • *
  • Posts: 4
Re: absolute beginners question
« Reply #5 on: December 28, 2020, 06:12:16 PM »
Here is my advice.

1) Open Pelles IDE ( Integrated Development Environment )

2) On the Main Menu, Click HELP

3) Click CONTENTS

4) Click the SEARCH tab

+ Attachments and other options
shortcuts: hit alt+s to submit/post or alt+p to preview

 


Topic Summary

5) in the ... Type in the keyword box, type HELLO then press ENTER

6) Click IDE: Your first project

7) Work through the illustrated "Your first project: Hello, World"


Extra Credit:

Forget about using Code Blocks until you have 6 months of successful experience using Pelles C.
At the end of 6 months, ask yourself, "Why do I want/need to use Code Blocks?"

Ok i have some questions around this, if you don't mind?

1) that help thing just had me click a few buttons to execute an already written program - what is the purpose of that in regards to learning how to write code?

2) i opened the main.c from the right coloumn to look at the source code as the helper pointed out, but the amount of code that went into displaying "hello windows" in this instance is pretty far ahead of what i'd consider my skill level to be at. the most advanced code i've written until now is managing to use float to add up expense1, expense2, expense3 and use total = expense1 + expense 2 etc which is probably a few months away from the overwhelming amount of code there.
Am i missing something here?

it did teach me how to execute the compilation though, which was nice

thanks for your time

Offline John Z

  • Member
  • *
  • Posts: 860
Re: absolute beginners question
« Reply #6 on: December 28, 2020, 08:45:07 PM »
[
Ok i have some questions around this, if you don't mind?

1) that help thing just had me click a few buttons to execute an already written program - what is the purpose of that in regards to learning how to write code?

2) i opened the main.c from the right coloumn to look at the source code as the helper pointed out, but the amount of code that went into displaying "hello windows" in this instance is pretty far ahead of what i'd consider my skill level to be at. the most advanced code i've written until now is managing to use float to add up expense1, expense2, expense3 and use total = expense1 + expense 2 etc which is probably a few months away from the overwhelming amount of code there.
Am i missing something here?

1) Once you have something that works it is easier to start learning from it, adding, changing etc rather than stumbling around with something broken and no idea why.

2) What was created was a windows program which has a significant amount of 'overhead' compared to a console program.  All of the extra code you see is just to be able to display the Hello World.

You can use the project wizard to create a console program, "Win32 Console" and then most of your books examples should be usable in it.

Yes C can be straightforward, it's longevity is due to its ability to also be complex.   I would say learning C lets you make a computer perform things you'd like it to do, I don't think it teaches you how a computer works.  IMO that comes from understanding the CPU and components architecture's and the controlling machine assembly language. Programming in a higher level language insulates you from that mostly, but not absolutely. 

John Z

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 189
    • Bcx Basic to C/C++ Translator
Re: absolute beginners question
« Reply #7 on: December 28, 2020, 09:28:09 PM »

Ok i have some questions around this, if you don't mind?

1) that help thing just had me click a few buttons to execute an already written program - what is the purpose of that in regards to learning how to write code?

The purpose was to show you some correct code and how to build and run it.


2) i opened the main.c from the right coloumn to look at the source code as the helper pointed out, but the amount of code that went into displaying "hello windows" in this instance is pretty far ahead of what i'd consider my skill level to be at. the most advanced code i've written until now is managing to use float to add up expense1, expense2, expense3 and use total = expense1 + expense 2 etc which is probably a few months away from the overwhelming amount of code there.
Am i missing something here?
it did teach me how to execute the compilation though, which was nice

Bingo!

The code you posted at the top of this thread had 3 errors.  See corrections below.


#include <stdio.h>
int main ()
{
    printf ("this is my first ") ;
    printf ("program! \n") ;
    return 0;
}

From one musician to another ...

I'm sometimes asked, " How did you learn to play so well?"  to which I respond, "By watching other players."
Similarly, I learned to program by examining, trying to understand, and learning from other people's code.

Bcx Basic to C/C++ Translator
https://www.BcxBasicCoders.com

Offline kaffepause

  • Member
  • *
  • Posts: 4
Re: absolute beginners question
« Reply #8 on: December 29, 2020, 12:27:52 AM »
1) Once you have something that works it is easier to start learning from it, adding, changing etc rather than stumbling around with something broken and no idea why.

2) What was created was a windows program which has a significant amount of 'overhead' compared to a console program.  All of the extra code you see is just to be able to display the Hello World.

You can use the project wizard to create a console program, "Win32 Console" and then most of your books examples should be usable in it.

Yes C can be straightforward, it's longevity is due to its ability to also be complex.   I would say learning C lets you make a computer perform things you'd like it to do, I don't think it teaches you how a computer works.  IMO that comes from understanding the CPU and components architecture's and the controlling machine assembly language. Programming in a higher level language insulates you from that mostly, but not absolutely. 

John Z

that makes sense, thanks


it did teach me how to execute the compilation though, which was nice

Bingo!

The code you posted at the top of this thread had 3 errors.  See corrections below.


#include <stdio.h>
int main ()
{
    printf ("this is my first ") ;
    printf ("program! \n") ;
    return 0;
}

From one musician to another ...

I'm sometimes asked, " How did you learn to play so well?"  to which I respond, "By watching other players."
Similarly, I learned to program by examining, trying to understand, and learning from other people's code.

[/quote]

yes thanks a lot. some guy on reddit pointed that out the semi colons as well. it's a lot to remember.
And yeah, seeing other peoples work is definitely the best way to learn something.

cheers!