Game Development Community

Simple question

by Griffin Milsap · in Technical Issues · 09/11/2005 (12:45 pm) · 4 replies

I feel like such a noob...

I have a pointer to an unsigned 8 bit character, defined as:

U8 *FileBuffer;

Then I have a line that creates an array out of that pointer which looks like:

FileBuffer[BufferSize] = 0;

Next, I have some code that fills that array with ascii values. I want the numeric value of those ascii codes stored in a separate array.

So I set up another array called beatArray by:

U32 beatArray[];

Now, I'm trying to set up a for loop that assigns the numeric values of each ascii value in FileBuffer to beatArray using dAtoi().

The problem is, that dAtoi takes a const char* as its only argument, and FileBuffer is a U8*.

How do I fit the square peg into the round hole?

-Griff

#1
09/11/2005 (1:00 pm)
Ive never looked at the engine objects, but wouldnt a U8* and a char* be the same thing?

to offer an answer maybe you can (cast) one type to the other. maybe that'll work.
#2
09/11/2005 (1:14 pm)
DAtoi((const char*)FileBuffer[0]) when evaluated is 18225, while FileBuffer[0] is equal to 49, which is ascii for "1".

Am I casting incorrectly?

-Griff
#3
09/11/2005 (1:22 pm)
DAtoi((const char*)&FileBuffer[0]) when evaluated is returning 1, which is good. The other elements in the array appear to be returning correctly too.

Its throwing a different exception now, that happens after a second and a half of processing. I'm going to check that out now. If I cant solve it, I'll be right back here.

-Griff
#4
09/11/2005 (2:55 pm)
Its asserting "Not an allocated block!" I've narrowed it down to one segment of code. (The one I've been working on for the last few hours)

If I comment it out, everything works, but if I put it in, it asserts "Not an allocated block!"

Where do I go from here?

-Griff