sal55
Posts: 63
Joined: Sat Sep 21, 2019 7:15 pm

Re: Where can I begin learning C/C++?

Thu Oct 17, 2019 12:41 pm

(Edited to remove off-topic stuff)
Heater wrote:
Thu Oct 17, 2019 11:12 am
Why do you insist on bashing on GCC for rather dubious reasons? GCC is a very fine C/C++ compiler.
Sure. It can produce some of the best code. It's available everywhere. It can do a million things.

But it's such a cumbersome product, the output can be so overwhelming , and the delay in producing a result so annoying when you have to do lots of compiles, that it is not my first choice when compiling C code for development. (I don't do C++).

ETA: My first choice is bcc then tcc and gcc on Windows, and tcc then gcc on Linux (bcc is my private Windows C compiler).
Last edited by sal55 on Thu Oct 17, 2019 4:27 pm, edited 1 time in total.

User avatar
jahboater
Posts: 6265
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Where can I begin learning C/C++?

Thu Oct 17, 2019 12:45 pm

sal55 wrote:
Thu Oct 17, 2019 10:51 am
My own compilers are rather simple: there are no warnings, only hard errors. And they will show the first error and then stop.
That's precisely what "-Werror -Wfatal-errors" does for GCC. -Werror makes all warnings into hard errors.
-Wfatal-errors abandons the compilation after the first error. You have the choice with GCC.
sal55 wrote:
Thu Oct 17, 2019 10:51 am
but then you have to contend with 'format codes', which tells the compiler you are printing an integer, of a particular size and type, information it actually already knows.)
No it does not already know.
Take a trivial "%5d" format. This prints the integer with a minimum field width of 5, right justified, padded with spaces.
How can the compiler possibly know all that ? And its a C language thing, nothing to do with GCC.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 27390
Joined: Sat Jul 30, 2011 7:41 pm

Re: Where can I begin learning C/C++?

Thu Oct 17, 2019 1:12 pm

What does all this have to do with the OP's question?

To save you typing, nothing.

Please keep on topic.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Where can I begin learning C/C++?

Thu Oct 17, 2019 9:52 pm

Does it matter? DOOMguy does not seem to be much interested in what anyone says here.

Perhaps those learning C++ would like to see the "Back to Basics" presentations from CppCon:

For example: “Back to Basics: Object-Oriented Programming” https://www.youtube.com/watch?v=32tDTD9UJCE

A search for "cppcon back to basics 2019" on YouTube will find all of them. Have a look at 2018 and 2017 as well.

Not for total beginners perhaps but the point of the suggestion is that they look at basic topics but making use of modern C++ facilities.
Memory in C++ is a leaky abstraction .

Floxi
Posts: 2
Joined: Fri Jul 05, 2019 11:45 am

Re: Where can I begin learning C/C++?

Tue Dec 03, 2019 3:24 pm

The already mentioned beginner's book by Simon Long got updated a while ago with a GUI section and I highly recommend it to absolute beginners. It's a really great start.
https://magpi.raspberrypi.org/books

Youtube videos are great, but it's extremely hard to look up stuff you might have missed or forgotten later, that's why I prefer books. (E.g. "C Primer Plus" or "C How to Program");
Even if you learn the basics from internet tutorials, "Understanding and Using C Pointers" is highly recommended as it does a terrific job at teaching the ins and outs of pointers.

As for the "Hello World" example: It's an absolute non-issue. Firstly, every half-decent IDE marks this specific error, and secondly, mixing up operators is a sign of lazy programming and can lead to horrific results which often only can get detected at runtime.

ejolson
Posts: 5967
Joined: Tue Mar 18, 2014 11:47 am

Re: Where can I begin learning C/C++?

Tue Dec 03, 2019 4:50 pm

Floxi wrote:
Tue Dec 03, 2019 3:24 pm
The already mentioned beginner's book by Simon Long got updated a while ago with a GUI section and I highly recommend it to absolute beginners. It's a really great start.
https://magpi.raspberrypi.org/books

Youtube videos are great, but it's extremely hard to look up stuff you might have missed or forgotten later, that's why I prefer books. (E.g. "C Primer Plus" or "C How to Program");
Even if you learn the basics from internet tutorials, "Understanding and Using C Pointers" is highly recommended as it does a terrific job at teaching the ins and outs of pointers.

