Article View: be.comp.programming
Article #12840Re: Segmentation Fault
From: Karel
Date: Wed, 26 Sep 2001 13:31
Date: Wed, 26 Sep 2001 13:31
50 lines
2312 bytes
2312 bytes
"Daisy" <daisy_ysiad@hotmail.com> wrote in message
> > Waarom mag ik geen 2 strings inlezen na elkaar? De source:
> >
> > #include <stdio.h>
> >
> > main(void)
> > {
> > char* string1, string2;
>
> char *string1,*string2;
>
> > printf("Geef getal: ");
> > scanf("%s",string1);
> > printf("Het ingevoerde getal is %s",string1);
> > printf("\nGeef tweede getal: ");
> > scanf("%s",string2);
> > printf("\nHet ingevoerde getal is %s",string2);
> > }
> >
> > De output:
> >
> > [14:50:47][karel@fdreactor:~/test]$ ./code
> > Geef getal: 23
> > Het ingevoerde getal is 23
> > Geef tweede getal: 11
> > Segmentation fault
> > [14:50:52][karel@fdreactor:~/testcode]$
> >
main(void)
{
char *string1, *string2;
printf("Geef getal: ");
scanf("%s",string1);
printf("Het ingevoerde getal is %s.",string1);
printf("\nGeef tweede getal: ");
scanf("%s",string2);
printf("\nHet ingevoerde getal is %s.",string2);
}
[15:29:10][karel@fdreactor:~/testcode]$ ./code
Geef getal: 12
Het ingevoerde getal is 12.
Geef tweede getal: 55
08551:
08551: calling fini: /lib/libc.so.6
08551:
Het ingevoerde getal is 55.[15:29:17][karel@fdreactor:~/testcode]$
Technical Details
Message-ID:
<BMks7.72346$6x5.15839206@afrodite.telenet-ops.be>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!193.190.198.17!newsfeeds.belnet.be!news.belnet.be!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mailReferences:
<ofks7.72306$6x5.15824854@afrodite.telenet-ops.be> <MFks7.72338$6x5.15835954@afrodite.telenet-ops.be>Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit X-Google-Thread: fcea4,235d965c7bd3acb4 X-Google-Attributes: gidfcea4,public X-Google-ArrivalTime: 2001-09-26 06:31:15 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!193.190.198.17!newsfeeds.belnet.be!news.belnet.be!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mail From: "Karel" <karel@fd.com> Newsgroups: be.comp.programming References: <ofks7.72306$6x5.15824854@afrodite.telenet-ops.be> <MFks7.72338$6x5.15835954@afrodite.telenet-ops.be> Subject: Re: Segmentation Fault Lines: 53 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: <BMks7.72346$6x5.15839206@afrodite.telenet-ops.be> Date: Wed, 26 Sep 2001 13:31:13 GMT NNTP-Posting-Host: 213.118.69.113 X-Complaints-To: abuse@pandora.be X-Trace: afrodite.telenet-ops.be 1001511073 213.118.69.113 (Wed, 26 Sep 2001 15:31:13 MET DST) NNTP-Posting-Date: Wed, 26 Sep 2001 15:31:13 MET DST Organization: Telenet Internet