Use printf and scanf without stdio.h
Can we use printf and scanf without stdio.h
if yes then why??
if yes then why??
Replies
-
[Prototype]Why not? Write your own printf and scanf definitions. But I don't see any reason to do so unless the curiosity bug has bitten.
-
Aadit Kapoor
You did not understand the question!I said can i call printf() and scanf() without writing up the #includes.[Prototype]Why not? Write your own printf and scanf definitions. But I don't see any reason to do so unless the curiosity bug has bitten. -
Sanyam Khurana
If you specifically want to call printf() and scanf() function only, then you have to add the header files. You can't skip that, because how the compiler would know where the definition of that particular function is actually is?Aadit KapoorYou did not understand the question!I said can i call printf() and scanf() without writing up the #includes.
If you don't include header files, you'll get an error for function not defined. -
Nayan GoenkaPrintf() and Scanf() are predefined functions in the stdio.h file. And unless you declare and define a function, you cannot call it. So you have to include that file.
-
Aadit KapoorNo that's not correct.
If you make a c program in turbo c++ without declaring stdio.h,you don't get an error. -
Nayan Goenkaprintf() and scanf() are C language functions. generally we use cout and cin in C++.
On other note, if you have included iostream.h, it may suffice.
But again, I would like to see that code which helps you run printf() and scanf() without stdio.h -
Nayan Goenkaand code should not be restricted to a particular compiler. Maybe Turbo C++ auto includes stdio.h (which I don't think it does). Your code won't run on other compilers so its basically pointless.
-
Aadit KapoorIt also run on gcc compiler
Code :
Turbo c ide
void main()
{
printf("hello World");
getch();
}
Save it and run it in turbo c ide or gcc after saving it. -
Ankita Katdare@#-Link-Snipped-# Does it give you a warning? (not error)
Calling a function without declaring it will create an implicit declaration based on the parameters you give.
In C, if you don't declare a function, and then you use it anyway, by default it returns type int. (In your case, printf and scanf both have int as their return type)
From what I have read, in the beginning stage C did not have function prototypes. So feature must have been implemented for backwards compatibility.
I think GCC will accept it (with a warning) because GCC does have special code to handle printf. You can check -Wformat in the manual. -
Aadit KapoorThank you bhaiya's and didi's
One more question-:
1.What is a dummy loop in C? -
Vishal Sharma
while(1) { }Aadit KapoorThank you bhaiya's and didi's
One more question-:
1.What is a dummy loop in C?
you can call this a dummy loop -
Aadit Kapoor
This is not a dummy loop!Vishal0203while(1) { }
you can call this a dummy loop
A dummy loop is
void main()
{
// variables declaration
// Here goes dummy loop
for (i=0;i<3;i++);
printf("Value of %d\n",i);
getch()
} -
Vignesh Gawaliwell i think we can use printf and scanf functions without writing the include statements. This is because the linker of turbo c automatically links the standard runtime libraries during compilation of code. this option can be found in
options->linker->libraries menu in turbo c ide. -
Aadit KapoorThe reason that printf and scanf can be called without declaring stdio.h because in C
Input and Output devices are directly connected to a medium i.e a device that is why it only happens with input and output functions.For other functions you have to first declare the particular header file (.h). -
guptas.snehaThere are few predefined functions in C, it allows us to call these functions without defining the prototypes.
if you don't want to include the headeryou can define it as
int printf();
You are reading an archived discussion.
Related Posts
It was only a while ago that apple had launched its location-based service with specific hardware as ‘iBeacon’, and suddenly it finds an android based rival. Frank Nuovo, the Ex-Vertu...
Budget Android smartphone manufacturer XOLO has launched the new Q700S in the Indian market for Rs. 9999. Most smartphones from other manufacturers in the sub Rs 10K price bracket tend...
Why the Railway tracks dont have banking? The Rail cannot slow at turnings also without banking? How is it possible?
Hi,
I have one question related to scanning, may we scan a pc or a laptop not having an antivirus using the pc which has an antivirus??
If yes..then how??...
I read an article on Economic Times that says that Powai in Mumbai is the new startup-valley in India. Called the 'Powai Valley', Mumbai has become the new hot destination...