S
sam
I got these two functions and questions from an employer.
I know pointer and pointer array, but how can I implement without modifying
original implementation.
Could someone help me on this question? Does C supports function override?
void func(){
char * p;
p=test();
}
char * test(){
char buf[8];
/*Here*/
return (char *) buf;
}
Question:
How, exactly, could one get a second 'char *' to use back from this
function? Be specific in terms of the exact syntax needed. Another way to
state this question is how can this function be modified to return a 'char *
' from the function, and an additional 'char *' value in one function call.
Please make sure that your answer will work even if the size of the char *
desired is not known in the outside calling function. Avoid C++ syntax.
Include statements in called and calling functions. Use good programming
practice. Although alternatives are acceptable, for this question, please
include an answer which maintains the original return type
I know pointer and pointer array, but how can I implement without modifying
original implementation.
Could someone help me on this question? Does C supports function override?
void func(){
char * p;
p=test();
}
char * test(){
char buf[8];
/*Here*/
return (char *) buf;
}
Question:
How, exactly, could one get a second 'char *' to use back from this
function? Be specific in terms of the exact syntax needed. Another way to
state this question is how can this function be modified to return a 'char *
' from the function, and an additional 'char *' value in one function call.
Please make sure that your answer will work even if the size of the char *
desired is not known in the outside calling function. Avoid C++ syntax.
Include statements in called and calling functions. Use good programming
practice. Although alternatives are acceptable, for this question, please
include an answer which maintains the original return type