I have a file with the following contents
"AAA";"BBB"
I am trying to extract 2 columns as follows:
char v1[50]; char v2[50]; int ret = fscanf(fp, "\"%s\";\"%s\"", v1, v2);
But it returns 1 and everything in 'v1'!
This is normal?
This is because the format "%s"reads space-delimited lines. It will read the input until it reaches a space or the end of the input.
"%s"
Maybe you can use the format "%[", maybe something like
"%["
fscanf(fp, "\"%[^\"]\";\"%[^\"]\"", v1, v2);
See this link scanf(and family) for more information.
scanf
Source: https://habr.com/ru/post/1620121/More articles:Why is absolute CSS not working with a static parent? - htmlIndirectly changing class parameters - c #Python Tkinter. How to save a record through a button in a shortcut - pythonUndefined ัะธะผะฒะพะปั ะดะปั ะฐัั ะธัะตะบัััั armv7 ะฒ Xcode 7.1 - xcodePHP - matching with all existing phrases in the text - preg_replace - phpHow to send email directly to a user using C # in Windows 10 applications? - c #What is the actual bit rate over a network transmitting 100 kbps? - networkingSQLAlchemy - connection condition fails with AttributeError: neither the BinaryExpression object nor the 'Comparator' object have the 'selectable' attribute - pythongetting data by column name apache poi excel - javaHow can I build multiple shapes on the same line with matplotlib? - pythonAll Articles