Hiroshi_S
Junior Member level 1
C:
#include <stdio.h>
#include <string.h>
struct student
{
char name[20];
}std;
char *fun(struct student *tempStd) // pointer
{
strcpy(tempStd->name,"Thomas");
return tempStd->name;
}
char *fun_one(struct student *tempStd)
{
strcpy(tempStd->name,"Mike");
return tempStd->name;
}
int main()
{
strcpy(std.name,"Mike 2");
printf("%s%s",fun(&std),fun_one(&std));
return 0;
}
output : ThomasThomas
If I print as : printf("%s%s",fun_one(&std),fun(&std)) ,then the output is MikeMike.
Please help me to understand this concept.