In my 96 line main.cpp code below, at lines 40-44 I can't get this loop to work:
if(string_a==string_b)
{
printf("string_a and string_b match\n");
return 0;
}
string_a and string_b are created from two identical files, named stringa.txt
and stringb.txt, both being 3 byte files containing: abc

If some kind person out there can take a few moments to create two such files
(create these two files in your own way without using my writetext function).

My frustration is that although these two 3 byte files are identical and although
I've verified they each both contain 'abc' by printing string_a and string_b ...
the fact remains that my loop at lines 40-44 fails to register that they match!

Perhaps my problem arises when I rename the string from loaded_values to string_a
and string_b, as per this code segment here:

char * string_a = new char[loaded_values.size() + 1];
std::copy(loaded_values.begin(), loaded_values.end(), string_a);

.. or maybe the tiny loadfile function is doing something it shouldn't, not sure.

So grateful if someone can tell me what's wrong in the above code!? Thnx, Peter
............................................Code follows.......................................
#include "mytools.h"
#include <fstream>
#include <string>
#include <iostream>
#include <stdio.h>
#include "stdafx.h"

void writetext(const char fname[], std::string str, const char method[]);

std::string loaded_values;
std::string string1;
std::string string2;
std::string string3;
std::string string_a;
std::string string_b;

int main()
{
string1="abc";
string2="def";
string3="abc";
printf("string1: %s\n",string1.c_str());
printf("string2: %s\n",string2.c_str());
printf("string3: %s\n",string3.c_str());

writetext("stringa.txt", "abc", "w");
loadfile("stringa.txt");
char * string_a = new char[loaded_values.size() + 1];
std::copy(loaded_values.begin(), loaded_values.end(), string_a);
//string_a[loaded_values.size()] = '\0'; // terminating 0 added
printf("---string_a is %s\n", string_a); //printed to show it

writetext("stringb.txt", "abc", "w");
loadfile("stringb.txt");
char * string_b = new char[loaded_values.size() + 1];
std::copy(loaded_values.begin(), loaded_values.end(), string_b);
//string_b[loaded_values.size()] = '\0'; // terminating 0 added
printf("---string_b is %s\n", string_b); //printed to show it

if(string_a==string_b)
{
printf("string_a and string_b match\n");
return 0;
}

//if(string1==string3)
//{
//printf("string1 and string3 match\n");
//return 0;
//}

}

void writetext(const char fname[], std::string str, const char method[])
{
FILE *fileText;
const char *text = str.c_str();
if(strcmp(method,"a")==0)
{
fileText = fopen (fname,"a");
fprintf(fileText,text);
fclose(fileText);
}
else if(strcmp(method,"w")==0)
{
fileText = fopen (fname,"w");
fprintf(fileText,text);
fclose(fileText);
}
else
{
printf("You entered wrong Parameter to access textfile\n");
}
}

void loadfile(const std::string &fileName)
{
loaded_values="";
std::ifstream file(fileName.c_str());
std::string line;
while(std::getline(file,line))
//loaded_values+=line+"\n";
loaded_values+=line;
printf("loaded_values is: %s\n",loaded_values.c_str());
}

//Below's what's in mytools.h:
//#ifndef GUARD_H
//#define GUARD_H
//#include <string>
//#include <stdio.h>
//extern std::string thestring;
//void loadfile(const std::string &fileName);
//void writetext(const char fname[], std::string str, const char method[]);
//extern std::string loaded_values;
//#endif