I have fscanf to read lines of setting from a configuration file. Those settings have strictly predefined format which looks like
name1=option1;
name2=option
Just add space at the end of the format string:
"%[^=]=%[^;]; "
This will eat all whitespace characters, including new-lines.
Quotation from cplusplus.com:
Whitespace character: the function will read and ignore any whitespace characters encountered before the next non-whitespace character (whitespace characters include spaces, newline and tab characters -- see isspace). A single whitespace in the format string validates any quantity of whitespace characters extracted from the stream (including none).