Run-Time Check Failure #2 - Stack around the variable 'Pstream' was corrupted. |
struct cpyDataPassword { enum {MAX_SIZE = 3}; char str [MAX_SIZE]; string old_pwd; }; ofstream PFile("file.file"); void *ptrPassword = &Pw;// Getting the address of the object: Password cpyDataPassword *ptrData = (cpyDataPassword*)ptrPassword;// type-casting the address of Password to *cpyDataPassword char Pstream[ptrData->MAX_SIZE], *P = Pstream; while((*P++=getchar()) != '\n'); for(int i=0;i!=ptrData->MAX_SIZE;i++) { PFile.put(Pstream[*P]); } |
|
|
|
|
PFile.write(reinterpret_cast<char*>(&Pw),sizeof(cpyDataPassword)); |
if(PFile.is_open()) { string Pstream;while(getchar() != '\n'){PFile.write(reinterpret_cast<char*>(&Pw),sizeof(cpyDataPassword)); } |
|
|
|
|
|
|
else if((!PFile.eof())&&(Pstream.length() != Pw.MAX_SIZE))
|
|