I have written this code to get the file in a directory, now i want to make it open the .txt & .ini & .docx and print this line: "=== THIS FILE HAS BEEN COMPRIMIZED ==="; in the file, need help with that code please.

Here is my code to get the files:

#include<iostream>
#include<string>
#include<wtypes.h>

using namespace std;

int main()
{
   HANDLE FindHandle = INVALID_HANDLE_VALUE;
   WIN32_FIND_DATA FindData;
   string FileName = ".\\*.*";   // . specifies the current directory
   FindHandle = FindFirstFile(FileName.c_str(), &FindData);
   if (INVALID_HANDLE_VALUE != FindHandle)
   {
      do
      {
         cout << FindData.cFileName << '\n';
      } while (FindNextFile(FindHandle, &FindData) != 0);
      FindClose(FindHandle);
   }
   return 0;
}

Thanks...

Don't know if anyone else here has the same feeling that I have.....

I have a feeling that this may either be a prank, or something malicious....

Am I the only one who feels this way?

Also, wrong forum.

Edited 4 Years Ago by Begginnerdev: edit

Really, you have no idee what malicious code is if you think this is malicious.

Edited 4 Years Ago by MasterHacker110

Am I the only one who feels this way?

Nope. I'm giving the OP the benefit of the doubt though, because it's possible that this has legitimate uses. However there's a strong chance that it's a very naive attempt at virus propagation logic.

Also, wrong forum.

Looks fine to me.

Edited 4 Years Ago by deceptikon

*.txt and *.ini files should be simple and straight forward to process as you described in your post. I don't know how the subject of this thread fits into that. *.docx files are more problematic because the are binary files, not text files. Other languages such as VB.NET and C# would be better suited to process *.docx files, which asre witten by Microsoft Word or Open Office.

@AD: The docx format is not really a binary format, it is just a zipped xml file. You can decompress it with a standard zip library and then read / write it with any decent xml library, plenty of those are available in C/C++.

This question has already been answered. Start a new discussion instead.