In my opinion, 1 wrong. 2 wrong. 3 wrong.

mycli (cli)
1 , The pointer P you defined in the function is a local variable , so it will return NULL. in this case.
2. The same as number 1.
3. The function needs you return pointer , but you give it a string value.
The solutions is either:
char* v(char* p)
char p[] = " result of function v()";
return p;
} This one is better
char* v()
static p[]="result of function v()";
return p;
} It is ok.
2001-5-31 -04:00
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: which one is right?

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论