Thread: Dynamic memory allocation example

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2017
    Posts
    129

    Dynamic memory allocation example

    I have allocated dynamic memory for one integer variable

    Code:
    #include<stdio.h>#include<stdlib.h>
    int main (void)
    {    
        int *i = (int*)malloc(1 * sizeof(int)); 
        
        printf(" : %d \n", i);
        printf("%d \n", i,  *(i));
        printf(" %d \n", i,  &i); 
         
       return 0;
    }
    11406808
    11406808
    11406808

    if you look at the operator all they are the different * and &

    Why does all three operator give a same data ?

    updated : size 1
    Last edited by abhi143; 11-04-2019 at 07:35 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to add dynamic memory allocation
    By JJ57663 in forum C Programming
    Replies: 1
    Last Post: 04-26-2019, 07:07 PM
  2. dynamic memory allocation
    By abhi143 in forum C Programming
    Replies: 12
    Last Post: 10-09-2018, 07:22 AM
  3. C dynamic memory allocation
    By Romyo2 in forum C Programming
    Replies: 4
    Last Post: 06-03-2015, 07:04 AM
  4. Dynamic memory allocation
    By Luciferek in forum C++ Programming
    Replies: 118
    Last Post: 10-02-2008, 11:34 AM
  5. Dynamic memory allocation
    By amdeffen in forum C++ Programming
    Replies: 21
    Last Post: 04-29-2004, 08:09 PM

Tags for this Thread