Re: Mentor for C self study wanted

2007-10-26 Thread james
On Thu, 2007-10-25 at 23:19 +0200, Harald Schmalzbauer wrote: Am Donnerstag, 25. Oktober 2007 20:22:26 schrieb Aryeh M. Friedman: Absolutely. (I just didn't mention it before because obviously Harald already has a beginner's book on the C programming language.) Herald does in fact

Re: Mentor for C self study wanted

2007-10-25 Thread Oliver Fromme
Harald Schmalzbauer wrote: #include stdio.h void main() That's not a C program. :-) The return value of the main function of a valid C program must be int. And of course, your main function should end with return 0; or exit(0); (the latter requires #include stdlib.h at the top). By

Re: Mentor for C self study wanted

2007-10-25 Thread Erik Trulsson
On Thu, Oct 25, 2007 at 05:02:00PM +0200, Oliver Fromme wrote: Harald Schmalzbauer wrote: #include stdio.h void main() That's not a C program. :-) The return value of the main function of a valid C program must be int. And of course, your main function should end with

Re: Mentor for C self study wanted

2007-10-25 Thread Bill Moran
In response to Oliver Fromme [EMAIL PROTECTED]: Harald Schmalzbauer wrote: #include stdio.h void main() That's not a C program. :-) The return value of the main function of a valid C program must be int. And of course, your main function should end with return 0; or

Re: Mentor for C self study wanted

2007-10-25 Thread Oliver Fromme
Erik Trulsson wrote: Oliver Fromme wrote: By the way, I recommend you get a copy of the C standard and use it for reference. You can buy a digital copy (PDF) at http://webstore.ansi.org/ (Search for 9899-1999), it's $30. Alternatively ask Google for C99 draft to get a free

Re: Mentor for C self study wanted

