#include <cstdio> int main() { unsigned char test; scanf("%hhu",&test); printf("%hhu",test); long double a; scanf("%Lf",&a); printf("%lf",a); }
test.cpp:5:23: warning: unknown conversion type character 'h' in format [-Wformat] test.cpp:5:23: warning: too many arguments for format [-Wformat-extra-args] test.cpp:6:23: warning: unknown conversion type character 'h' in format [-Wformat] test.cpp:6:23: warning: too many arguments for format [-Wformat-extra-args] test.cpp:8:19: warning: unknown conversion type character 'L' in format [-Wformat] test.cpp:8:19: warning: too many arguments for format [-Wformat-extra-args] test.cpp:9:19: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'long double' [-Wformat]
g++ (GCC) 4.6.1 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
c++ c scanf [解决办法] 没见过%h, %L unsigned字符,我们一般输入%u,%x用,但是是不安全的最好是输入到int在赋值给unsiged char [解决办法] unsigned char的格式输入输出单个符是%c long double a-》lf [解决办法] 1、unsigned char用%c 2、long double用%Lf或者是%llf