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

  • SEARCH
  • Home
  • 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 331171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:44:59+00:00 2026-05-12T09:44:59+00:00

From The C Programming Language 2nd Edition: Since an argument of a function call

  • 0

From The C Programming Language 2nd Edition:

Since an argument of a function call is an expression, type conversions also take place when arguments are passed to function. In absence of a function prototype, char and short become int, and float becomes double.

By reading the text, I am getting an impression that unless you explicitly specify the argument type by either using cast or function prototype, function arguments will always be passed as either passed as int or double.

In order to verify my assumption, I compiled the following code:

#include <stdio.h>

main()
{
     unsigned char c = 'Z';
     float number = 3.14f;
     function_call(c, number);
}

void function_call(char c, float f)
{
}

After compilation I get the following warnings:

typeconversion.c:11: warning: conflicting types for ‘function_call’

typeconversion.c:7: warning: previous implicit declaration of ‘function_call’ was here

My guess is c and number were both converted to int and double on the function call, and were then converted back to char and float. Is this what actually happened?

  • 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-12T09:44:59+00:00Added an answer on May 12, 2026 at 9:44 am

    Casts are irrelevant, it’s the (possibly implicit) prototype that matters.

    void foo(short s) {
        // do something
    }
    
    int main(void) {
      signed char c = 'a';
    
      foo(c);  // c is promoted to short by explicit prototype
      bar(c);  // c is promoted to int by implicit prototype
    }
    
    void bar(int i) {
        // do something
    }
    

    When the book says “an argument of a function call is an expression” it means that the same type promotion rules apply. It might be easier to understand if you think of a function argument as an implicit assignment to the variable specified in the function prototype. e.g. in the call to foo() above there’s an implicit short s = c.

    This is why casts don’t matter. Consider the following code snippet:

    signed char c = 'a';
    int i = (short) c;
    

    Here the value of c is promoted first to short (explicitly) then to int (implicitly). The value of i will always be an int.

    As for char and short becoming int and float becoming double that refers to the default types for implicit function prototypes. When the compiler sees a call to a function before it has seen either a prototype or the definition of the function it generates a prototype automatically. It defaults to int for integer values and double for floating-point values.

    If the eventual function declaration doesn’t match to implicit prototype, you’ll get warnings.

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

Sidebar

Ask A Question

Stats

  • Questions 208k
  • Answers 209k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Pickle with the newest protocol version and open the files… May 12, 2026 at 9:40 pm
  • Editorial Team
    Editorial Team added an answer Just use: Type type = typeof(T); Generic parameters are like… May 12, 2026 at 9:40 pm
  • Editorial Team
    Editorial Team added an answer I found that this works: public class SubclassConvention : ISubclassConvention,… May 12, 2026 at 9:40 pm

Related Questions

Object-Oriented programmers seem to have all the fun. Not only are they treated to
Consider: char amessage[] = now is the time; char *pmessage = now is the
I'm reading The C Programming Language (2nd ed.) and near the beginning, it has
From The C Programming Language (Brian W. Kernighan), 2.7 TYPE CONVERSIONS, pg 43 :

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.