Page 2 of 2 FirstFirst 12
Results 16 to 27 of 27
  1. #16
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by ISmokeWeedAmICoolNow View Post
    you cant NOT have 30000 memory allocations unless you use static char arrays. your solution would have 30000 char*s all pointing to "30000".

    Code:
    char* OP[30000];
    for (int Doesnt = 0; Doesnt < 30000; ++Doesnt)
    {
    	char* KnowCPP = new char[15];
    	_itoa(Doesnt, KnowCPP, 10);
    	OP[Doesnt] = KnowCPP;
    }
    Other way round bud, static remains at a constant memory allocation. Creating a new character array (as in my earlier post) every iteration does allocate new memory every iteration (while it does clean up the old memory due to it going out of scope, it's still overhead you don't need.)

    Nice try with the insult code, shame you forgot to add 1 to "Doesnt" meaning his array with be { "0", "1"...."29999" }

    QQ moar.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  2. The Following User Says Thank You to Jason For This Useful Post:

    Hassan (08-31-2011)

  3. #17
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    Quote Originally Posted by Jason View Post


    Other way round bud, static remains at a constant memory allocation. Creating a new character array (as in my earlier post) every iteration does allocate new memory every iteration (while it does clean up the old memory due to it going out of scope, it's still overhead you don't need.)

    Nice try with the insult code, shame you forgot to add 1 to "Doesnt" meaning his array with be { "0", "1"...."29999" }

    QQ moar.


    I have never seen a programming language insult until today. LOL.

  4. #18
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by 258456 View Post
    I have never seen a programming language insult until today. LOL.
    They're everywhere!
    Code:
    Human *Hassan = (Human*)0xBEEF;
    Human *Me = (Human*)0xFFFFFFFF;
    while ( Hassan->MusicTaste == MusicTaste.Shit )
        Me->RespectFor(Hassan)--;

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  5. #19
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by Jason View Post


    They're everywhere!
    Code:
    Human *Hassan = (Human*)0xBEEF;
    Human *Me = (Human*)0xFFFFFFFF;
    while ( Hassan->MusicTaste == MusicTaste.Shit )
        Me->RespectFor(Hassan)--;
    ROFL. You mad because MJ sings and dance better than those who you listen to ?

  6. #20
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Yes, that is exactly why I am mad. Because MJ is awesome. I am not being sarcastic, I really and truly believe it...

    -.-

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  7. #21
    ISmokeWeedAmICoolNow's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    54
    Reputation
    10
    Thanks
    19
    My Mood
    Bitchy
    Quote Originally Posted by Jason View Post


    Other way round bud, static remains at a constant memory allocation. Creating a new character array (as in my earlier post) every iteration does allocate new memory every iteration (while it does clean up the old memory due to it going out of scope, it's still overhead you don't need.)

    Nice try with the insult code, shame you forgot to add 1 to "Doesnt" meaning his array with be { "0", "1"...."29999" }

    QQ moar.
    sorry to burst your bubble but your code only has one static array that gets changed every iteration, and all of the array points to that one array, so they all point to "30000" :].

    and your code had that same error in addition to its other errors by the way.

  8. #22
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by ISmokeWeedAmICoolNow View Post
    sorry to burst your bubble but your code only has one static array that gets changed every iteration, and all of the array points to that one array, so they all point to "30000" :].

    and your code had that same error in addition to its other errors by the way.
    Yes, you are correct that my second solution would not work as I thought, at the time I just assumed itoa malloc'd some memory and returned that as it's returned char*, I use C not C++ mostly so I don't have itoa often, and have to write my own.

    Code:
    static char* __itoa(int v)
    {
    	char *retVal = (char*)malloc(sizeof(char) * 10);
    	sprintf(retVal, "%d\0", v);
    	return retVal;
    }
    
    static int main(int argc, char *argv[])
    {
        char *values[30000];
        for ( int i = 0; i < 30000; i++ )
            values[i] = __itoa(i + 1);
        //assigning is complete, just to verify that all is correct we'll print them.
        for ( int i = 0; i < 1000; i++ )
            printf("%s\n", values[i]);
    
        //free the malloc'd memory
        for ( int i = 0; i < 30000; i++ ) 
            free(values[i]);
        
        return 0;
    }
    So, my original solution (the first one i posted) works anyway, get off your high horse.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  9. #23
    ISmokeWeedAmICoolNow's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    54
    Reputation
    10
    Thanks
    19
    My Mood
    Bitchy
    Quote Originally Posted by Jason View Post


    Yes, you are correct that my second solution would not work as I thought, at the time I just assumed itoa malloc'd some memory and returned that as it's returned char*, I use C not C++ mostly so I don't have itoa often, and have to write my own.

    Code:
    static char* __itoa(int v)
    {
    	char *retVal = (char*)malloc(sizeof(char) * 10);
    	sprintf(retVal, "%d\0", v);
    	return retVal;
    }
    
    static int main(int argc, char *argv[])
    {
        char *values[30000];
        for ( int i = 0; i < 30000; i++ )
            values[i] = __itoa(i + 1);
        //assigning is complete, just to verify that all is correct we'll print them.
        for ( int i = 0; i < 1000; i++ )
            printf("%s\n", values[i]);
    
        //free the malloc'd memory
        for ( int i = 0; i < 30000; i++ ) 
            free(values[i]);
        
        return 0;
    }
    So, my original solution (the first one i posted) works anyway, get off your high horse.
    you used *your* version of itoa, so it doesnt work for anyone except you. you act like ive been trying to attack you, but you posted incorrect code so i was pointing out the error, dont be so ignorant

  10. #24
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by ISmokeWeedAmICoolNow View Post
    you used *your* version of itoa, so it doesnt work for anyone except you. you act like ive been trying to attack you, but you posted incorrect code so i was pointing out the error, dont be so ignorant
    LOL itoa doesn't exist in C bud, so of course I wrote my own, I specifically stated that I made a mistake with my previous post, I was just used to my own itoa because I use C most of the time not C++.

    Also, posting:
    Code:
    char* OP[30000];
    for (int Doesnt = 0; Doesnt < 30000; ++Doesnt)
    {
    	char* KnowCPP = new char[15];
    	_itoa(Doesnt, KnowCPP, 10);
    	OP[Doesnt] = KnowCPP;
    }
    Is what? Constructive?

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  11. #25
    ISmokeWeedAmICoolNow's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    54
    Reputation
    10
    Thanks
    19
    My Mood
    Bitchy
    Quote Originally Posted by Jason View Post


    LOL itoa doesn't exist in C bud, so of course I wrote my own, I specifically stated that I made a mistake with my previous post, I was just used to my own itoa because I use C most of the time not C++.

    Also, posting:
    Code:
    char* OP[30000];
    for (int Doesnt = 0; Doesnt < 30000; ++Doesnt)
    {
    	char* KnowCPP = new char[15];
    	_itoa(Doesnt, KnowCPP, 10);
    	OP[Doesnt] = KnowCPP;
    }
    Is what? Constructive?
    you specifically stated that your first solution was correct, which it is clearly not.

    is correct c++ and it works?

  12. #26
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by ISmokeWeedAmICoolNow View Post
    you specifically stated that your first solution was correct, which it is clearly not.

    is correct c++ and it works?
    Yeah lol just looked at my first post and for some reason I thought I wrote one like this:

    Code:
    char *values[30000]
    for (int i = 0; i < 30000; i++ )
        values[i] = itoa(i + 1, new char[15], 10);
    Which I didn't, so just calm the fuck down.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  13. The Following User Says Thank You to Jason For This Useful Post:

    Hassan (09-01-2011)

  14. #27
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    /Sigh. Jason's correction works. i.e;

    [highlight=vb]char *largeArray[30000];
    for(int i = 0; i < 30000; i++)
    largeArray[i] = itoa(i + 1, new char[10], 10);[/highlight]

    The OP doesn't gives a flying fuck if he wrote anything afterwards, so no big deal.

    /Closed.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. [Help] Char Arrays [Solved]
    By kibbles18 in forum C++/C Programming
    Replies: 8
    Last Post: 09-23-2011, 04:28 PM
  2. [Help] C++ Array [Solved]
    By alvaritos in forum C++/C Programming
    Replies: 12
    Last Post: 09-09-2011, 05:31 AM
  3. Large Char Array!
    By Braco22 in forum Combat Arms Coding Help & Discussion
    Replies: 10
    Last Post: 09-03-2011, 12:38 PM
  4. [Help] Intializing a Boolean Array [Solved]
    By Braco22 in forum C++/C Programming
    Replies: 9
    Last Post: 08-31-2011, 03:22 PM
  5. [Help]Isolate new ID in a Int32 array[Solved]
    By topblast in forum Visual Basic Programming
    Replies: 3
    Last Post: 12-18-2010, 05:35 PM