+ 1
Cosine(x)
https://code.sololearn.com/cvtNfKDrk4zg/?ref=app here there is a code for cosine, but there is a mistake in calling the class... Can u help please?..
2 Réponses
+ 3
malloc() returns a pointer, so you would have to adjust the type of "objs" to myCosine* (the same applies to the explicit cast to the returned value).
It should also be noted that you access the array far out of its bounds, which is undefined behaviour.
However, since the size of "objs" is known at compile time, you can allocate the array on the stack instead and avoid malloc().
Here is how you could rewrite it:
https://code.sololearn.com/c4PRr0YRx97q/?ref=app
+ 1
Thanks Shadow for your great help. You saved my time in figuring it out😊😊✨