2007-10-25 Thread cpghost
On Thu, 25 Oct 2007 17:22:11 +0200 Erik Trulsson [EMAIL PROTECTED] wrote: For a beginner the standard itself is probably a bit too heavy-going. The book usually recommended is 'The C programming language, Second edition' by Kernighan and Ritchie. ( http://cm.bell-labs.com/cm/cs/cbook/ ) Yes,

Re: Mentor for C self study wanted

2007-10-25 Thread Aryeh M. Friedman
Absolutely. (I just didn't mention it before because obviously Harald already has a beginner's book on the C programming language.) Herald does in fact have one that sucks (it does a terrible job on type sizes for example [doesn't mention that they may very on different machines])...

Re: Mentor for C self study wanted

2007-10-25 Thread Bahman M.
On 2007-10-25 Bill Moran wrote: In response to Oliver Fromme [EMAIL PROTECTED]: Harald Schmalzbauer wrote: #include stdio.h void main() That's not a C program. :-) The return value of the main function of a valid C program must be int. And of course, your main

Re: Mentor for C self study wanted

2007-10-25 Thread Harald Schmalzbauer
Am Donnerstag, 25. Oktober 2007 20:22:26 schrieb Aryeh M. Friedman: Absolutely. (I just didn't mention it before because obviously Harald already has a beginner's book on the C programming language.) Herald does in fact have one that sucks (it does a terrible job on type sizes for

Re: Mentor for C self study wanted

2007-10-24 Thread Giorgos Keramidas
On 2007-10-23 23:24, Harald Schmalzbauer [EMAIL PROTECTED] wrote: Thanks all, here was my example, just for completeness, I found mentors for my needs. #include stdio.h void main() { short nnote; // Numerischen Notenwert einlesen printf(Bitte numerischen Schulnotenwert eingeben:

Re: Mentor for C self study wanted

2007-10-23 Thread cpghost
On Tue, 23 Oct 2007 20:44:52 +0200 Harald Schmalzbauer [EMAIL PROTECTED] wrote: The first one was for example the attached code: Why does it segfault? Mailman ate the attachment... Can't see it here. -cpghost. -- Cordula's Web. http://www.cordula.ws/

Re: Mentor for C self study wanted

2007-10-23 Thread Bill Moran
In response to cpghost [EMAIL PROTECTED]: On Tue, 23 Oct 2007 20:44:52 +0200 Harald Schmalzbauer [EMAIL PROTECTED] wrote: The first one was for example the attached code: Why does it segfault? Mailman ate the attachment... Can't see it here. I may be out of line, but I think if you're

Re: Mentor for C self study wanted

2007-10-23 Thread Harald Schmalzbauer
Am Dienstag, 23. Oktober 2007 22:24:54 schrieb Bill Moran: In response to cpghost [EMAIL PROTECTED]: On Tue, 23 Oct 2007 20:44:52 +0200 Harald Schmalzbauer [EMAIL PROTECTED] wrote: The first one was for example the attached code: Why does it segfault? Mailman ate the attachment...

Re: Mentor for C self study wanted

2007-10-23 Thread Harald Schmalzbauer
Am Dienstag, 23. Oktober 2007 23:24:09 schrieb Harald Schmalzbauer: [*snip*] Although, you'll have to include your code inline to get past the sanitizers. Thanks all, here was my example, just for completeness, I found mentors for my needs. Thanks a lot to all! #include stdio.h void

Re: Mentor for C self study wanted

2007-10-23 Thread Derek Ragona
At 04:24 PM 10/23/2007, Harald Schmalzbauer wrote: Am Dienstag, 23. Oktober 2007 22:24:54 schrieb Bill Moran: In response to cpghost [EMAIL PROTECTED]: On Tue, 23 Oct 2007 20:44:52 +0200 Harald Schmalzbauer [EMAIL PROTECTED] wrote: The first one was for example the attached code: Why

Re: Mentor for C self study wanted

2007-10-23 Thread cpghost
On Tue, 23 Oct 2007 23:24:09 +0200 Harald Schmalzbauer [EMAIL PROTECTED] wrote: #include stdio.h void main() { short nnote; ^ // Numerischen Notenwert einlesen printf(Bitte numerischen Schulnotenwert eingeben: ); scanf(%d,nnote); ^ I found that declaring

Re: Mentor for C self study wanted

2007-10-23 Thread Bruce Cran
Derek Ragona wrote: At 04:24 PM 10/23/2007, Harald Schmalzbauer wrote: Am Dienstag, 23. Oktober 2007 22:24:54 schrieb Bill Moran: In response to cpghost [EMAIL PROTECTED]: On Tue, 23 Oct 2007 20:44:52 +0200 Harald Schmalzbauer [EMAIL PROTECTED] wrote: The first one was for example the

Re: Mentor for C self study wanted

2007-10-23 Thread Bruce Cran
cpghost wrote: There's a mismatch here: scanf(%d, ...) expects a pointer to int, while nnote is a pointer to a short. Normally, an int occupies more bytes in memory than a short (typically sizeof(int) == 4 on 32bit platforms, and sizeof(int) == 8 on 64bit platforms; while typically

Re: Mentor for C self study wanted

2007-10-23 Thread cpghost
On Tue, 23 Oct 2007 23:36:40 +0100 Bruce Cran [EMAIL PROTECTED] wrote: cpghost wrote: There's a mismatch here: scanf(%d, ...) expects a pointer to int, while nnote is a pointer to a short. Normally, an int occupies more bytes in memory than a short (typically sizeof(int) == 4 on 32bit

Re: Mentor for C self study wanted

2007-10-23 Thread Heiko Wundram (Beenic)
Am Dienstag, 23. Oktober 2007 23:24:09 schrieb Harald Schmalzbauer: #include stdio.h void main() { short nnote; // Numerischen Notenwert einlesen printf(Bitte numerischen Schulnotenwert eingeben: ); scanf(%d,nnote); man 3 scanf (most important thing to look at with any such

Re: Mentor for C self study wanted

2007-10-23 Thread Garrett Cooper
Bruce Cran wrote: cpghost wrote: There's a mismatch here: scanf(%d, ...) expects a pointer to int, while nnote is a pointer to a short. Normally, an int occupies more bytes in memory than a short (typically sizeof(int) == 4 on 32bit platforms, and sizeof(int) == 8 on 64bit platforms; while

Re: Mentor for C self study wanted

2007-10-23 Thread cpghost
On Tue, 23 Oct 2007 23:24:09 +0200 Harald Schmalzbauer [EMAIL PROTECTED] wrote: #include stdio.h void main() { short nnote; // Numerischen Notenwert einlesen printf(Bitte numerischen Schulnotenwert eingeben: ); scanf(%d,nnote); switch (nnote) { case 1: printf(Die