🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #617

Re: Problems with variables//problemas con variables

#617
From: miramboo
Date: Sun, 02 Jul 2000 00:00
115 lines
4957 bytes
I would almost certainly say that your problem is pointer based.

The reason it works for a set of variables decalred in one order and not
in another is due to how the order of the variables affects program
copilation.

Lets take you case where things work OK and lets assume that you have a
pointer problem. What is probably happening is your code follows the bad
pointer but ends up in a bit of memory that (luckily) does not cause the
program to crash or may even produce semi reasonable results.

When yopu com[pile the program with the variables ordered the bad way
the copde follows the pointer as per before but ends up in a memory
address that contains differnt data (as the location of the variables
have been set to different places) that is not compaitble with wjhat the
pointer is being used for and alas your program goes awol.

This sought of thing is also responsible with code that breaks upon the
inclusin of a comment???? This may slightly change the compiled programs
structure and cause a pad pointer to land in a really bad data segment
and crash.

Anway hope this helps. I would be tracking your pointers and see where
they are going.

I could also be wrong but I have seen this sought of thing many toimes
before and the problem is usaually a bad pointer.

Goodluck







In article <8jihd0$3518@eui1nw.euskaltel.es>,
  "TimoSoft" <timosoft@geocities.com> wrote:
> I am trying to make a computer game. I am using DirectX and Borland
C++
> Builder.
> I have made some directdraw and directsound classes to simplify the
directx
> programming.
> With this classes I have made another class to control the Warriors in
my
> game.
> Now I'm making the classes and some small examples to prove them ,
then i
> will try to make a big game.
>
> When I declare the variables depending the order I use to do it my
program
> works properly,
> works but some items don't appear or justly don't works.
>
> For example:
>
> if I declare the variables in this way the program crashes
> //////////////////////////////////////////////////////////////////////
>       TObjeto Pocima;  // Tobjeto is a class which has an array of
> TSDIRECTDRAWSURFACE and counter variables
>       int VELOCIDAD;
>       int legolaspunt;
>       int gandalfpunt;
>       int primero;
>       TSDIRECTDRAW direct1; //TSDIRECTDRAW is a class i have made to
make
> idirectdraw easier
>       TSDIRECTDRAWSURFACE Temporal,logo,fondo2,fondo; // idem but with
> idirectdrawsurface
>       TPersonaje Legolas,Gandalf;  // TPersonaje is a class to control
the
> warriors in the game (it has a great array of TSDIRECTDRAWSURFACE to
keep
> the                                                         //
different
> movements of the warriors.
>       RPersonaje DatosLego,DatosGan,datosmago;
>       RegFoto REGFOTO;
> //////////////////////////////////////////////////////////////////////
>
> But if I declare the variables in this order the program works
properly
> //////////////////////////////////////////////////////////////////////
>       TObjeto Pocima;
>       int VELOCIDAD;
>       int legolaspunt;
>       int gandalfpunt;
>       int primero;
>       TSDIRECTDRAW direct1;
>       TSDIRECTDRAWSURFACE Temporal;
>       TPersonaje Legolas;
>       RPersonaje DatosLego;
>       TSDIRECTDRAWSURFACE logo;
>       RPersonaje datosmago;
>       TSDIRECTDRAWSURFACE fondo2;
>       RPersonaje DatosGan;
>       TPersonaje Gandalf;
>       TSDIRECTDRAWSURFACE fondo;
>       RegFoto REGFOTO;
> //////////////////////////////////////////////////////////////////////
>
> If I change the order the program may draw only some of the items in
the
> screen
> f.e. In some cases I can only see one of the two warriors in the game.
> I think than the pointers are the problem, but I'm not able to solve
it.
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.
Technical Details
Message-ID: <8jmvgj$e93$1@nnrp1.deja.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8jihd0$3518@eui1nw.euskaltel.es>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10c163,d2157333467379ac
X-Google-Attributes: gid10c163,public
X-Google-Thread: 105367,d2157333467379ac
X-Google-Attributes: gid105367,public
X-Google-Thread: fd3cd,d2157333467379ac
X-Google-Attributes: gidfd3cd,public
X-Google-Thread: 114592,d2157333467379ac
X-Google-Attributes: gid114592,public
From: miramboo@my-deja.com
Subject: Re: Problems with variables//problemas con variables
Date: 2000/07/02
Message-ID: <8jmvgj$e93$1@nnrp1.deja.com>
X-Deja-AN: 641428575
References: <8jihd0$3518@eui1nw.euskaltel.es>
X-Http-Proxy: 1.0 proxy2.senet.com.au:9090 (Squid/2.2.STABLE5-CSS), 1.0 x51.deja.com:80 (Squid/1.1.22) for client 203.56.238.136, 203.56.239.112
Organization: Deja.com - Before you buy.
X-Article-Creation-Date: Sun Jul 02 08:46:11 2000 GMT
X-MyDeja-Info: XMYDJUIDmiramboo
Newsgroups: alt.comp.lang.learn.c-c++,alt.games.builder,alt.games.builder.dcgames,cern.c++
X-Http-User-Agent: Mozilla/3.04 (Win95; I)