[Solved] C – How can a pointer overwrite a local const block of memory but not the global const block of memory?

It is completely up to the implementation. For example, const data on bare metal ARM uCs is stored in the FLASH memory. You can write to there but it will have no effect at all. Hosted systems will behave differently depending on the OS, its version and hardware. How can I overwrite a const block … Read more

[Solved] Exception thrown at 0x0F640E09 (ucrtbased.dll) in ConsoleApplication5.exe: 0xC0000005: Access violation writing location 0x014C3000?

Exception thrown at 0x0F640E09 (ucrtbased.dll) in ConsoleApplication5.exe: 0xC0000005: Access violation writing location 0x014C3000? solved Exception thrown at 0x0F640E09 (ucrtbased.dll) in ConsoleApplication5.exe: 0xC0000005: Access violation writing location 0x014C3000?

[Solved] C prog. Pointers and strings [closed]

In your first example, you MUST pass a char pointer for the “%s” modifier so it is actually the way it has to be, you would of course know that if you read the appropriate documentation, like e.g. The C Standard. The second one, is wrong. Because it would invoke undefined behavior. To print the … Read more

[Solved] How to sort structs from least to greatest in C?

fix like this #include <stdio.h> #include <stdlib.h> #include <string.h> #define BUFF_SIZE 32 #define STRUCT_SIZE 512 struct info { char name[BUFF_SIZE]; char stAddress[BUFF_SIZE]; char cityAndState[BUFF_SIZE]; char zip[BUFF_SIZE]; }; void selectionSort(struct info *ptrStruct[], int size);//! int main(void){ int count, size;//! char buffer[600]; struct info *ptrStruct[STRUCT_SIZE]; for (count = 0; count < STRUCT_SIZE; count++){ ptrStruct[count] = (struct info*) … Read more

[Solved] Why can’t we store addresses in normal int variables? and by assigning i dont want it to point anywhere.

why we need pointer variables… No, we don’t need pointer variables until… we need one. In other words, there are many cases (or algorithms) which don’t need pointers. But soon or later you realize that pointers are needed. Well, pointers contain values, which are different from integers, different from floating point numbers and so on. … Read more

[Solved] confusing notation in C++ (OMNeT++)

Let us assume that msg->dup() returned void * — that is, a pointer to void, which means a pointer whose type the compiler doesn’t track. But you may know, e.g. because of documentation on that function, or because certain preconditions have been met, that msg->dup() will return a pointer to CMessage. Before you can use … Read more