0

Return function from function

Hi! I am having some trouble understanding pointers. I think that *someptr = value pointer is pointing to / pointer declaration &somevar = address of value someptr = address pointer is pointing to. I'm trying to return a pointer to a function from inside of a function, but it doesn't work. I'll add the code bit here. Thanks in advance! https://code.sololearn.com/cDamsXApQ2Mu/?ref=app

15th Oct 2021, 5:23 AM
Joel Kronqvist
Joel Kronqvist - avatar
2 odpowiedzi
0
I thought it may have something to do with data types, but how could I fix them? If it indeed is impossible to declare a function inside another function and return it, then I guess I will have to come up with a different solution.
15th Oct 2021, 1:17 PM
Joel Kronqvist
Joel Kronqvist - avatar
0
The code has a problem in the line printf("%i", *func(i));. The function func returns an integer, but the code is trying to dereference it as a pointer. To fix this, remove the asterisk before func(i). The corrected line should be printf("%i", func(i));
28th Jan 2024, 5:48 PM
Otid Kartgepsut
Otid Kartgepsut - avatar