As for the "Hello World" example: It's an absolute non-issue. Firstly, every half-decent IDE marks this specific error, and secondly, mixing up operators is a sign of lazy programming and can lead to horrific results which often only can get detected at runtime.
It is nice to see a new edition of that introductory C programming book. I still find it strange that the author persists in the error of writing

void main()

rather than the correct

int main()

In my opinion, it does not reflect well on the MagPi publishers that the author's insistence on intentionally making this error was not overridden by technical review and editor oversight. At the same time, I greatly appreciate a book that teaches introductory programming for true beginners using a language that wears as well with continued use as C does. Thank you!

One thing missing from the present thread on learning C is how important it is to choose a suitable programming project to motivate the learning. In my opinion, only by writing code is it possible to learn any kind of computer programming. Unfortunately, beginners often want to write a full symphony before creating a few tunes.

The reason for this may be a source of examples: While there are many songs made by beginning musicians that play guitar and sing, there are relatively few GitHub repositories that consist of fun programs written in C that are simple enough for a beginner to understand, improve and learn from. Moreover, those repositories that do exist are not popular, hummable or easy to find.
Last edited by ejolson on Tue Dec 03, 2019 5:13 pm, edited 3 times in total.

User avatar
jahboater
Posts: 6265
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: Where can I begin learning C/C++?

Tue Dec 03, 2019 5:02 pm

ejolson wrote:
Tue Dec 03, 2019 4:50 pm
rather than the correct

int main()
Don't you need "int main( void )" to be correct?
ejolson wrote:
Tue Dec 03, 2019 4:50 pm
One thing missing from the present thread on learning C is how important it is to choose a suitable programming project to motivate the learning. In my opinion, only by writing code is it possible to learn any kind of computer programming. Unfortunately, beginners often want to write a full symphony before creating a few tunes.
Most definitely true.
And you must write original code yourself rather than blindly following examples.

DarkElvenAngel
Posts: 1030
Joined: Tue Mar 20, 2018 9:53 pm

Re: Where can I begin learning C/C++?

Tue Dec 03, 2019 7:06 pm

jahboater wrote:
Tue Dec 03, 2019 5:02 pm
ejolson wrote:
Tue Dec 03, 2019 4:50 pm
rather than the correct

int main()
Don't you need "int main( void )" to be correct?
ejolson wrote:
Tue Dec 03, 2019 4:50 pm
One thing missing from the present thread on learning C is how important it is to choose a suitable programming project to motivate the learning. In my opinion, only by writing code is it possible to learn any kind of computer programming. Unfortunately, beginners often want to write a full symphony before creating a few tunes.
Most definitely true.
And you must write original code yourself rather than blindly following examples.
I think it would depend on what your trying to do. In my personal journey of learning I had the background from school long ago learning Turbo Pascal and basic and I never found satisfaction with it back then. Now I aim high and go for something challenging. I might not get it right away but when you crack it then you have something to be proud of. That's just my personal thoughts and it's not for everyone. I have a background in computers so it's not like starting right from scratch. Starting from scratch you have to do learn your basics

sal55
Posts: 63
Joined: Sat Sep 21, 2019 7:15 pm

Re: Where can I begin learning C/C++?

Tue Dec 03, 2019 8:20 pm

jahboater wrote:
Tue Dec 03, 2019 5:02 pm
Don't you need "int main( void )" to be correct?
Yes. There are 2-3 possible prototypes for 'main', and 'int main()' isn't one of them. The return value needs to be 'int' because the program is expected to return a status code. Although a compiler will warn if you pile on enough options, a beginner won't know about that and won't do it. The gcc examples in that C book don't use any such options.

One problem with main() is that you can then call it like this:

Code: Select all

 int main() {
	main(1,2,3,4,"five");
	main(main);
}
It's not a good idea to do this anyway (main calling main), but using (void) or (int nargs, char** args), it has a better chance of being reported.

The C/GUI book itself seems rather odd to me: a very lightweight introduction to C occupying half of an already slim volume, then it gets into GTK, one of the most complex GUI toolkits you can have (comprising some 600 C headers IIRC). Not the sort of sort of thing you'd want to do in C anyway.
Last edited by sal55 on Tue Dec 03, 2019 10:03 pm, edited 1 time in total.

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Where can I begin learning C/C++?

Tue Dec 03, 2019 10:02 pm

DarkElvenAngel,
Starting from scratch you have to do learn your basics
Ha, I read that all wrong the first time through.

Back in the day there was no Scratch with which to learn the basics. We had to start from scratch with BASIC.

