Reputation: 1746
I'm trying to parse a string into a char and multiple floats in the following format:
v 1.00000 1.00000 1.00000
Originally using sscanf
I could do so with:
char b;
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
int result = sscanf(lineHeader,"%c %f %f %f", &b, &x, &y, &z);
However, I'm trying to eliminate an unrelated problem which requires me to use sscanf_s
.
If I simply change the code to:
int result = sscanf_s(lineHeader,"%c %f %f %f", &b, &x, &y, &z);
I get an exception stating an unsigned integer is expected. Does sscanf_s
use different formatting to parse strings?
Upvotes: 0
Views: 2268
Reputation: 63124
According to the documentation, sscanf_s
's %c
conversion specifier requires an additional parameter to check for the buffer size:
int result = sscanf_s(lineHeader,"%c %f %f %f", &b, rsize_t{1}, &vertex.x, &vertex.y, &vertex.z);
// It's a single char ^^^^^^^^^^
Upvotes: 1