www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/10/00:53:52

Date: Mon, 9 Mar 1998 15:49:27 -0800 (PST)
Message-Id: <199803092349.PAA11543@adit.ap.net>
Mime-Version: 1.0
To: brunobg AT geocities DOT com (Bruno Barberi Gnecco), djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Struct gives a GPF

At 08:54  3/7/1998 GMT, Bruno Barberi Gnecco wrote:
>Hello!
>	I've got a problem when running a program. It worked well, but then I
>added a second struct, and it shows this error:

>#include <stdio.h>
>#include <conio.h>
>#include <stdlib.h>
>#include <string.h>
>#define   min(b,c)    (((b) <= (c)) ? (b) : (c))
>#define   max(b,c)    (((b) >= (c)) ? (b) : (c))
>
>int main() {
>    struct motorista {
>       int pontos, dia, mes, ano, carteira;
>    };
>    struct multa {
>       int infr, dia, mes, ano;
>    };
>    int tabela[] = {0, 4, 5, 5, 7, 7};
>    struct motorista mot[3];
>    int count;
>    struct multa database[20];
>    int *point, *infr, *temp;
>
>    mot[0].pontos = 0;
>    mot[1].pontos = 0;
>    mot[2].pontos = 0;
>    mot[0].carteira = 0;
>    mot[1].carteira = 0;
>    mot[2].carteira = 0;
>
>    for ( count = 0; count < 20; count++ ) {
>       printf("Type the numbers: ");
>       scanf("%d %d %d %d", &database[count].infr, &database[count].dia,
>&database[count].mes, &database[count].ano);
>
>       if ( database[count].infr == 0 && database[count].dia == 0 &&
>database[count].mes == 0 && database[count].ano == 0 ) {
>          break;
>       }
>       *temp = database[count].infr;

I don't see where you initialize `temp' to point to something...

>       *infr = tabela[*temp];
>       printf("chegou aqui");
>       *point = min(mot[1].pontos , mot[2].pontos );

Nor `point'.

>       if ( (mot[0].pontos + *infr)>19 && (mot[1].pontos + *infr)>19 &&
>(mot[2].pontos + *infr)>19) {

Nor, even, `infr'.
[snipped]

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019