cstring help!!

hi guys,

i need your help.. i don't know why my "moduleTxt" will auto change to "t"? I never overwrite it and the address is not using the same as "moduleDat". =((

void fileFormat (char module [], bool& end, fstream& afile)
{
char moduleTxt[code];
char moduleDat[code];

cout << endl << "Address txt: " << &moduleTxt << endl << endl;
cout << endl << "Address dat: " << &moduleDat << endl << endl;

strcpy (moduleTxt, module);

cout << endl << "----- TXT: " << moduleTxt << " ------" << endl << endl;

strcat (moduleTxt, ".txt");

cout << endl << "----- TXT: " << moduleTxt << " ------" << endl << endl;

strcpy (moduleDat, module);

cout << endl << "----- DAT: " << moduleDat << " ------" << endl << endl;
cout << endl << "----- TXT: " << moduleTxt << " ------" << endl << endl;

strcat (moduleDat, ".dat");

cout << endl << "----- DAT: " << moduleDat << " ------" << endl << endl;
cout << endl << "----- TXT: " << moduleTxt << " ------" << endl << endl;

creationBinaryFile (module, moduleTxt, moduleDat, end, afile);

}


The outcome of my program came this..


Address txt: 0x28fd5e


Address dat: 0x28fd54


----- TXT: CSCI124 ------


----- TXT: CSCI124.txt ------


----- DAT: CSCI124 ------


----- TXT: CSCI124.txt ------


----- DAT: CSCI124.dat ------


----- TXT: t ------ (I didn't use any code to change my "moduleTxt" into "t"... =((

can someone help meeee... thanks....

from your post addresses i calculate that code is 10. Both strings exceed 10.
That means you write data where it doesn't belong and what you see is the result.
Topic archived. No new replies allowed.