Machine-translated by Google. Questions are authored in English.
Top

Discussion

#include <stdio.h>
int main()
{
    struct site
    {
        char name[] = "GeeksQuiz";
        int no_of_pages = 200;
    };
    struct site *ptr;
    printf("%d ", ptr->no_of_pages);
    printf("%s", ptr->name);
    getchar();
    return 0;
}

 

  • A.200 GeeksQuiz
  • B.200
  • C.Runtime Error
  • D.Compiler Error

Answer: D

Correct answer: Compiler Error

A structure declaration describes a type, not an object, so its members cannot carry initialisers - both char name[] = "GeeksQuiz"; and int no_of_pages = 200; are rejected. A member array also cannot have an unspecified size. The program never compiles, so the uninitialised ptr never becomes an issue.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.