Raised This Month: $51 Target: $400
 12% 

"Replace" command ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cr3V3TT3
Senior Member
Join Date: Jul 2004
Location: V'dauban
Old 01-22-2005 , 16:03   "Replace" command ?
Reply With Quote #1

hi
In small i used the "replace" command to replace a string in a string

But I don' t know what is this command in C++

Like
Code:
strcpy(prepare_hud, "Round $rn");
replace(prepare_hud, 127 , "$rn", "3");
i wan' t prepare_hud = "Round 3"

What the true code?

Sorry for this noob question ...
Cr3V3TT3 is offline
Send a message via MSN to Cr3V3TT3
vancelorgin
Senior Member
Join Date: Dec 2004
Location: san frandisco
Old 01-22-2005 , 23:53  
Reply With Quote #2

It's much easier if you use std::strings :

Code:
void ReplaceTerm(std::string& strDest, const char* lpcTerm, const char* lpcReplace){
	int iTermLen = strlen(lpcTerm);
	int iPos = 0;

	while((iPos = strDest.find(lpcTerm)) != std::string::npos)
		strDest.replace(strDest.begin() + iPos, strDest.begin() + iPos + iTermLen, lpcReplace);
}
__________________
Avoid like the plague.
vancelorgin is offline
Manip
Senior Member
Join Date: Jan 2004
Old 01-23-2005 , 00:22  
Reply With Quote #3

Except std strings are evil and shit...
Manip is offline
Send a message via AIM to Manip
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 01-23-2005 , 03:17  
Reply With Quote #4

Quote:
Originally Posted by Manip
Except std strings are evil and shit...
No, they are excellent.
__________________
hello, i am pm
PM is offline
Cr3V3TT3
Senior Member
Join Date: Jul 2004
Location: V'dauban
Old 01-23-2005 , 09:29  
Reply With Quote #5

Thx
Where have you find it plz?
Or have you got an example?

( Because i don' t know what is std lol )
Cr3V3TT3 is offline
Send a message via MSN to Cr3V3TT3
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 01-23-2005 , 15:38  
Reply With Quote #6

Try to google on STL C++ or something ^^

The std::string class is part of the Standard Template Library (STL).

Example:
Code:
#include <string>

void func()
{
   std::string str = "hi";
   str += " there!";
   printf("%s", str.c_str());
}
__________________
hello, i am pm
PM is offline
Cr3V3TT3
Senior Member
Join Date: Jul 2004
Location: V'dauban
Old 01-23-2005 , 15:44  
Reply With Quote #7

Quote:
Originally Posted by PM
Try to google on STL C++ or something ^^
I' m so exeting to make my plugin ^^
I forgot THE google lOl

Thx
Cr3V3TT3 is offline
Send a message via MSN to Cr3V3TT3
Bad HAL 9000
Senior Member
Join Date: Mar 2004
Location: Minnesota, USA
Old 01-24-2005 , 13:38  
Reply With Quote #8

I dont know If I should say what everyone is thinking or not
Bad HAL 9000 is offline
Send a message via ICQ to Bad HAL 9000 Send a message via AIM to Bad HAL 9000 Send a message via MSN to Bad HAL 9000 Send a message via Yahoo to Bad HAL 9000
Cr3V3TT3
Senior Member
Join Date: Jul 2004
Location: V'dauban
Old 01-24-2005 , 13:50  
Reply With Quote #9

Quote:
Originally Posted by Bad HAL 9000
I dont know If I should say what everyone is thinking or not
i' m a noob?
you can tell it lol
Cr3V3TT3 is offline
Send a message via MSN to Cr3V3TT3
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode