www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/03/16:09:26

Xref: news2.mv.net comp.os.msdos.djgpp:2408
From: calvid AT stu DOT rpi DOT edu (David J. Calvin)
Newsgroups: comp.os.msdos.djgpp
Subject: Why doesn't this code work?
Date: 1 Apr 1996 21:59:56 GMT
Organization: Rensselaer Polytechnic Institute, Troy NY, USA
Lines: 31
Message-ID: <4jpjks$82r@usenet.rpi.edu>
Reply-To: calvid AT rpi DOT edu
NNTP-Posting-Host: icarus.stu.rpi.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'm not sure if this is a problem with DJGPP or if I'm doing something
wrong.  I'm using DJGPP V2, and when I run the following code, it SIGSEGV's.
The command line I used to compile was
gcc filename.cc -lgpp
It compiled fine, but crashed without outputting anything but the error
message.  I compiled the same code under gcc for linux, and that didn't
crash, but it didn't output the right value either.  So I'm sure it's
something I'm doing wrong, but I thought this was legal.  
Anyway, here's the code:

#include <iostream.h>

void main(void)
{
	int array1[50][50];
	int array2[2];
	int i,j;

	for(i=0; i<50; i++)
		for(j=0; j<50; j++)
			array1[i][j] = 0;

	array2[0] = 1;
	array2[1] = 2;
	cout << array2[(array1[i][j])] << endl;
}

Thanks for any help!

Dave Calvin
calvid AT rpi DOT edu

- Raw text -


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