What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student n;
struct student *s = &n;
(*s).c = "hello";
printf("%p\n%p\n", s, &n);
}
#include <stdio.h>
struct student
{
char *c;
};
void main()
{
struct student n;
struct student *s = &n;
(*s).c = "hello";
printf("%p\n%p\n", s, &n);
}
A. Different address
B. Run time error
C. Nothing
D. Same address
Answer: Option D
Related Questions on Structure and Union
In a structure, what are the members also known as?
A. Variables
B. Properties
C. Objects
D. Elements
Which of the following can be a member of a structure?
A. Function
B. Another structure
C. Enumeration
D. All of the above
Join The Discussion