[Solved] Exception thrown: read access violation. **dynamicArray** was 0x1118235. occurred

There are multiple issues with your program. Let me list all of them one by one. As mentioned in one of the comments, You are immediately deallocating memory just after you allocated it. Definitely this will result in a segmentation fault or memory access violation when you access deallocated memory. When you allocate the memory … Read more

[Solved] std::vector push_back results in access Violation

Dict* test = (Dict*)malloc(sizeof(Dict)); does not do what you think it does. malloc allocates a block of memory, but does not initialize it. So later on, when you call test->nodes.push_back, you’re calling into uninitialized memory. Undefined behavior. In your case, it crashes. The solution here is allocate test with new, which will initialize both test … Read more

[Solved] c++, reading string from file, segmentation fault

I’ve read Your answers, search in books and changed whole idea of reading-writing 🙂 Now when I write I use: int stringSize=text.length()*sizeof(char); file.write(reinterpret_cast<char*>(&stringSize),sizeof(stringSize)); file.write(text.c_str(),stringSize); And when I read I use: int stringSize=0; string text; plik.read(reinterpret_cast<char*>(&stringSize),sizeof(stringSize)); char * tempCharArray = new char[stringSize+1]{}; plik.read(tempCharArray,stringSize); text=tempCharArray; delete [] tempCharArray; No segmentation fault/access violation since then 🙂 I guess … Read more

[Solved] AccessViolationException in Delphi – impossible (check it, unbelievable…)

Try changing PBoolean to PBOOL function(IsEnabled: PBOOL): HRESULT; stdcall; var Flag: BOOL; PBoolean is a pointer to a Pascal Boolean which is 1 byte in size. PBOOL is a pointer to a Windows (C based) BOOL, which is 4 bytes in size. You need to match the size expected by windows. In general, when translating … Read more