Click here to Skip to main content
15,910,234 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: wave sound not playing properly..sounds different?? Pin
Richard MacCutchan12-Aug-10 10:00
mveRichard MacCutchan12-Aug-10 10:00 
QuestionCreateRemoteThread Error Pin
gothic_coder12-Aug-10 0:36
gothic_coder12-Aug-10 0:36 
AnswerRe: CreateRemoteThread Error Pin
_AnsHUMAN_ 12-Aug-10 2:30
_AnsHUMAN_ 12-Aug-10 2:30 
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 
Hi!
I've a vector of strings. I've to pass the strings in the vector to a function and there I've to replace some of the characters in the string. I've to return the rearranged string and store it in an array. I used the following code to do this:

stringc swapChars(stringc& str1)
{
 std::string str(str1.c_str());
 std::string strChar;
 std::string strChar1;
 int length = str.size();
 stringstream ss;
 stringstream ss1;
 char chr =65 +  rand() % 26;
 char chr1 = chr;
 ss << chr;
 ss >> strChar;
 str.replace((int)length/3,1,strChar);
 while(chr == chr1)
 {
  chr = 65 + rand() % 26;
 }
 chr = chr + 32;
 ss1 << chr;
 ss1 >> strChar1;
 str.replace((int)length*2/3,1,strChar1);
 return str.c_str();
}


Above is the function where I'm rearranging the string. This is how I'm calling the above function:

vector<stringc> players;
array<stringc> nameFirstPart,nameSecondPart;
unsigned int t = time(NULL);
for(register int i = 0; i<players.size()-1; i++)
{
 srand(t);
 nameSecondPart.push_back(swapChars(players[++i]));
 t++;
}


This is where i'm printing the string:

for(register int k = 0; k < nameSecondPart.size(); k++)
{
 printf("%s \n",nameSecondPart[k].c_str());
}


While printing the strings I get unexpected and irrelevant strings or characters in between. Why it comes like this? How to avoid this?
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 
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 

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.