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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:33:06+00:00 2026-05-22T23:33:06+00:00

Recently, while I was writing a brief introduction to C for Fortran programmers, one

  • 0

Recently, while I was writing a brief introduction to C for Fortran programmers, one of said Fortran programmers asked me about type casting.
To him, it did not really make sense that in C you have to explicitly cast variables instead of having the compiler do it for you automatically.
I actually had a bit of hard time making my point that this is good thing because it helps in avoiding unintentional errors.

How would you justify this?

  • 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-22T23:33:07+00:00Added an answer on May 22, 2026 at 11:33 pm

    C does not need casts. Conversions are mostly done automatically at compile time.

    This works and is idiomatic C

    #include <stdio.h>
    int main(void) {
        double x;
        int i;
    
        x = 42;                  /* automatically convert `int` to `double` */
        i = x;                   /* automatically convert `double` to `int` */
        printf("%f\n", i * 1.0); /* automatically convert `int` to `double` */
    
        printf("%d\n", (int)x);  /* explicit conversion needed */
    
        return 0;
    }
    

    Too many casts in a program indicate the programmer was (probably) using a C++ compiler to compile a C source file. Some (many??) uses of casts are just plain wrong.

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

Sidebar

Related Questions

This is an issue that recently came up for me while writing a new
I recently heard the term hook while talking to some people about a program
Two questions about unit tests. I've been writing unit tests for a while, however
Background: Recently while looking at a structured text editor I noticed they used a
Recently, my Eclipse 3.4 installation started complaining while trying to update installed software. I
We recently were given a client requirement to encrypt all their data while at
While working in a Java app, I recently needed to assemble a comma-delimited list
I've had an app doing prefix searches for a while. Recently the index size
Somewhat of an academic question, but I ran into this while writing some unit
Several frameworks for writing web-based desktop-like applications have recently appeared. E.g. SproutCore and Cappuccino

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.