#include <iostream.h>
#include <string.h>
char *fun(void);
void main()
{
char *p = fun();
cou<<p;
}
char *fun()
{
char buf[32];
strcpy(buf,"hel lo");
return buf;
}
In this program how the address of the buffer will be pass to the pointer?
I am confused caz buf is a local variable, and when fun() come back to the main at that time if I am not wrong stack will be cleared.
Can I know the stack working for main and for the function fun()?
or from where can i get the information about the stack?
#include <string.h>
char *fun(void);
void main()
{
char *p = fun();
cou<<p;
}
char *fun()
{
char buf[32];
strcpy(buf,"hel lo");
return buf;
}
In this program how the address of the buffer will be pass to the pointer?
I am confused caz buf is a local variable, and when fun() come back to the main at that time if I am not wrong stack will be cleared.
Can I know the stack working for main and for the function fun()?
or from where can i get the information about the stack?
Comment