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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:31:10+00:00 2026-05-14T03:31:10+00:00

int main() { int p; scanf(%d,&p); fun() { int arr[p]; // isn’t this similar

  • 0
int main() 
{  
    int p; 
    scanf("%d",&p);
    fun()   
    {
        int arr[p]; // isn't this similar to dynamic memory allocation?? 
    }    
}

//if not then what other objective is achieved using malloc and calloc??

//Someone please throw some light 🙂

  • 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-14T03:31:10+00:00Added an answer on May 14, 2026 at 3:31 am

    Creating an arbitrary amount on the stack is dangerous. You do not know how large the stack is (Well you can probably set it from the compiler) but if you create a 256Meg array as you have defined you WILL cause a stack overflow. IF you do it with malloc then you will create on the heap. This won’t, then, touch the stack and won’t affect the running of your application. Creating on the heap means that you are limited by the free memory on your system. If there is none the malloc returns NULL, if there is enough you are good to go. You also have the bonus of being able to free the memory whenever you like rather then when the allocation drops out of scope (ie passes the next ‘}’).

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

Sidebar

Related Questions

#include<stdio.h> #include<time.h> int main() { clock_t start; double d; long int n,i,j; scanf(%ld,&n); n=100000;
consider the code #include<stdio.h> int main(void) { char* a; scanf(%s,a);//&a and &a[0] give same
#include<stdio.h> void function(int); int main() { int x; printf(Enter x:); scanf(%d, &x); function(x); return
int main( ) { char str[200]; int n,tc; scanf(%d,&tc); while(tc--) { scanf(%d,&n); gets(str); puts(str);
int main() { int i,j; i='c'; scanf(%d,&j); // I will read 'c' here printf(%d
#include<stdio.h> int main() { int x; float peri ,area1; scanf(%d,&x); area(x, &peri, &area1); printf(
#include<stdio.h> #include<conio.h> int main(){ char i; int c; scanf(%i,&c); scanf(%c,&i);// catch the new line
#include<stdio.h> int main() { float a; printf(Enter a number:); scanf(%f,&a); printf(%d,a); return 0; }
#include<stdio.h> int main() { double fract=0; int tmp; //scanf(%lf,&fract); fract=0.312; printf(%lf,fract); printf(\n\n); while(fract>0){ fract*=(double)10;
int main() { int *d=0; printf(%d\n,*d); return 0; } this works fine. >cc legal.c

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.