char *ReadFile(string& filepath)
{
string buffer="";
char temp_char;
ifstream file;
file.open(filepath);
while(!(file.eof()))
{
file.get(temp_char);
buffer+=temp_char;
}
size=buffer.length();
char *result1=new char[size];
for(int i=0;i<buffer.length();i++)
{
result1[i]=buffer[i];
}
file.close();
return result1;
}
code looks pretty normal right?
but when I run it with the rest of the program this happens...
http://imageshack.us/photo/my-images/267/chararray0001.jpg/
http://imageshack.us/photo/my-images/28/chararray0002.jpg/
http://imageshack.us/photo/my-images/11/chararray0003.jpg/
on the declaration of my result1 array(line 13) some string appends to it from the end and even if I enter values in the array it shifts and sticks to my array and when I return it it returns with the stupid meaningless string...
any ideas?
if you want the whole code I can paste here... there is no result1 declared before...
there is not much happening before function is called. some cout and cin lines only...