Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / arrays

Author
Message
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 22nd Feb 2009 17:33
Hi,
I have the following array in my game:


Is there a fast way of assigning all elements in the array to " " without looping through them all?

Thanks,
Alex

prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 22nd Feb 2009 17:46
char* TextObjectText[10000] = { };

btw, why do you want 10000 spaces? couldn't you use #include <string>
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 22nd Feb 2009 18:16 Edited at: 22nd Feb 2009 18:18
Thanks.

Quote: "btw, why do you want 10000 spaces?"


I don't, its just that some of the array is assigned later in the code and some is not. Later I run through parts of the array, but I get an access violation because a part of the array is not assigned to anything.

AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 22nd Feb 2009 18:29
I still get an access violation. Here is the code:



This works:



But I don't want to have to loop through the array and assign them all.

Any ideas?

Thanks,
Alex

prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 22nd Feb 2009 19:05
Im not sure, but i guess the only way is to loop through them and assign them, but it shouldn't take that long to do.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Feb 2009 00:21


This changes the if statement to check to see if TextObjectText[1] is not null, and if that's true, to then carry out the strcmp function call.

AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 23rd Feb 2009 13:42
Thanks. Can remove the looping code now

atomic knights
16
Years of Service
User Offline
Joined: 12th Apr 2008
Location: On my laptop
Posted: 25th Feb 2009 13:03
when you have char * text[1000];
text[1] =" ";

text[1] points to a valid memory location that has NULL in the first location. It is NOT address 0 as if you had done text[1] = 0;

what you want is:
text[1] = " ";

if( *text[1] == 0 )

Login to post a reply

Server time is: 2024-09-30 19:30:49
Your offset time is: 2024-09-30 19:30:49