19,464
社区成员
发帖
与我相关
我的任务
分享
string str;
str=(char*)malloc(2);
str[0]=char(1);
str[1]=char(2);
int datasize;
datasize=str.length();
void main( void )
{
long *buffer;
size_t size;
if( (buffer = (long *)malloc( 1000 * sizeof( long ) )) == NULL )
exit( 1 );
size = _msize( buffer );
printf( "Size of block after malloc of 1000 longs: %u\n", size );
/* Reallocate and show new size: */
if( (buffer = realloc( buffer, size + (1000 * sizeof( long )) ))
== NULL )
exit( 1 );
size = _msize( buffer );
printf( "Size of block after realloc of 1000 more longs: %u\n",
size );
free( buffer );
exit( 0 );
}
#include<malloc.h>
void CTestDlg::OnButton1()
{
std::string str;
char *p = (char*)malloc(50 * sizeof(char));
int nCount = _msize(p);
}
char* str=(char*)malloc(3);
str[0]=char(1);
str[1]=char(2);
str[2]='\0';
string str1;
str1=str;
int datasize;
datasize=str1.length();
str=(char*)malloc(3);
str[0]=char(1);
str[1]=char(2);
str[2]='\0';
int datasize;
datasize=str.length();