From owner-freebsd-questions@FreeBSD.ORG Tue Oct 23 22:18:37 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0029616A421 for ; Tue, 23 Oct 2007 22:18:36 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from betty.computinginnovations.com (mail.computinginnovations.com [64.81.227.250]) by mx1.freebsd.org (Postfix) with ESMTP id AB9B413C4B8 for ; Tue, 23 Oct 2007 22:18:36 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from p28.computinginnovations.com (dhcp-10-20-30-100.computinginnovations.com [10.20.30.100]) (authenticated bits=0) by betty.computinginnovations.com (8.13.8/8.13.8) with ESMTP id l9NMICg8063616; Tue, 23 Oct 2007 17:18:12 -0500 (CDT) (envelope-from derek@computinginnovations.com) Message-Id: <6.0.0.22.2.20071023171535.0244b420@mail.computinginnovations.com> X-Sender: derek@mail.computinginnovations.com X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Date: Tue, 23 Oct 2007 17:18:00 -0500 To: Harald Schmalzbauer , freebsd-questions@freebsd.org From: Derek Ragona In-Reply-To: <200710232324.09851.h.schmalzbauer@omnisec.de> References: <200710232044.53240.h.schmalzbauer@omnisec.de> <20071023220134.3abd635e@epia-2.farid-hajji.net> <20071023162454.93851854.wmoran@potentialtech.com> <200710232324.09851.h.schmalzbauer@omnisec.de> Mime-Version: 1.0 X-ComputingInnovations-MailScanner-Information: Please contact the ISP for more information X-ComputingInnovations-MailScanner: Found to be clean X-ComputingInnovations-MailScanner-From: derek@computinginnovations.com X-Spam-Status: No Content-Type: text/plain; charset="iso-8859-1"; format=flowed Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: Re: Mentor for C self study wanted X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Oct 2007 22:18:37 -0000 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 : > > > On Tue, 23 Oct 2007 20:44:52 +0200 > > > > > > Harald Schmalzbauer wrote: > > > > The first one was for example the attached code: Why does it segfau= lt? > > > > > > Mailman ate the attachment... Can't see it here. > > > > I may be out of line, but I think if you're using FreeBSD as your > > learning platform, that it wouldn't be a problem to ask this list. > >> Harald Schmalzbauer wrote: > > > Am Dienstag, 23. Oktober 2007 21:43:52 schrieben Sie: > > >>> Hello Aryeh, > > >>> > > >>> I'm willing to pay fair fees, but are you interested in "micro paym= ent" > > >>> ;) ? > > >> > > >> For other reasons I love micro payments. > > >> > > >>> Serious, I'll have the one or other short question per week (I'm > > >>> usually busy, just making spare time lessons from my book (UTC-1 sp= are > > >>> time)). > > >> > > >> Just so I know what level to present on what is your background in CS > > >> and programming? > > > > > > CS?? > > > I'm able to solve problems analytically, but I don't know any language > > > really well. > > > I know bourne shell, csh, pascal, and basic. And a tiny bit asm, but > > > that's been on ZX81. > > > > 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 > >void main() >{ > short nnote; > > // Numerischen Notenwert einlesen > printf("Bitte numerischen Schulnotenwert eingeben: "); > scanf("%d",&nnote); > > switch (nnote) > { > case 1: printf("Die Note %d entspricht sehr gut.",nnote); > break; > case 2: printf("Die Note %d entspricht gut.",nnote); > break; > case 3: printf("Die Note %d entspricht befriedigend.",nnote); > break; > case 4: printf("Die Note %d entspricht ausreichend.",nnote); > break; > case 5: printf("Die Note %d entspricht mangelhaft.",nnote); > break; > case 6: printf("Die Note %d entspricht ungen=FCgend.",nnote); > break; > default: printf("%d ist keine zul=E4ssige Schulnote!"); > } > printf("\n"); >} > >P.S.: >I found that declaring nnote as int soleves my problem, but I couldn=C4t >understand why. >Another one was the result of default: nnote was -1077942208 instead of 9 = for >example. if you check the man page on scanf: d Matches an optionally signed decimal integer; the next pointer must be a pointer to int. You shouldn't try to put a short into an int. Always declare the correct= =20 size for variables. Your segv is because scanf was trying to put an int=20 where it won't fit. You will get the same result if you go off the end of an array. -Derek --=20 This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks transtec Computers for their support.