GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Programming  >  C

 Print  |  
Question:  printf() and printf as a variable

Answer: can printf be used as a variable as well as a procedure?


July 07, 2008 12:41:13 #2
 Jaya_Kaja CRM Expert  Member Since: July 2008    Total Comments: 3 

RE: printf() and printf as a variable
 

printf  can be used as a variable . But once we declare a variable printf ,
standard Library function "printf"  can not be recongnized by the compiler within   the scope of the variable  (reason :local symbol might be having higher precedence ).
If at all library func is  used ,compiler  wil throw the error saying- " called object is not a function."

For eg : below  is an  error free C program :

#include <stdio.h>
int main()

{
     int printf;
     printf = 10;
  /*  printf("n My Number = %d",num);*/  /* Activating this line,causes an error */
     Display( printf);
    return 1;
}

Display(int num)
{
    printf("n My Number = %d",num);
}

Note : But in programming it is not recommended to  use the sandard symbols.



-Jayalakshmi  Kaja
 

     

 

Back To Question