Categories
c programming tips and tricks

Some Cool SCANF Tricks

Find out some of the unheard scanf tricks that you must know.

scanf(“%[^,]”, a); // This doesn’t scrap the comma
scanf(“%[^,],”,a); // This one scraps the comma
scanf(“%[^\n]\n”, a); // It will read until you meet ‘\n’, then trashes the ‘\n’
scanf(“%*s %s”, last_name); // last_name is a variable

Leave a Reply

Your email address will not be published. Required fields are marked *