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 6827903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:19:13+00:00 2026-05-26T22:19:13+00:00

When declaring functions in C, you should set a prototype in which you do

  • 0

When declaring functions in C, you should set a prototype in which you do not need to write the name of parameters. Just with its type is enough.

     void foo(int, char);

My question is, is it a good practice to also include names of parameters?

  • 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-26T22:19:14+00:00Added an answer on May 26, 2026 at 10:19 pm

    Yes, it’s considered good practice to name the arguments even in the prototypes.

    You will usually have all your prototypes in the header file, and the header may be the only thing your users ever get to inspect. So having meaningful argument names is the first level of documentation for your API.

    Likewise, comments about the what the functions do (not how they’re implemented, of course) should go in the header, together with their prototypes.

    A well-written header file may be the most important part of your library!


    As a curious aside, constness of arguments is an implementation detail. So if you don’t mutate an argument variable in your implementation, only put the const in the implementation:

    /* Header file */
    
    /* Computes a thingamajig with given base
     * in the given number of steps.
     * Returns half the thingamajig, or -1 on error.
     */
    int super_compute(int base, int steps); 
    

    /* implementation file */
    
    #include "theheader.h"
    
    int super_compute(const int base, int steps)
    {
      int b = 2 * base;
      while (--steps) { b /= 8; } /* no need for a local variable :-) */
      return -1;
    }
    

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

Sidebar

Related Questions

What are the technical reasons for using .prototype instead of declaring functions and members
When declaring an array as a class member, which way should it be done?
What are differences between declaring a method in a base type virtual and then
I am declaring an array of void pointers. Each of which points to a
I need to call properties and functions of an object from a different class.
I am supposed to write a program that should read from input numbers in
I'm trying to write a function that writes information to a stream. I need
i need to create a data type (struct in this case) with an array
How to implement a module say 'test' which exposes two functions getter and setter
I have already searched SO and google, I am not declaring the same variable

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.