Examveda

What will be the output of the following C code?
#include <stdio.h>
struct student
{
    char *name;
};
struct student s;
struct student fun(void)
{
    s.name = "newton";
    printf("%s\n", s.name);
    s.name = "alan";
    return s;
}
void main()
{
    struct student m = fun();
    printf("%s\n", m.name);
    m.name = "turing";
    printf("%s\n", s.name);
}

A. newton alan alan

B. alan newton alan

C. alan alan newton

D. compile time error

Answer: Option A


This Question Belongs to C Program >> Structure And Union

Join The Discussion

Related Questions on Structure and Union