Now a days I would not recommend starting from scratch and learning ones basics with either Scratch or BASIC.

If you see what I mean :)
Memory in C++ is a leaky abstraction .

DarkElvenAngel
Posts: 1030
Joined: Tue Mar 20, 2018 9:53 pm

Re: Where can I begin learning C/C++?

Tue Dec 03, 2019 11:14 pm

Heater,

Well done, well done. I see what you did there.

I agree wholeheartedly but schools always seem to favor these odd languages over something more useful. I remember my computer science teacher teaching us Turing and LOGO who if anyone uses those these days. I thought when we got into Turbo Pascal that was something more useful. At least people still use Pascal.

Good for the OP looking to learn something a little more useful.

One piece of advice when you write your code fix all the warnings don't ignore them because your code works.

DarkElvenAngel
Posts: 1030
Joined: Tue Mar 20, 2018 9:53 pm

Re: Where can I begin learning C/C++?

Wed Dec 04, 2019 2:20 am

jcyr wrote:
Wed Dec 04, 2019 1:33 am
DarkElvenAngel wrote:
Tue Dec 03, 2019 11:14 pm
I agree wholeheartedly but schools always seem to favor these odd languages over something more useful.
I understand many institutions are turning to Python these days.
At least Python is something useful, many things can be done with it. It's not dependent on any given platform and micro python even runs on embedded microcontrollers. So it's a good first step to teach as an introduction. It's been awhile since I've been in school so nice knowing they have finally picked something better.

LdB
Posts: 1639
Joined: Wed Dec 07, 2016 2:29 pm

Re: Where can I begin learning C/C++?

Wed Dec 04, 2019 3:07 am

Talk about Necro a thread and taking it for a walk

The OP asked a question about C/C++ back in Tue Oct 01, 2019 and hasn't been back since.

Now we are talking about Python :-)

People no-one cares especially the OP.

Jamesh you said all that needs to be said a couple of posts above ... lock the thread.

User avatar
Gavinmc42
Posts: 4815
Joined: Wed Aug 28, 2013 3:31 am

Re: Where can I begin learning C/C++?

Wed Dec 04, 2019 3:11 am

Micropython is an option for Buildroot on Pi's.
That makes it useful for small embedded Pi OS's.

My Uni teaches and helps staff/researchers with Python, R and Github.
I suppose that is the science equivalent of Word, Excel and Powerpoint?
It has sort of become an expectation to know Python around here.
C++ I would regard as CS and/or a full time programmers coding language.

What is the more useful language for coders and everyone else?
C and Python respectively?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

LdB
Posts: 1639
Joined: Wed Dec 07, 2016 2:29 pm

Re: Where can I begin learning C/C++?

Wed Dec 04, 2019 3:23 am

You are posting in a C/C++ forum section .. and you ask the question :-)

Some of us don't want to wade thru this junk, can you ask it in an appropriate forum area .. General Programming discussion would probably be the go.

ejolson
Posts: 5967
Joined: Tue Mar 18, 2014 11:47 am

Re: Where can I begin learning C/C++?

Wed Dec 04, 2019 3:52 am

LdB wrote:
Wed Dec 04, 2019 3:07 am
People no-one cares especially the OP.

Jamesh you said all that needs to be said a couple of posts above ... lock the thread.
I'm not sure pestering the administrators to lock threads started by people who subsequently leave the forum is a good use of anyone's time. While apparent it is that you don't want to discuss how to learn the C programming language, I was quite happy to find out about the new edition of Simon's book.

LdB
Posts: 1639
Joined: Wed Dec 07, 2016 2:29 pm

Re: Where can I begin learning C/C++?

Wed Dec 04, 2019 6:51 am

The irony of you accusing me of wasting time :-)
Please explain what Python, Logo, Basic or half the other junk in the posts above has to do with learning C?
If you are posting on topic I have no issue and I wouldn't complain.
Now all we need is 20 posts about me complaining, that should really finish the thread off :-)

Again I simply echo Jamesh, this junk is annoying you read it because of the title but the discussion doesn't match the topic.
jamesh wrote:
Thu Oct 17, 2019 1:12 pm
What does all this have to do with the OP's question?

To save you typing, nothing.

Please keep on topic.

ejolson
Posts: 5967
Joined: Tue Mar 18, 2014 11:47 am

Re: Where can I begin learning C/C++?

Wed Dec 04, 2019 3:57 pm

