0

Hello there!, Who can help me to know ? What do this %*c?I am working in C

This is line of my code scanf("%c%*c",&r);

18th Jul 2018, 2:06 PM
azael lope
azael lope - avatar
5 odpowiedzi
+ 3
Having a function: void func(char *out) { *out = 'a'; } calling it with: char f; func(&f); updates f = 'a' so yes you get a pointer to char.
20th Jul 2018, 12:29 AM
John Wells
John Wells - avatar
+ 3
Your scanf reads 2 characters. %c specifies read a character storing it in the r variable. The %*c specifies read a character and do not stored it.
19th Jul 2018, 11:50 PM
John Wells
John Wells - avatar
+ 3
Say your input is "a b": char f,s; scanf("%c%*c%c", &f, &s); sets f = 'a'; s = 'b'; and the ' ' is tossed. You need to pass the addresses of f and s so scanf can write to them so &f gets the address of f.
20th Jul 2018, 12:26 AM
John Wells
John Wells - avatar
+ 1
thank you so much!
20th Jul 2018, 3:30 AM
azael lope
azael lope - avatar
0
is second parameter is apointer to Char? sorry, but in the book that I read some Codes use %*c, so I am lost, for example prinntf("add ID studen"); scanf("%d%*c",&h.nal); printf("curse");. scanf("%d%*c",&a.curse);
20th Jul 2018, 12:06 AM
azael lope
azael lope - avatar