NO

Author Topic: Complete Newb with modern C(++) ... where best to go for hand holding?  (Read 4266 times)

fopetesl

  • Guest

I'm somewhat lost where to go for a decent tutorial on modern C.
Pelles seems to assume programming knowledge for Windows a la MSDN.
I don't have.
My experience was some years ago with TurboC and AZ86 and I haven't written a function in C since.
Some experience with PHP which I find straightforward.

What I find somewhat baffling is the HWND (hwnd), WINAPI stuff.
OK so they're the same as say, printf() but several layers removed. Right?

I recall many, may years ago trying to understand calculus which baffled me in the same way until one day a senior tutor sat down and in 15 minutes ... BINGO!
I'm clearly missing something so I need something like that experience here.

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772

I'm somewhat lost where to go for a decent tutorial on modern C.
Well, to be clear, Pelle's C is a plain C(11) compiler, nothing remotely C++. C and C++ are (should be treated as) completely different programming languages.
Quote
Pelles seems to assume programming knowledge for Windows a la MSDN.
As far as programming in C goes, no. You can write C program for console applications pretty much without any knowledge of Windows.
As programming for a target environment like Windows is/can be incredible complex, it is hard to include lessons for that in a free compiler. Pelle seems to have been busy enough to keep the compiler itself up to date.
As a general note, if I have to get down to such Windows basics, I usually fall back to (one of the earlier editions of) "Programming Windows" by Charles Petzold. Should be pretty much "the book" on programming for Windows.
Quote
My experience was some years ago with TurboC and AZ86 and I haven't written a function in C since.
Some experience with PHP which I find straightforward.
As long as you write proper ANSI C, you can do the same with Pelle's C.
Quote
What I find somewhat baffling is the HWND (hwnd), WINAPI stuff.
OK so they're the same as say, printf() but several layers removed. Right?
The basic problem is that with that, you are programming more for a specific environment (Windows in this case) rather than with a specific programming language.

Programming in a specific programming language and programming for a specific (user) environment are two different skill sets, that's something a lot of times people seem to overlook.

And as far as PHP goes (as you mentioned that you are/have been using it), it removes a lot of that by targeting a more common user environment, a web browser, which is (more or less) agnostic to the actual user environment being used (as in M$ Windows, Mac OS X, Linux KDE/Gnome/xfec/<etc>).
Quote
I recall many, may years ago trying to understand calculus which baffled me in the same way until one day a senior tutor sat down and in 15 minutes ... BINGO!
I'm clearly missing something so I need something like that experience here.
Well, things have been becoming more complex (and ever changing) since the days of Turbo C and Aztec C 86, where your only user environment was DOS.

I personally don't use Pelle's C for any Windows GUI based development, just mainly for console applications, sometimes even cross platform (Windows, Linux, DOS) and use a different programming environment (and programming language) for the very reason not to bother (too much) with the user environment specifics in GUI work that for me is always cross-platform (Windows, Linux and Mac OS).

Ralf

fopetesl

  • Guest
Many thanks, Bitbeisser.
Lot of sense there. I've downloaded a free version of the book by Charles Petzold.
That'll keep me reading for a while.
It's the 5th edition and mentions W98 early in the book.

Hopefully I can come back and report progress.

Your final paragraph is intriguing.  You seems to be suggesting there are better, (easier?), ways of generating code for a GUI?

I like LINUX and do write C code for it but not GUI applications. So my comment regarding never having written a function since DOS is not actually true though there is little difference for what I have been coding.

At present I am being forced into writing a Windows application where most of it needs a GUI since it needs to display graphs and selectable menus.

Offline DMac

  • Member
  • *
  • Posts: 272
Take a look at Catch 22.  I found that helpful when I started out.
« Last Edit: May 12, 2014, 05:31:53 PM by DMac »
No one cares how much you know,
until they know how much you care.

czerny

  • Guest
This http://www.winprog.org/tutorial/ is also a good starting point.

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Many thanks, Bitbeisser.
Lot of sense there. I've downloaded a free version of the book by Charles Petzold.
That'll keep me reading for a while.
It's the 5th edition and mentions W98 early in the book.
That's strange, AFAIK, 7th edition is the current one and that covers Windows 8. Quite a few things have changed since Windows 98, but at least you should be able to get a bit "the lay of the land" as far as GUI programming goes.
Quote
Hopefully I can come back and report progress.
Good luck!  ;)
Quote
Your final paragraph is intriguing.  You seems to be suggesting there are better, (easier?), ways of generating code for a GUI?
As far as I am personally concerned, yes. But not in C though. I am using Pascal for 38 years now, so I started also to do Windows GUI programming with Borland/Codegear/Inprise/Embarcadero Delphi (which is only for Windows, though cross-compiling and debugging for OS X) and now mainly in FreePascal with the Lazarus RAD (which support Windows, OS X and Linux).
The nice thing (for me at least) is that I don't have to deal with all those Windows (OS X/Linux KDE/Gnome/etc) internals and just use "components" with a visual editor to create the GUI parts and then fill out/add additional code for the program logic as needed. Helps me to concentrate on my application rather then having to deal with all the other fluff to get the GUI stuff by itself working.
Quote
I like LINUX and do write C code for it but not GUI applications. So my comment regarding never having written a function since DOS is not actually true though there is little difference for what I have been coding.
I used (Pelle's) C mainly for command line/console tools where I am (re)using existing libraries/snippets or on an OS where there is no Pascal available. And yes, very little (mainly filename/directory related stuff) is different regardless if you program for DOS, OS/2, TheOS, Unix or Linux...  ;)

Ralf

Offline jj2007

  • Member
  • *
  • Posts: 536
You seems to be suggesting there are better, (easier?), ways of generating code for a GUI?

It all depends on how you define "better" and "easier" ;-)

In the C++ scene, for example, many people are enthusiastic about QT, a GUI library. It's a download of several hundred megabytes, no problem with current harddisks, but each single hello world *.cpp source creates an executable of ... guess ... around 10 MB.

In case you find that exaggerated, attached a very simple Windows GUI template, with an edit control and a "File/Open" menu entry that inserts a source file content into the edit control. Compiled it's not 10 MB but 23 kB...

Re Petzold: Old and obsolete, and absolutely sufficient for 99.9% of your tasks. A good companion is the (equally old and obsolete) Win32.hlp file that is still available at PowerBasic's tool page. With Petzold and Win32.hlp together, you can create absolutely gorgeous Windows GUI apps. Alternatively, you can download the latest Win32 SDK, and spend your time learning how to use the SDK ;-)
« Last Edit: May 13, 2014, 04:31:34 AM by jj2007 »

fopetesl

  • Guest
Thanks, guys.
Sorry for delayed response. Went down with some horrible bug Sunday.
Unfortunately not the software kind :(
When I'm back up to speed I'll try and absorb and come back.