Interview answers verified by specialists.

Find interview questions and answers on this website:

See right interview answers on 30 common job interview questions

How can a program be made to print the name of a source file where an error occurs?

The ANSI C standard includes a predefined macro named __FILE__ that can be used to insert the current
source code filename in your program. This macro, like the __LINE__ macro, can
be very valuable when it comes to debugging your program and checking for logic errors. For instance, the
following code, includes the filename as well as the line number when logic errors are trapped:

int print_document(char* doc_name, int destination)
     switch (destination)
          case TO_FILE:
          case TO_SCREEN:
          case TO_PRINTER:
               printf("Logic error on line number %d in the file %s!\n",
                         __LINE__, __FILE__);

Now, any erroneous values for the destination parameter can be trapped, and the offending source file and
line number can be printed.

Do you know that?

$49 average hourly rates for Graphic Designer freelance Next


Getting payments for Freelancers
1. Read how to register and get earned money

2. Open account within 5 minPayoneer sing up to get free $25