Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Strings in C++
Strings in C++ [message #398962] Sat, 22 August 2009 06:54
Nightma12 is currently offline  Nightma12
Messages: 2593
Registered: August 2003
Karma:
General (2 Stars)
Category Moderator
I guess this is more C++ help than specific scripts.dll help Razz

anyway, im an amature C++ coder, and cant do strings for shit Very Happy Thumbs Up


Heres the code im trying to do:

char *RndSpawn[78];

void RandomizeArray(void){

	int counter = 0;

	for(counter=0;counter >= 78;counter++;){
		*RndSpawn[counter] = "";
	}

	for(counter=1;counter >= 78;counter++;){
		RandomizeArray2("c_chicken");
	}	

}

void RandomizeArray2(char *data){
	int RandomNumber;

	RandomNumber = Commands->Get_Random_Int(1,78);

	if (RndSpawn[RandomNumber] != ""){
		RandomizeArray2(data);
		return;
	}

	RndSpawn[RandomNumber] = *data;
}


what im trying to do is have a list of player models (ive got a total of 78) in an array and i want to 'randomize' the array everytime RandomizeArray is called.

At the moment it fills it up with c_chicken but thats just the model im useing to test my code Smile

I know my logic is correct as i coded this in VB earlier and it works perfect.

Heres my compile errors:

Compiling...
gmmain.cpp
.\gmmain.cpp(4954) : error C3861: 'RandomizeArray': identifier not found
.\gmmain.cpp(5365) : error C2365: 'RandomizeArray' : redefinition; previous definition was 'formerly unknown identifier'
.\gmmain.cpp(5369) : error C2059: syntax error : ';'
.\gmmain.cpp(5370) : error C2440: '=' : cannot convert from 'const char [1]' to 'char'
        There is no context in which this conversion is possible
.\gmmain.cpp(5373) : error C2059: syntax error : ';'
.\gmmain.cpp(5374) : error C3861: 'RandomizeArray2': identifier not found
.\gmmain.cpp(5379) : error C2365: 'RandomizeArray2' : redefinition; previous definition was 'formerly unknown identifier'
.\gmmain.cpp(5384) : warning C4130: '!=' : logical operation on address of string constant
.\gmmain.cpp(5385) : error C3861: 'RandomizeArray2': identifier not found
.\gmmain.cpp(5389) : error C2440: '=' : cannot convert from 'char' to 'char *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
.\gmmain.cpp(5822) : error C2664: 'void (GameObject *,const char *)' : cannot convert parameter 2 from 'char' to 'const char *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
.\gmmain.cpp(5822) : error C2664: 'void (GameObject *,const char *)' : cannot convert parameter 1 from 'char' to 'GameObject *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast


As you can see, lots of errors with the strings/chars. How exactly would i use strings in this context in C++?

Thanks Smile
 
Read Message
Previous Topic: SCUD Storm Recruiting!
Next Topic: My Project
Goto Forum:
  


Current Time: Thu Dec 19 10:47:49 MST 2024

Total time taken to generate the page: 0.00630 seconds