次のコードでは、sscanf が 0 を返すことを期待しますが、1 を返し、0.000000 を float 変数 x に代入します。文字列が文字 i で始まり、他の文字がない場合、同じ動作が発生します。
void main() {
int ss_return;
float x;
char str_to_sscanf[] = "noduh";
ss_return = sscanf( str_to_sscanf, "%f", &x );
printf( "\n\nThe word passed to sscanf is %s", str_to_sscanf );
printf( "\n\nWhen looking for a float, sscanf returned %d", ss_return );
printf( "\n\nand assigned %f to x (declared as float)", x );
printf( "\n\nWHY DID sscanf NOT RETURN ZERO????" );
}
プログラムの出力は次のとおりです。
私は何が欠けていますか?