// String_Stuff.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include char *test( char *pszstr ) { size_t count = strlen( pszstr ); char *pszstrtmp = new char[ count ]; for( int i = 0; i < (int)count; i++ ) { printf( "Copying: str(%c) - Count: %i\n", pszstr[ i ], i ); pszstrtmp[ i ] = pszstr[ i ]; } return pszstrtmp; } int _tmain(int argc, _TCHAR* argv[]) { char *psz = test( "hellothere12" ); //Outputs: hello☺5 - (size) 7 and if I pass hellothere12 it comes hellothere12ram ♠ - (size) 17 printf( "\n%s - (size) %i \n", psz, strlen( psz ) ); return 0; } //-----------------------------------------------Outputs Copying: str(h) - Count: 0 Copying: str(e) - Count: 1 Copying: str(l) - Count: 2 Copying: str(l) - Count: 3 Copying: str(o) - Count: 4 hello☺5 - (size) 7 Press any key to continue . . . Copying: str(h) - Count: 0 Copying: str(e) - Count: 1 Copying: str(l) - Count: 2 Copying: str(l) - Count: 3 Copying: str(o) - Count: 4 Copying: str(t) - Count: 5 Copying: str(h) - Count: 6 Copying: str(e) - Count: 7 Copying: str(r) - Count: 8 Copying: str(e) - Count: 9 Copying: str(1) - Count: 10 Copying: str(2) - Count: 11 hellothere12ram ♠ - (size) 17 Press any key to continue . . .