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
or
char* v()
{
static p[]="result of function v()";
return p;
} It is ok.
(#86423@0)
2001-5-31 -05:00

回到话题: which one is right?

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论

URL:   
http://www.rolia.net/zh/post.php?f=0&p=86423