programing

Discussion in 'C++' started by mc110403106, Jan 13, 2013.

  1. mc110403106

    mc110403106 Guest

    #include <iostream.h>
    main()
    {
    long z,i,b;
    cin >> z;
    cout << z;
    for (i=0;i<z;i++)
    {
    for (int c=0;c<z;c++ )
    {
    long ac;
    /*sir i want here to create variable type long (ac)again and again
    ,a1,a2,a3..... but only one address variable created i wana see how
    much memoryy decrease with thousands of long variable*/

    cout << "p" << '\n' << &ac;
    }

    }

    }
     
    mc110403106, Jan 13, 2013
    #1
    1. Advertisements

  2. To verify an assumption, perhaps.
    If it's a member of a class, or an element of an array, this will not
    hold necessarily.
    It's a funny thing, memory, isn't it? You allocate an array of five
    thousand longs, *and* write code to use it, and suddenly the process
    memory grows by more than 5000*sizeof(long). Is it linear? Is it
    logarithmic?... Somebody might want to find the pattern, *assuming*
    there is one. And then they might want to try to figure out the
    reason... They fancy themselves a researcher, so let them. Perhaps
    it's in vain to try to tell them not to do it because there is some
    theoretical dependency between the number of longs allocated and the
    amount of memory used. So? They probably want empirical evidence.

    V
     
    Victor Bazarov, Jan 13, 2013
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.