Functions Using void Pointers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Functions Using void Pointers

C Output 6 squared is 36 ./Playground/file0.c: In function 'main': ./Playground/file0.c:8:10: warning: assignment to 'int' from 'void *' makes integer from pointer without a cast [-Wint-conversion] 8 | sq_int = square(&x); | ^ ./Playground/file0.c: In function 'square': ./Playground/file0.c:18:9: warning: returning 'int' from a function with return type 'void *' makes pointer from integer without a cast [-Wint-conversion] 18 | return(result); | ^ this is showing error while compile. is it intended?

28th Jun 2020, 8:49 AM
Tara Kumar Sunuwar
Tara Kumar Sunuwar - avatar
4 Answers
+ 2
Could you please share your code?
28th Jun 2020, 8:54 AM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
+ 1
Please share your code.
28th Jun 2020, 12:31 PM
Ćheyat
Ćheyat - avatar
+ 1
I believe this is the sample code given in the C course under "Strings & Function Pointers" -> "void Pointer" -> Page 2/3. The sample code shown there is deeply flawed and would produce these warnings.
28th Jun 2020, 2:37 PM
Gen2oo
Gen2oo - avatar
0
This is the given sample code.
29th Jun 2020, 9:55 AM
Tara Kumar Sunuwar
Tara Kumar Sunuwar - avatar