Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    Braco22's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    150
    Reputation
    12
    Thanks
    607

    Intializing Large Character Array [Solved]

    I need help creating a long char array. Or is there a much simpler way to do this? I dont want to type it out to 30000. Is there a much shorter way to do this?

    char *num[] = { "1", "2", .., "29000", "30000" };

  2. #2
    master131's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    Melbourne, Australia
    Posts
    8,858
    Reputation
    3438
    Thanks
    101,670
    My Mood
    Breezy
    Utilize a for loop? :/ Unless this is a static array then I have no idea.
    Donate:
    BTC: 1GEny3y5tsYfw8E8A45upK6PKVAEcUDNv9


    Handy Tools/Hacks:
    Extreme Injector v3.7.3
    A powerful and advanced injector in a simple GUI.
    Can scramble DLLs on injection making them harder to detect and even make detected hacks work again!

    Minion Since: 13th January 2011
    Moderator Since: 6th May 2011
    Global Moderator Since: 29th April 2012
    Super User/Unknown Since: 23rd July 2013
    'Game Hacking' Team Since: 30th July 2013

    --My Art--
    [Roxas - Pixel Art, WIP]
    [Natsu - Drawn]
    [Natsu - Coloured]


    All drawings are coloured using Photoshop.

    --Gifts--
    [Kyle]

  3. #3
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Code:
    char *largeArray[30000];
    for(int i = 0;  i < 30000; i++)
        largeArray[i] = itoa(i + 1)
    There you go.

    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)

  4. #4
    Braco22's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    150
    Reputation
    12
    Thanks
    607
    Quote Originally Posted by Jason View Post
    Code:
    char *largeArray[30000];
    for(int i = 0;  i < 30000; i++)
        largeArray[i] = itoa(i + 1)
    There you go.
    'itoa' : function does not take 1 arguments
    Last edited by Braco22; 08-31-2011 at 06:17 AM.

  5. #5
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    oh yeh that's right.

    largeArray[i] = itoa(i + 1, new char[10], 10);

    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)

  6. #6
    .::SCHiM::.'s Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    733
    Reputation
    180
    Thanks
    880
    My Mood
    Twisted
    Quote Originally Posted by Braco22 View Post
    'itoa' : function does not take 1 arguments
    You do realize that chars only go to 255 right? so once you go over that magic number behavior will be undefined?

    I'm SCHiM

    Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.

    Polymorphic engine
    Interprocess callback class
    SIN
    Infinite-precision arithmetic
    Hooking dynamic linkage
    (sloppy)Kernel mode Disassembler!!!

    Semi debugger




  7. #7
    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 .::SCHiM::. View Post
    You do realize that chars only go to 255 right? so once you go over that magic number behavior will be undefined?
    char *values[0xFF]

    Is a double pointer, so essentially an array of char* or an array of strings, not an array of chars.

    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)

  8. #8
    .::SCHiM::.'s Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    733
    Reputation
    180
    Thanks
    880
    My Mood
    Twisted
    Quote Originally Posted by Jason View Post


    char *values[0xFF]

    Is a double pointer, so essentially an array of char* or an array of strings, not an array of chars.
    Ohh wait, you're right missed the '*' there, I've said nothing

    I'm SCHiM

    Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.

    Polymorphic engine
    Interprocess callback class
    SIN
    Infinite-precision arithmetic
    Hooking dynamic linkage
    (sloppy)Kernel mode Disassembler!!!

    Semi debugger




  9. #9
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    /Marked Solved.

  10. #10
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    To save on 30,000 memory allocations:

    Code:
    char buffer[10];
    char *values[30000];
    for ( int i = 0; i < 30000; i++ )
        values[i] = itoa(i + 1, buffer, 10);

    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. #11
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    When i was first learning c++ i really hated pointers and i thought they were so useless. Now that i understand pointers i have discovered that they are really helpful. And this thread is another example of this.


    (I know this doesn't have anything to do with the thread, but i just posted it so the newbies at c++ know that pointers are extremely important)

  12. #12
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    I thought everyone knew pointers were important lul.

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

    Saltine (09-14-2011)

  14. #13
    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
    I thought everyone knew pointers were important lul.
    Well, people who are like me 8 months ago don't know. Trust me, 8 months ago 4 months after starting c++ i really thought that i would never have to use pointers because they are stupid and pointless(no pun intended). LOL.

  15. #14
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Lol but how would you survive without char*? I've only been C/C++'ing for 4 weeks at uni and basic pointers was one of the first things we learned.

  16. #15
    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
    To save on 30,000 memory allocations:

    Code:
    char buffer[10];
    char *values[30000];
    for ( int i = 0; i < 30000; i++ )
        values[i] = itoa(i + 1, buffer, 10);
    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;
    }

Page 1 of 2 12 LastLast

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