Mail Archives: djgpp/1998/10/03/03:20:10
From: | Graham Watkins <Graham AT gingecat DOT demon DOT co DOT uk>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Incomprehensible messages when attempting to run program
|
Date: | Thu, 1 Oct 1998 08:43:38 +0100
|
Organization: | dis-
|
Message-ID: | <jp3mMAAqKzE2Ew3A@gingecat.demon.co.uk>
|
NNTP-Posting-Host: | gingecat.demon.co.uk
|
X-NNTP-Posting-Host: | gingecat.demon.co.uk:158.152.77.124
|
X-Trace: | news.demon.co.uk 907399116 nnrp-10:18598 NO-IDENT gingecat.demon.co.uk:158.152.77.124
|
X-Complaints-To: | abuse AT demon DOT net
|
MIME-Version: | 1.0
|
X-Newsreader: | Turnpike (32) Version 3.05 <I0cLCaUEoOEFJMnQElGqNUTgtV>
|
Lines: | 78
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Can anybody out there explain this?
I am currently attempting to learn C using the djgpp compiler. When
attempting to run the program below which has compiled without errors,
all I get is the following message:
====== contents of stderr from random.exe 3==========
Exiting due to signal SIGSEGV
General Protection Fault at eip=00001662
eax=3cf26d88 ebx=74f605a0 ecx=OOOOea4O edx=74f61544 esi=00000054
edi=OOOOfaaO
ebp=0004fa74 esp=0004fa70 program=c:/djgpp/bin/random.exe cs: sel=0117
base=82d50000 limit=0005ffff
ds: sel=Ollf base=82d50000 limit=0005ffff es: sel=Ollf base=82d50000
limit=0005ffff fs: sel=OOc7 base=00014eb0 limit=DOOOffff gs: sel=012f
base=00000000 limit=ffffffff ss: sel=Ollf base=82d50000 limit=0005ffff
Call frame traceback EIPs: 0x00001662
0x00001cda
I have no idea what all this means, or whether it is a result of a
program fault, or due to my (limited) programming skills. If anybody
could tell me what I am doing wrong, I would appreciate it.
The program:
/*RANDOM.C creates a multi-dimensional array*/
#include <stdio.h>
#include <stdlib.h>
/*Declare a random array with 1000 elements*/
int random_array[10][10][10];
int a, b, c;
main()
{
/*Fill an array with random numbers. The C library*/
/*function rand() returns a random number. Use one*/
/*for loop for each array subscript.*/
for (a = 0; a < 10; a++)
{
for (b = 0; b < 10; b++)
{
for (c = 0; b < 10; c++)
{
random_array[a][b][c] = rand();
}
}
}
/*Now display the array elements 10 at a time*/
for (a = 0; a < 10; a++)
{
for (b = 0; b < 10; b++)
{
for (c = 0; c < 10; c++)
{
printf("\nrandom_array[%d][%d][%d] = ",
a, b, c);
printf("\%d", random_array[a][b][c]);
}
printf("\nPress a key to continue, CTRL+C to
quit.");
getch();
}
}
} /*End of main()*/
--
Graham Watkins
He who fights with monsters should look to it that he himself does not become a
monster. And when you gaze long into an abyss the abyss also gazes into you.
F.Nietzche - 'Beyond Good and Evil'
- Raw text -