Hello guys,
i want to convert a text file to hex and have written this code :
int main(int argc, char **argv)
{
ifstream file;
string fileName = "CODEZ";
file.open(fileName.c_str()); // oeffen im Text-Modus
if(file)
{
string text; // Haupttext
while(!file.eof())
{
char buffer; // Buffer
file.get(buffer);
//text += buffer; // Zeichen zusammensetzen
cout << "%" << hex <<(int)buffer ;
}
file.close();
}
else
{
cout << "Datei Fehler!";
}
cin.get();
return 0;
}
My problem is to recognise where the line of the original document ends.
The input from text file is :
hello
world
The output is :
%68%65%6c%6c%6f%a%77%6f%72%6c%64%a%a
But my desired Output is:
%68%65%6c%6c%6f%a
%77%6f%72%6c%64%a
The Strings in the text file are of various length,...but in each line is just one word!
Any ideas how to solve this problem?