http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

TheGrumpyProgrammer



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pointing to the wrong thing......



On Sun, 7 May 2000, Josiah Avery wrote:

>    Hello all,

>    I have once again run into another memory type problem. This one really 
> has me running up walls. Heres the scenario: I have created this function 

	It might be good to read up on pointers a bit more.  

> which preforms operations on 4 pararmeters ( more specifically, it scans the 
> edge of a polygon and store as the points in an array ). After this is 
> completed, I have the function return a pointer to the beggining of the 
> array. Sorta like this:
> int* _doStuff(int a, int b, int c, int d)
> {
>    int* results;
>    return results;
> }

	results is pointing to a random place in memory; or do you have
'results=(int *)malloc(sizeof(int)*<the number of ints you want>)'
somewhere?  Additionally you will need a 'delete <variable name>'
somewhere.
	Names with underscores (ie _* or __*) are reserved for the
compilers use.  While you will probably get by, it can create problems
(especially if you ever did something like _max); these problems will
typically be very hard to track down.

--
Marc Hernandez

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html