char [] 和 char * 之间如何转换
void CTestDlg::OnButton1()
{
char *pStr;
pStr= "This is a test ";
WriteLog(pStr);
}
WriteLog(char *pStr)
{
char buffer[100];
buffer=pStr;
//出错 cannot convert from 'char ' to 'char []
// 或者就是cannot convert from 'char ' to 'char *
//::memcpy(buffer,pStr,strlength);
WriteFile(hFile,Buffer,
sizeof(Buffer),
&Written,NULL);//写入文件
}
请问各位老大,如何转换啊,我目的是想向TXT文件中写入LOG
我是个VC的初学者,被VC的各种字符串折磨的不成样子了。
[解决办法]
buffer=pStr;
////////////////////////////////////
memset(buffer, 0, sizeof(buffer));
strcpy(buffer, pStr);
[解决办法]
char *pStr;
pStr= "This is a test ";
char buffer[100];
strcpy(buffer, pStr);
MessageBox(buffer);