I am trying to use sscanf (on a string that I know is well formed and not malicious) to write a value to a specific part of an array.
#include <stdio.h>
int main(void){
int arr[10], i;
sscanf("5 5", "%d %d", &i, arr + i);
}
When I run this in valgrind, I am told that the sscanf line reads an uninitialized value. However, arr is initialized as a pointer to an automatically allocated array and i is initialized because there is a sequence point associated with every format specifier (this is not the case for general functions which do not have sequence points between arguments). I might be inclined to believe that this is only happening because valgrind does not know about that format specifier sequence point rule, but in my full program the line causes an actual segmentation fault. Why is this happening? Am I mistaken about format specifiers creating sequence points?