Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6627363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:00:18+00:00 2026-05-25T22:00:18+00:00

please take a look at my codes below #include <stdio.h> void printOut() { static

  • 0

please take a look at my codes below

#include <stdio.h>

void printOut()
{
 static int i = 0;
 if (i < 10)
 {
  printOut(i);
 }
}

int main(int argc, char *argv[])
{

  return 0;
}

i guess there should be an error due to my invoking the non-existed function prototype.Actually, the code compiles well with mingw5 compiler, which is weird for me, then i change to Borland Compiler, i get a warning message said that no printOut function prototype, is this only a warning ? What is more, the code executes well without any pop-up error windows.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:00:19+00:00Added an answer on May 25, 2026 at 10:00 pm

    Your program’s behavior is undefined, because you define printOut() with no parameters, but you call it with one argument. You need to fix it. But you’ve written it in such a way that the compiler isn’t required to diagnose the problem. (gcc, for example, doesn’t warn about the parameter mismatch, even with -std=c99 -pedantic -Wall -Wextra -O3.)

    The reasons for this are historical.

    Pre-ANSI C (prior to 1989) didn’t have prototypes; function declarations could not specify the expected type or number of arguments. Function definition, on the other hand, specified the function’s parameters, but not in a way that the compiler could use to diagnose mismatched calls. For example, a function with one int parameter might be declared (say, in a header file) like this:

    int plus_one();
    

    and defined (say, in the corresponding .c file) like this:

    int plus_one(n)
    int n;
    {
         return n + 1;
    }
    

    The parameter information was buried inside the definition.

    ANSI C added prototypes, so the above could written like this:

    int plus_one(int n);
    
    int plus_one(int n)
    {
        return n + 1;
    }
    

    But the language continued to support the old-style declarations and definitions, so as not to break existing code. Even the upcoming C201X standard still permits pre-ANSI function declarations and definitions, though they’ve been obsolescent for 22 years now.

    In your definition:

    void printOut()
    {
        ...
    }
    

    you’re using an old-style function definition. It says that printOut has no parameters — but it doesn’t let the compiler warn you if you call it incorrectly. Inside your function you call it with one argument. The behavior of this call is undefined. It could quietly ignore the extraneous argument — or it could conceivably corrupt the stack and cause your program to die horribly. (The latter is unlikely; for historical reasons, most C calling conventions are tolerant of such errors.)

    If you want your printOut() function to have no parameters and you want the compiler to complain if you call it incorrectly, define it as:

    void printOut(void)
    {
        ...
    }
    

    This is the one and only correct way to write it in C.

    Of course if you simply make this change in your program and then add a call to printOut() in main(), you’ll have an infinite recursive loop on your hands. You probably want printOUt() to take an int argument:

    void printOut(int n)
    {
        ...
    }
    

    As it happens, C++ has different rules. C++ was derived from C, but with less concern for backward compatibility. When Stroustrup added prototypes to C++, he dropped old-style declarations altogether. Since there was no need for a special-case void marker for parameterless functions, void printOut() in C++ says explicitly that printOut has no parameters, and a call with arguments is an error. C++ also permits void printOut(void) for compatibility with C, but that’s probably not used very often (it’s rarely useful to write code that’s both valid C and valid C++.) C and C++ are two different languages; you should follow the rules for whichever language you’re using.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please take a look at following code: #include <stdio.h> #include <iostream> using namespace std;
Please take a look at below codes, for whatever reason I am unable to
Below are the list of my codes. Please kindly take a look. Option 1
Please take a look at the html listed below and let me know why
Please take a look at this example: #include <iostream> #include <vector> #include <string> using
Please take a look at this below line of code in JSF <h:inputText id=name
Please take a look at my code: #include <windows.h> #include <Sti.h> #include <iostream> #pragma
Please take a look at this code: template<class T> class A { class base
Please take a look at the following .htaccess ErrorDocument 404 /404/ RewriteEngine On RewriteRule
Please take a look here: alt text http://img16.imageshack.us/img16/2810/errrp.jpg Why i got that error when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.