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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:42:25+00:00 2026-05-15T16:42:25+00:00

#include <stdio.h> int main() { int c = c; printf(c is %i\n, c); return

  • 0
#include <stdio.h>
int main() {
    int c = c;
    printf("c is %i\n", c);
    return 0;
}

I’m defining an integer variable called c, and I’m assigning its value to itself. But how can this even compile? c hasn’t been initialized, so how can its value be assigned to itself? When I run the program, I get c is 0.

I am assuming that the compiler is generating assembly code that is assigning space for the the c variable (when the compiler encounters the int c statement). Then it takes whatever junk value is in that un-initialized space and assigns it back to c. Is this what’s happening?

  • 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-15T16:42:26+00:00Added an answer on May 15, 2026 at 4:42 pm

    I remember quoting this in a previous answer but I can’t find it at the moment.

    C++03 §3.3.1/1:

    The point of declaration for a name is immediately after its complete declarator (clause 8) and before its initializer (if any), …

    Therefore the variable c is usable even before the initializer part.

    Edit: Sorry, you asked about C specifically; though I’m sure there is an equivalent line in there. James McNellis found it:

    C99 §6.2.1/7: Any identifier that is not a structure, union, or enumeration tag “has scope that begins just after the completion of its declarator.” The declarator is followed by the initializer.

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

Sidebar

Ask A Question

Stats

  • Questions 495k
  • Answers 495k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer By setting the Parent, you have a circular reference. PHP… May 16, 2026 at 11:29 am
  • Editorial Team
    Editorial Team added an answer MVC is about separing concerns. So you have three components… May 16, 2026 at 11:29 am
  • Editorial Team
    Editorial Team added an answer SELECT Date(p.born_at), SUM(case when status = 1 then p.value end)… May 16, 2026 at 11:29 am

Trending Tags

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

Top Members

Related Questions

Consider this program: #include <stdio.h> int main() { printf(%s\n, __FILE__); return 0; } Depending
#include <stdio.h> int main() { printf(This goes to screen\n); freopen(out.txt, a, stdout); printf(This goes
I have written a simple Hello World program. #include <stdio.h> int main() { printf(Hello
Can someone explain this behaviour? test.c: #include <stdio.h> int main(void) { printf(%d, %d\n, (int)
#include vss.h #include vswriter.h #include <VsBackup.h> #include <stdio.h> #define CHECK_PRINT(result) printf(%s\n,result==S_OK?S_OK:error) int main(int argc,
I have a question about the source-code binary on Windows. #include <stdio.h> int main()
I've just typed in an example from K&R... #include <stdio.h> int main (int argc,
I was under the impression that this code #include <windows.h> #include <stdio.h> int WINAPI
this program hangs after taking first argument:- #include <stdio.h> #include <conio.h> void ellip(char*,...); int
I was reading some samples of code, and they returned a const int. 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.