+ 2

Why can't I use char type with scanf() and do the void pointer in C language?

I was learning Void pointers and tried to make the code with scanf(), but the code wouldn't print the char. Please help https://code.sololearn.com/c3927x2fvs8G/?ref=app

15th Jan 2020, 9:33 AM
Manthan Gohel
Manthan Gohel - avatar
12 ответов
+ 4
Manthan Gohel Try adding a space in between each format specifier in the `scanf` call. e.g. scanf("%d %f %c", &x, &y, &c);
15th Jan 2020, 11:22 AM
Ipang
+ 4
Share your code within your question Description please, people need to see your code to really understand the situation. So share that code, in case you don't know how, see the following guide on how to share links 👍 https://www.sololearn.com/post/74857/?ref=app
15th Jan 2020, 9:41 AM
Ipang
+ 4
~ swim ~ Thanks
15th Jan 2020, 11:49 AM
Manthan Gohel
Manthan Gohel - avatar
+ 4
Got it ~ swim ~ Big Thanks 🙏😂
15th Jan 2020, 12:15 PM
Ipang
+ 3
15th Jan 2020, 10:55 AM
Manthan Gohel
Manthan Gohel - avatar
+ 2
Ipang Now take a look.
15th Jan 2020, 10:58 AM
Manthan Gohel
Manthan Gohel - avatar
+ 2
Ipang Now it's working, Thank you. But I tried with 2 scanf() one for int and float and second for char, but it didn't worked then.
15th Jan 2020, 11:32 AM
Manthan Gohel
Manthan Gohel - avatar
0
~ swim ~ I was wondering, is casting necessary when assigning an address of variable into a void pointer? In the code ... void *ptr; ... ptr = &x; My doubt is ... is it necessary to cast the address as void pointer? ptr = (void*)&x;
15th Jan 2020, 11:50 AM
Ipang
0
Hi
16th Jan 2020, 11:14 PM
Joe Rhynearson
Joe Rhynearson - avatar
17th Jan 2020, 7:28 AM
Manthan Gohel
Manthan Gohel - avatar