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

Discussion

What is the Error of this program?

#include <stdio.h>
#define CONDITION(x) 
printf("letsfindcourse");                         
int main()
{
  CONDITION(0);
  return 0;
}

 

  • A.letsfindcourse
  • B.Compilation error
  • C.Runtime error
  • D.None of the above

Answer: B

Correct answer: Compilation error

CONDITION(x) is defined with an empty body - the macro definition ends at the end of that line. The printf on the next line is therefore not part of the macro at all: it is an ordinary statement sitting at file scope, outside any function, which the compiler rejects. Continuing the definition onto a second line requires a backslash at the end of the first.

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

Post your comment

Please log in or register to post a comment.