简体   繁体   中英

'new char[]' does not work, but it should

I had the code, that returned char* If a write in cpp:

char* test_char = new char[size];

all is good, but if i write in header:

char* test_char;

and in cpp:

test_char = new char[size];

the program compiles but does not run.

What am I doing wrong?

char = new char[size];

You probably want

test_char = new char[size];
char = new char[size];

This should not even compile. You are missing a variable name:

test_char = new char[size];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM