delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/07/23/06:42:38

From: tomweston_usenet AT yahoo DOT com (Tom Weston)
Newsgroups: comp.os.msdos.djgpp
Subject: newbie: pointers/vectors confusion w/ DJGPP
Date: 23 Jul 2003 02:58:51 -0700
Organization: http://groups.google.com/
Lines: 63
Message-ID: <87752c88.0307230158.15540458@posting.google.com>
NNTP-Posting-Host: 194.193.33.9
X-Trace: posting.google.com 1058954332 31735 127.0.0.1 (23 Jul 2003 09:58:52 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: 23 Jul 2003 09:58:52 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi 

I have neither experience with DJGPP nor (much) with C++
in general but I wanted to run a small test program to 
test the speed of execution in C/C++ with another application
under Windows.

However, I seem to have fallen at the first hurdle..

It is necessary for the task in question to use containers and 
I had wanted to use vectors. However I cannot seem to interpret
the behaviour of the following small program:

#include <iostream>
#include <vector>

using namespace std;

int main() {

	vector<int> *demand; 

	for (int i=0; i<10; ++i) 
	{
		demand->push_back(7);
	}

	for (vector<int>::iterator it=demand->begin(); it!=demand->end();
++it)
	{
		cout << *it << "\n";
	}

	return 0;
}
 
I had hoped it would print 10 7s on the screen. Instead it sends about
800 lines of ints follow by the 10 7s.

Either (a) I've haven't understood some aspect of the use of
vectors/pointers
or (b) there's some issue with DJGPP and I would be very grateful
of any hints.

In case it might be the latter, I'm using gxx under windows2000, and
gxx -v produces
Reading specs from c:/djgpp/lib/gcc-lib/djgpp/3.23/specs
Configured with: /devel/gnu/gcc/3.2/gnu/gcc-3.23/configure
i586-pc-msdosdjgpp --prefix=/dev/env/DJDIR --disable-nls
Thread model: single
gcc version 3.2.3
 c:/djgpp/lib/gcc-lib/djgpp/3.23/collect2.exe c:/djgpp/lib/crt0.o
-Lc:/djgpp/lib -Lc:/djgpp/lib/gcc-lib/djgpp/3.23 -Lc:/djgpp/bin
-Lc:/djgpp/lib -Lc:/djgpp/lib/gcc-lib/djgpp/3.23/../../.. -lstdcxx -lm
-lgcc -lc -lgcc -Tdjgpp-x.djl
c:/djgpp/lib/crt0.o(.data+0xc2):crt0.s: undefined reference to `_main'
c:/djgpp/lib/libc.a(crt1.o)(.text+0x404):crt1.c: undefined reference
to `_main'
collect2: ld returned 1 exit status

Many thanks for any help,

Tom

- Raw text -


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