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 › Failure after failure after...

Failure after failure after...

Posts 1–6 of 6 · Page 1 of 1
why06jz
why06jz
Failure after failure after...
For those of you who don't know I have been working on this damned file comparator for a little over a week now, and it's been driving me insane. I didn't want to ask for help, but I've run up shit creek. It all come down to this one part. I've narrowed the entire problem down to this one infernal line of code:

Code:
#include <iostream>
#include <fstream>
using namespace std;

int CompareFiles(fstream &file1, fstream &file2);

int main()
{
    char* file[2] = {"",""};
    char files[50] = "";
      // Starting message    
      cout << "Enter: File1,File2\n";
      cin >> files;
      //Print what was entered
      cout << endl <<files << endl;
     
      // Will try to parse the text into different files
      int p = 0;
      for(int i = 0; files[i]; i++)
      {
             if(files[i]!=',')
              {
                file[p]+=files[i]; // Right here!
               cout << file[p] << endl;
              }
              // The first file should print here
              else {p++; cout << "This should be were the first is: " << file[p-1] <<endl;}
      }
      cout << file[0] << " " << file[1];
      system("pause");
      return 0;
}
Look at that it seems so damned easy right? All it's supposed to do is split up the entered text and add the strings to an array.

But every damned time I try to mess with this the thing blows up in my face. The part I highlighted in red is where everything Blows up. I can't figure out why o_O?

Here's the output:


I am so confused -_-


PS: At BA. I know you showed me one way to do it, but I want to understand how to do it this way before I try to do it the easy way.
#1 · 16y ago
B1ackAnge1
B1ackAnge1
file[p] is either char* file[0] or char* file[1] that points to a spot in memory that is your emtpy string ""
Let's start simply by saying p =0;

you say: File[0] += files[i];

So what does that do?
File[0] is a Pointer
Files[i] is a Character;
So you're adding a character (the VALUE of whatever letter is) in files[i] to Pointer File[0]

Say you enter 'a,b' and File[0] Pointers to a memory address of 0x00001000
The Hex Value for 'a' is 0x61.
So you end up saying file[0] = file[0] + 0x61; so you end up with file[0] pointer to memory address 0x000010061 where you point to garbage.
Of course the longer your actual entered filename is, it keeps moving the pointer further and further into memory

If you want to keep 2 pointers pointing to the different filenames inside the original string
(which is what you're doing)the thing to remember then is File[0] is always going to be &Files[0];
and File[1] is going to be pointing to the first character after the ','. you WILL need to replace the comma with a '\0' though otherwise File[0] will think it's the entire string length
#2 · edited 16y ago · 16y ago
why06jz
why06jz
Quote Originally Posted by B1ackAnge1 View Post
you say: File[0] += files[i];
So you end up saying file[0] = file[0] + 0x61; so you end up with file[0] pointer to memory address 0x000010061 where you point to garbage.
Of course the longer your actual entered filename is, it keeps moving the pointer further and further into memory
Oh damn! That's not good o_O...

So what if I do this *file[0] += files[i];
#3 · 16y ago
B1ackAnge1
B1ackAnge1
....hmm weird dupe post...
#4 · edited 16y ago · 16y ago
B1ackAnge1
B1ackAnge1
That won't work either

I think you need to look back at a higher level what you're trying to accomplish:
Are you trying to set 2 pointers to the beginning of each filename? or are you are trying to COPY the names into secondary buffers/strings?

The 1st I sorta described above (added possibly after you responded)
the second you'd have another 2 char[50] or so buffers and their own index that you increment yourself so it copies over the characters from the other string
#5 · 16y ago
LA
lalakijilp
i don't understand pointers to arrays yet but found an other way to solve your "problem" (or i don't understand your problem)



Code:
#include <iostream>
#include <fstream>
using namespace std;



int main()
{
    
    char files[50] = "";
      
      cout << "Enter: File1,File2\n";
      gets (files);
     
      cout << endl <<files << endl <<endl;
     
     for(int i = 0;files[i]; i++)
     {
     
     
     
     if(files[i]==',') 
     {
                       cout <<endl<<endl;
                       i++;
     }
     
     cout << files [i];
     
     }
     
      cout <<endl<<endl;
      system("pause");
      return 0;
}
#6 · edited 16y ago · 16y ago
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

  • Urgent: Computer failure after Game Crash?By tinnarcan in Combat Arms Help
    12Last post 16y ago
  • Before and after with photoshopBy Killclowns in Art & Graphic Design
    10Last post 20y ago
  • After sometime of inactivity(my intro)By vega in General
    13Last post 19y ago
  • No Hacks Work After UpdateBy sirbannedalot in WarRock - International Hacks
    10Last post 19y ago
  • HACKS DON'T WORK!! after 23-05-07By jaspertjuhh in WarRock - International Hacks
    19Last post 19y ago

Tags for this Thread

#failure