Regarding dyanamic allocation of memory

Discussion in 'C Programming' started by prati, Aug 5, 2012.

  1. prati

    prati

    Joined:
    Aug 2, 2012
    Messages:
    7
    i have written one small c programme for dynamic memory allocation.But when programme runs memory is not getting allocated. So its output is only "error".So what could be the problem?

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int i;
    int *array;
    clrscr();
    array=(int*)malloc(sizeof(int));
    if(array==NULL);
    {
    printf("error");
    return;
    }
    *array=6;
    printf("%d",*array);
    free(array);
    getch();
    }
     
    prati, Aug 5, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Jausovec

    Re: creating Dyanamic splash screen

    Peter Jausovec, Mar 12, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    540
    Peter Jausovec
    Mar 12, 2005
  2. Frank
    Replies:
    0
    Views:
    496
    Frank
    Mar 12, 2005
  3. Sundar

    Dyanamic User Controls.

    Sundar, Nov 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    379
    S. Justin Gengo
    Nov 21, 2003
  4. Ken
    Replies:
    24
    Views:
    3,896
    Ben Bacarisse
    Nov 30, 2006
  5. chris
    Replies:
    6
    Views:
    1,007
    chris
    Oct 28, 2005
Loading...

Share This Page