變數問題!解决办法
變數問題!?請問變數該如何變全域變數?小弟在 main.h 內宣告C/C++ codeextern char* b在 main.cpp 內C/C++
變數問題!?
請問變數該如何變全域變數?
小弟在 main.h 內宣告
C/C++ codeextern char* b;
在 main.cpp 內
C/C++ codeCount=SizeY*WriteGoal*SizeX;char* b=new char[Count];memset(b,0,Count);
↑ 確實有開出記憶體空間
在 data.cpp 內宣告
C/C++ codechar* 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);
}