Why is .copy adding duplicate characters to one word?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ajm113
    New Member
    • Jun 2007
    • 161

    Why is .copy adding duplicate characters to one word?

    For some reason when I try to pass a string that is this:

    'man!';

    Into the first param of copy and the value of 4 in to the second param and 6 into the last argument for some reason copy is adding duplicate characters in the string. Then it comes out like so:

    man!!';

    It's kinda odd because if I form the string into a sentence it works fine, because of the spaces can someone help me out why it's doing this? I just want it to get the man! part. Just exclude the '; part.

    Code:
    Code:
    				size_t i_mFound;
    	int RB;
    	int RE;
    	int length;
    
    	i_mFound = sData.find("'");
    
    	
    	if (i_mFound!=std::string::npos) {
    	 RB = int(i_mFound);
    	 RB++;
    
    	}
    
    		
    	i_mFound = sData.find("';");
    		if (i_mFound!=std::string::npos) {
    		RE = int(i_mFound);
    		}
    		length = RE - RB;
    		length=sData.copy(szFilename,length,RB);
  • jwwicks
    New Member
    • Oct 2007
    • 19

    #2
    Did you initialize szFilename... I ran the code and seems to work as expected.

    I just init szFilename like so...

    char szFilename[1024] = {0};

    JW

    Comment

    Working...