Printf() and printf as a variable

Can printf be used as a variable as well as a procedure?

Questions by chandrikakr   answers by chandrikakr

Showing Answers 1 - 9 of 9 Answers

Jaya_Kaja

  • Jul 18th, 2008
 

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
 

sarav957

  • Jul 10th, 2009
 

We can use printf as a variable and it is compiling GCC compiler
This is my program which is having runtime and compiled successfully without any
warning


#include<stdio.h>

int main( )
{
char printf='a';  /*for printing use other than printf function*/
putchar(printf);
return o;
}
 


Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions