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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:20:27+00:00 2026-05-20T07:20:27+00:00

Just started with K & R and on the 2nd chapter, there is the

  • 0

Just started with K & R and on the 2nd chapter, there is the line:

Declarations list the variables to be
used and state what type they have and
perhaps what their initial values are.

So:

int x = 42 is a definition.

and int x is a declaration but also a definition since every definition is a declaration.

But when we assign an intial value like K & R say, doesn’t that make the declaration a definition?

  • 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-20T07:20:27+00:00Added an answer on May 20, 2026 at 7:20 am

    You confuse two things:

    1. A declaration states (declares) what an object’s* type, name and scope is
    2. A definition defines what a object’s content is

    * object as in: variable, function etc., not an OOP object.

    A definition is hence very often also a declaration, since you cannot define what is in an object when you do not state what the type of the object is. Easiest to remember is just: “Every definition is a declaration, but not every declaration is a definition”

    For variables

    There is only 1 way to declare without defining the variable:

    extern typeX variable_name
    

    This tells the compiler that there is a variable called variable_name with type typeX, but not where to get it.
    Every other way to declare a variable is also a definition, since it tells the compiler to reserve space for it and perhaps give it an initial value.

    The difference is much clearer in structs and functions:

    For Structs

    A declaration:

    struct some_struct{
        int a;
        int b;
    }
    

    This declares some_struct to the compiler with a and b as struct variables both with type int.

    Only when you define them space is reserved and you can use them:

    void foo(){
        struct some_struct s;
        s.a = 1; // For this to work s needs to be defined
    }
    

    For functions:

    The difference is much more clear

    declaration:

    // This tells the compiler that there is a function called "foo" that returns void and takes void arguments
    void foo();
    

    A definition could be like the one above (in the struct part)

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

Sidebar

Related Questions

As I'm just starting to develop an iPad application & have started getting used
I am not a C programmer. I have just started reading K&R's TCPL last
I have just started using eclipse and wonder if there is a way to
I just started learning Zend (& OO PHP for that matter), I have spent
I have just started Entity Framework & linq and write this query var query
I have just started learning Python & have come across namespaces concept in Python.
I've just started learning XML & XSLT and have a quick question regarding Xpath.
Just started mongo and started having issue with querying already. i have a collection
Just started working with Mercurial a few days ago and there's something I don't
Just started working through the Ruby chapter in Mr. Tate's Seven Language in Seven

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.