[Solved] Referencing to a pointer member in a different class

As the compiler is telling you, this line: Note n = Note(&track.generator); Tries to construct a Note and supply a Generator** to its constructor (since track.generator has type Generator*, &track.generator has type Generator**). However, your Note class constructor accepts a Generator*, not a Generator**. Just do this instead (notice, that copy-initialization is unnecessary here, rather … Read more

[Solved] Whats wrong with the c code?

A 2D array does not decay to a pointer to a pointer. By using: maxim=findMax((int **)a,m,n); you are forcing the compiler to ignore your error. Instead of int findMax(int **a,int m,int n) use int findMax(int a[][20],int m,int n) and then, call the function simply using: maxim=findMax(a,m,n); You said: The problem statement says that int findMax(int … Read more

[Solved] Vector of pointers to vectors

Given your declarations, you need vecP[1]->resize(6); // or vecP[1]->at(3) = 7; The problem being that since your (top level) vector elements are pointers, you need to dereference them to access their contents. The easiest way of dereferencing is to use -> instead of ., as I did above, but you can also use (unary) *. … Read more

[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