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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:05:34+00:00 2026-06-08T16:05:34+00:00

When are variables in main() allocated? Especially how much memory is allocated for the

  • 0

When are variables in main() allocated? Especially how much memory is allocated for the pointer to arrays arr and 2d in the following:

int main()
{
  float a, b;
  int *b;
  float *(arr)[6];
  float *(2d)[5][5];
}

Are these considered auto, global, or static?

  • 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-06-08T16:05:35+00:00Added an answer on June 8, 2026 at 4:05 pm

    Memory for all the local variables declared inside a function will be allocated during run time, before executing a function. For each function an activation record will be created in the stack of the process memory, which will contains all the local variables. Once the function execution is completed activation record will be poped out.

    All the variables declared inside a function are consider as auto only, unless it is explicitly declared as static or register. Variables declared outside a function will be considered as global.

    If a variable is declared inside or outside a function as static, means memory allocation will be done at compile time itself, which will be in data segment(or bss).

    All the pointer variable is going to store some virtual address(of variable of any type or function). So size of a pointer variable is 4 bytes in case of 32 bit machine and 8 bytes in case of 64 bit machine.

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

Sidebar

Related Questions

#include <stdio.h> double seed=0.579832467; main(ac, av) int ac; char *av[]; { /* declare variables
I got the following simple C++ code: #include <stdio.h> int main(void) { ::printf(\nHello,debugger!\n); }
This following code works fine: #include <stdio.h> #include <stdlib.h> int main() { struct node{
The main activity includes some variables with set values. I created a sub-activity with
What's the main point behind putting variables and method signatures inside ApplicationDelegate.h in Objective-C
I heard that static methods should use only static variables in java. But, main
I have the next scenario: I define an int[][] variable in my main class.
I have the following global in variable in file_1.pl, in package main: package main;
I am using a global variable say d_myVar, which will be allocated device memory
Can someone help me to understand the output of these program. int* fun1(); void

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.