Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C++/C Programming › MULTI-DIMESIONAL C-Style Strings

MULTI-DIMESIONAL C-Style Strings

Posts 1–5 of 5 · Page 1 of 1
25
258456
MULTI-DIMESIONAL C-Style Strings
I tried to use multi-dimensional c-style strings but i keep getting into corners in which i can't get out, so if somebody can explain them for me i would appreciate it.


I have been using it like this:

Code:
char szString[3][40];
also i have read that this is the same:

Code:
char **szString = 0;
I have no idea how to put the strings in it. Thanks in advance.
#1 · 14y ago
Jason
Jason
If you're using the 2nd option you need to dynamically allocate the memory for the char**.

i.e, say you're going to store....20 strings at this stage:

Code:
char **strArray = (char**)calloc(20, sizeof(char*));
So now the top level has been allocated, but there has been no room actually allocated for strings themselves, just the pointers to the strings. To produce a valid pointer you can do it several ways, the easiest being strdup, it will duplicate an existing string into heap memory and give you a pointer to that string, you can then add that pointer to your array:

For example:

Code:
char **strArray = (char**)calloc(20, sizeof(char*));
char *derp = "literal static string";
//now, i don't want to risk the "derp" variable being collected or modified somewhere during runtime, so I'll create my own copy of the string (not the pointer to the string, the string itself.
strArray[0] = strdup(derp);
It might be easier to envision what this is doing when you consider:

Code:
char** == *char[]
So essentially you have an array of pointers-to-string.

As always, pointers can be a mindfuck.
#2 · 14y ago
25
258456
Sorry for late reply. Thanks Jason that makes sense. And ya, as usual pointers are bein annoying, lol.


The only thing annoying me now is that this line is giving me an Assertion error:

Code:
sprintf(szServerRequestArray[i - 2], "somestring %i some string %i some string", WhichOne, i);
#3 · edited 14y ago · 14y ago
Jason
Jason
Quote Originally Posted by 258456 View Post
Sorry for late reply. Thanks Jason that makes sense. And ya, as usual pointers are bein annoying, lol.


The only thing annoying me now is that this line is giving me an Assertion error:

Code:
sprintf(szServerRequestArray[i - 2], "somestring %i some string %i some string", WhichOne, i);
Im guessing you never allocated any memory for szServerRequestArray[i - 2] to point to. Personally I'd use a buffer and then duplicate.

Code:
char buffer[256];
//other code
sprintf(buffer, "somestring %i some string %i some string", WhichOne, i);
szServerRequestArray[i - 2] = strdup(buffer);
#4 · 14y ago
25
258456
Quote Originally Posted by Jason View Post


Im guessing you never allocated any memory for szServerRequestArray[i - 2] to point to. Personally I'd use a buffer and then duplicate.

Code:
char buffer[256];
//other code
sprintf(buffer, "somestring %i some string %i some string", WhichOne, i);
szServerRequestArray[i - 2] = strdup(buffer);
LOl, this is just a pain, i am just gonna use the function to return the string, the only bad thing is i will need to call the function many more times, but it isn't that bad performance wise. Thanks guys.
#5 · 14y ago
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

  • Playing Warrock In Multi Windows Need HelpBy Shadowguild in WarRock - International Hacks
    27Last post 20y ago
  • New Style - Pop OutBy Bull3t in Art & Graphic Design
    9Last post 20y ago
  • Can you Multi gunz still?By rzoin in Gunz General
    2Last post 20y ago
  • New StyleBy Chronologix in Art & Graphic Design
    3Last post 20y ago
  • [Done] Siggy Request.. Warrock styleBy Zcar in Help & Requests
    7Last post 20y ago

Tags for this Thread

None