LdB wrote:
Wed Dec 04, 2019 6:51 am
The irony of you accusing me of wasting time :-)
I just finished looking through Simon's book to see if it suggested any additional programming exercises and projects that could be done in C for a beginner. I found six blank pages at the end. Maybe a discussion of suitable exercises that could go with each chapter would make that book a better learning resource and help anyone reading this thread get started with C as well. In the end, such an effort could result in a companion book with problems at the correct level.

Does anyone know if there is already a source of introductory programming projects designed to be completed in C with a difficulty level suitable for a person reading Simon's book?

LetsLearnCoding
Posts: 2
Joined: Thu Jun 11, 2020 4:09 pm

Re: Where can I begin learning C/C++?

Thu Jun 11, 2020 4:18 pm

Hi!

For anyone still trying to learn how to program, lots of my friends have recommended this to me and I can personally vouch for this course here:

https://training.mammothinteractive.com ... onbootcamp

Hope this helps! :D

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Where can I begin learning C/C++?

Fri Jun 12, 2020 2:11 am

Here is an interesting forum quirk.

Suspecting that user LetsLearnCoding was a spammer I clicked on the "2" next to "Posts" above. The result is:

"No suitable matches were found."

But it says he made two posts and I'm reading one of them! How is that possible?
Memory in C++ is a leaky abstraction .

DarkElvenAngel
Posts: 1030
Joined: Tue Mar 20, 2018 9:53 pm

Re: Where can I begin learning C/C++?

Fri Jun 12, 2020 2:33 am

Heater wrote:
Fri Jun 12, 2020 2:11 am
Here is an interesting forum quirk.

Suspecting that user LetsLearnCoding was a spammer I clicked on the "2" next to "Posts" above. The result is:

"No suitable matches were found."

But it says he made two posts and I'm reading one of them! How is that possible?
I'm getting the same thing. I wonder if it has to do with being a new user? However the link is for a python boot camp or something. I'm not going to open it but that's the url. I've noticed some strange behaviour with posts vanishing and the threads changing to not read. I know a mod didn't delete it. And I know I answered the post...

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Where can I begin learning C/C++?

Fri Jun 12, 2020 4:04 am

Yes, this is not the first time I have seen new posters with low post count but no posts for them can be found.

Previously I when to flag them a SPAM and found someone had already done so. I thought the mods had deleted the posts. But not in this case.
Memory in C++ is a leaky abstraction .

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13366
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Where can I begin learning C/C++?

Fri Jun 12, 2020 8:58 am

Heater wrote:
Fri Jun 12, 2020 2:11 am
Here is an interesting forum quirk.

Suspecting that user LetsLearnCoding was a spammer I clicked on the "2" next to "Posts" above. The result is:

"No suitable matches were found."

But it says he made two posts and I'm reading one of them! How is that possible?
True, they have one some "optimisation" on the forum, resulting that some things are not updated immediately anymore., but only daily.
Its a pain... :twisted:

Its what you get with a forum with 1.6-million posts, and three-hundred-thousand members.

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Where can I begin learning C/C++?

Fri Jun 12, 2020 9:25 am

Hmm...

That does not sound like such a lot. If even 10% of all the members made one post per day that wouldn't even be 4 posts per second.

What are you using for a database there, a monastery full of monks with quills and parchment?

It would be interesting to know what the actual usage stats are.
Memory in C++ is a leaky abstraction .

ejolson
Posts: 5967
Joined: Tue Mar 18, 2014 11:47 am

Re: Where can I begin learning C/C++?

Fri Jun 12, 2020 4:07 pm

Unfortunately, the discussion is still off topic. I learned C by reading "The C Programming Language" by Kernighan and Ritchie and writing some programs that ran on a VAX 11/750. Note that the protected virtual memory employed by Linux on a Pi is just as convenient when learning C: Only the program crashes, not the entire operating system.

Back off topic
Heater wrote:
Fri Jun 12, 2020 9:25 am
It would be interesting to know what the actual usage stats are.
In your thread on using the Raspberry Pi to calculate the number of different ways to arrange carpet in a rectangular room

viewtopic.php?t=257317&start=250#p1589165

appears the graph

Image

which shows the number of new posts per year on this forum over time.

I also made a comparison between one month during the epidemic and a year earlier but lost track of where that post went. If you could find it, I'd very much appreciate that.
Last edited by ejolson on Fri Jun 12, 2020 4:26 pm, edited 1 time in total.

Return to “C/C++”