请教一个struct的问题
我定义了一个struct.
typedef struct{
int a;
int b;
char *info;
}Mystruct;
void fun()
{
char buff[128];
memset(buff,0,128);
Mystruct *pData=(Mystruct *)buff;
pData->a=1;
pData->b=2;
memcpy(pData->info,(char *)"aaaaa",5);
CString str;
str.Format("%s",&(pData->info));
AfxMessageBox(str);
}
为什么在执行
str.Format("%s",&(pData->info));
时会出错呢?
typedef struct{
int a;
int b;
char *info;
}Mystruct;
void fun()
{
char buff[128];
memset(buff,0,128);
Mystruct *pData=(Mystruct *)buff;
pData->a=1;
pData->b=2;
memcpy(pData->info,(char *)"aaaaa",5);
CString str;
str.Format("%s",&(pData->info));
AfxMessageBox(str);
}
为什么在执行
str.Format("%s",&(pData->info));
时会出错呢?
...全文
相关推荐
struct和typedef struct区别
struct typedef struct 区别
C语言结构体(struct)常见使用方法(细节问题)
主要介绍了C语言结构体(struct)常见使用方法(细节问题),需要的朋友可以参考下
C/C++语法知识:typedef struct 用法详解
主要讲述c/c++中struct和typedef struct的区别以及各种用法
typedef struct 用法详解和用法小结
typedef为C语言的关键字,作用是为一种数据类型定义一个新名字。下面就一起来看看
C# Struct的内存布局问题解答
介绍了C# Struct的内存布局问题解答,有需要的朋友可以参考一下


