CrazyEngineers
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • [Prototype]

    MemberJan 20, 2014

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • Aadit Kapoor

    MemberJan 22, 2014

    [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.
    You did not understand the question!I said can i call printf() and scanf() without writing up the #includes.
    Are you sure? This action cannot be undone.
    Cancel
  • Sanyam Khurana

    MemberJan 22, 2014

    Aadit Kapoor
    You did not understand the question!I said can i call printf() and scanf() without writing up the #includes.
    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?

    If you don't include header files, you'll get an error for function not defined.
    Are you sure? This action cannot be undone.
    Cancel
  • Nayan Goenka

    MemberJan 22, 2014

    Printf() 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.
    Are you sure? This action cannot be undone.
    Cancel
  • Aadit Kapoor

    MemberJan 22, 2014

    No that's not correct.
    If you make a c program in turbo c++ without declaring stdio.h,you don't get an error.
    Are you sure? This action cannot be undone.
    Cancel
  • Nayan Goenka

    MemberJan 22, 2014

    printf() 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
    Are you sure? This action cannot be undone.
    Cancel
  • Nayan Goenka

    MemberJan 22, 2014

    and 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.
    Are you sure? This action cannot be undone.
    Cancel
  • Aadit Kapoor

    MemberJan 22, 2014

    It 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.
    Are you sure? This action cannot be undone.
    Cancel
  • Ankita Katdare

    AdministratorJan 22, 2014

    @#-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.
    Are you sure? This action cannot be undone.
    Cancel
  • Aadit Kapoor

    MemberJan 23, 2014

    Thank you bhaiya's and didi's
    One more question-:
    1.What is a dummy loop in C?
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberJan 23, 2014

    Aadit Kapoor
    Thank you bhaiya's and didi's
    One more question-:
    1.What is a dummy loop in C?
    while(1) { }

    you can call this a dummy loop
    Are you sure? This action cannot be undone.
    Cancel
  • Aadit Kapoor

    MemberJan 23, 2014

    Vishal0203
    while(1) { }

    you can call this a dummy loop
    This is not 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()
    }
    Are you sure? This action cannot be undone.
    Cancel
  • Vignesh Gawali

    MemberJan 23, 2014

    well 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.
    Are you sure? This action cannot be undone.
    Cancel
  • Aadit Kapoor

    MemberJan 23, 2014

    The 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).
    Are you sure? This action cannot be undone.
    Cancel
  • guptas.sneha

    MemberJan 23, 2014

    There 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 header<stdio.h> you can define it as
    int printf();
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register