Click here to Skip to main content
15,891,993 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
RantRe: CreateRemoteThread Error Pin
Cool_Dev12-Aug-10 3:30
Cool_Dev12-Aug-10 3:30 
AnswerRe: CreateRemoteThread Error Pin
Richard MacCutchan12-Aug-10 4:25
mveRichard MacCutchan12-Aug-10 4:25 
AnswerRe: CreateRemoteThread Error Pin
elchupathingy12-Aug-10 4:56
elchupathingy12-Aug-10 4:56 
GeneralRe: CreateRemoteThread Error Pin
gothic_coder12-Aug-10 21:15
gothic_coder12-Aug-10 21:15 
QuestionDuplicate String Pin
T.RATHA KRISHNAN11-Aug-10 23:08
T.RATHA KRISHNAN11-Aug-10 23:08 
QuestionRe: Duplicate String Pin
CPallini11-Aug-10 23:48
mveCPallini11-Aug-10 23:48 
AnswerRe: Duplicate String Pin
T.RATHA KRISHNAN11-Aug-10 23:59
T.RATHA KRISHNAN11-Aug-10 23:59 
AnswerRe: Duplicate String Pin
Nuri Ismail12-Aug-10 0:01
Nuri Ismail12-Aug-10 0:01 
T.RATHA KRISHNAN wrote:
I've to return the rearranged string and store it in an array

But you are not rearranging the string.
You are trying to replace some characters at particular positions (depending on the length of the input string) with some random characters.

If you really want to randomly rearrange the string then just use the standard library algorithm - std::random_shuffle[^].

Here is an example usage:
std::string s = "some test string";

// Rearrange the whole string.
std::random_shuffle(s.begin(), s.end()); 

// If you want to rearrange some part of the string
// then give a different range to random_shuffle.
// For example: rearrange first 5 chars.
std::random_shuffle(s.begin(), s.begin() + 5);


If you want to change some of the chars of your string then check out std::transform[^].

Also this snippet is from your code:
for(register int i = 0; i<players.size()-1; i++) // !!! You increment i once, normal.
{
  srand(t);
  
  // !!! You increment i second time. Why? Think about that!
  nameSecondPart.push_back(swapChars(players[++i])); 
  t++;
}


Smile | :)
GeneralRe: Duplicate String Pin
T.RATHA KRISHNAN12-Aug-10 0:12
T.RATHA KRISHNAN12-Aug-10 0:12 
GeneralRe: Duplicate String Pin
Nuri Ismail12-Aug-10 0:37
Nuri Ismail12-Aug-10 0:37 
GeneralRe: Duplicate String Pin
Aescleal12-Aug-10 0:14
Aescleal12-Aug-10 0:14 
GeneralRe: Duplicate String Pin
T.RATHA KRISHNAN12-Aug-10 0:32
T.RATHA KRISHNAN12-Aug-10 0:32 
GeneralRe: Duplicate String Pin
CPallini12-Aug-10 0:46
mveCPallini12-Aug-10 0:46 
GeneralRe: Duplicate String Pin
Aescleal12-Aug-10 1:18
Aescleal12-Aug-10 1:18 
GeneralRe: Duplicate String Pin
CPallini12-Aug-10 1:36
mveCPallini12-Aug-10 1:36 
GeneralRe: Duplicate String Pin
Aescleal12-Aug-10 2:17
Aescleal12-Aug-10 2:17 
GeneralRe: Duplicate String Pin
Nuri Ismail12-Aug-10 0:44
Nuri Ismail12-Aug-10 0:44 
GeneralRe: Duplicate String Pin
Niklas L12-Aug-10 1:17
Niklas L12-Aug-10 1:17 
GeneralRe: Duplicate String Pin
Aescleal12-Aug-10 1:19
Aescleal12-Aug-10 1:19 
GeneralRe: Duplicate String Pin
Niklas L12-Aug-10 1:30
Niklas L12-Aug-10 1:30 
GeneralRe: Duplicate String Pin
CPallini12-Aug-10 1:38
mveCPallini12-Aug-10 1:38 
GeneralRe: Duplicate String Pin
Niklas L12-Aug-10 1:42
Niklas L12-Aug-10 1:42 
GeneralRe: Duplicate String Pin
CPallini12-Aug-10 1:59
mveCPallini12-Aug-10 1:59 
GeneralRe: Duplicate String Pin
Niklas L12-Aug-10 5:34
Niklas L12-Aug-10 5:34 
QuestionC++ Pin
tushar.shinde00711-Aug-10 21:29
tushar.shinde00711-Aug-10 21:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.