I have a question about this code snippet - Scanf

Asked

Viewed 50 times

-1

Hello, would you like a help with this code snippet, could someone explain to me what it does exactly ? (Especially the part %*1[ n])

scanf(%[^\n]%*1[\n], string);
  • Mr Robot, that’s called Regular expressions, is a form of input "formatting and validation". I don’t know exactly what the formatting is in your code, but do a search to know better.

  • @welington2632 in this case nay are regular expressions, are formatting codes for scanf function

1 answer

2

%[^\n]: reads a string until you find a ' n' (end of line).

%*1[\n]: this * right after the % indicates that what is read will not be assigned to any variable (in this case to discard ENTER).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.