What is the practical use of the formats "%*"
in scanf(). If this format exists, there has to be some purpose behind it. The following program gives weird output.
#include<stdio.h>
int main()
{
int i;
char str[1024];
printf("Enter text: ");
scanf("%*s", &str);
printf("%s
", str);
printf("Enter interger: ");
scanf("%*d", &i);
printf("%d
", i);
return 0;
}
Output:
manav@workstation:~$ gcc -Wall -pedantic d.c
d.c: In function ‘main’:
d.c:8: warning: too many arguments for format
d.c:12: warning: too many arguments for format
manav@manav-workstation:~$ ./a.out
Enter text: manav
D
Enter interger: 12345
372
manav@workstation:~$
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…