读书人

!解决办法

发布时间: 2012-03-26 15:46:55 作者: rapoo

!?
如何全域?

小弟在 main.h 宣告

C/C++ code
extern char* b;



在 main.cpp


C/C++ code
Count=SizeY*WriteGoal*SizeX;char* b=new char[Count];memset(b,0,Count);


↑ 有出空

在 data.cpp 宣告

C/C++ code
char* b;
(Global)



什是不能使用呢?

使用方法 http://topic.csdn.net/u/20120315/20/62d1fc2f-6fd9-4614-b044-bcef2dbda790.html

[解决办法]
test.h---------------
extern char *b;

void Tmalloc();


test.cpp---------------
#include "test.h"

char* b;
void Tmalloc()
{
b=new char[10];
memset(b,0,10);
memcpy_s(b, 10, "abc",4);
}

data.cpp----------------------------
extern char *b;

void main()
{
Tmalloc();
memset(b,0,10);
}

读书人网 >C++

热点推荐