5/2/2023 0 Comments Lua string fscanf![]() ![]() With the above, the first string can't be longer than one single character, and the second can't be longer than eight characters. they're arrays) then use the format maximum field width to limit the number of characters that fscanf will read and put into your array.įor example (without knowing anything at all about your actual strings/arrays): while (fscanf(file, "%1s %8, %d", operation, address, &size) = 3). That can lead to overflow of your strings. ![]() Note that the above format will not impose any limits on the strings it will read. this scanf (and family) reference for more details.Īlso, you shouldn't be comparing the result of fscanf with -1, instead check that it parsed the correct number of sequences by comparing the return with 3: while (fscanf(file, "%s %, %d", operation, address, &size) = 3). You can solve this with the "%, %d", operation, address, &size) The problem here is that the "%s" format reads space delimited strings, and since there's no space in 03f8ab8,1 it will all be read as a single string.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |