【发布时间】:2019-10-25 06:58:36
【问题描述】:
我有一个任务要做,使用 char* 和 double 变量调用 scanf 和 printf 函数。 Char* 正在工作,但我有双重问题。
Function:用于 scanf/printf char*,function1:用于 scanf/printf double。比如我编译后的结果:
(scanf)b
(printf)char: b
(scanf)1.3
(printf)双精度: 99997200381866062965879955188785948733402760577162787362451212786.000000
看来问题出在双变量的 printf 上,但我不知道如何解决它。
.data
STDIN = 0
STDOUT = 1
SYSREAD = 3
SYSWRITE = 4
SYSEXIT = 1
EXIT_SUCCESS = 0
format_inchar: .string "%c"
format_indouble: .string "%lf"
char: .ascii " "
double: .double 0.0
format_string1: .string "char: %c\n"
format_double1: .string "double: %f\n"
.text
.global main
main:
function:
push $char
push $format_inchar
call scanf
push char
push $format_string1
call printf
function1:
push $double
push $format_indouble
call scanf
push double
push $format_double1
call printf
exit:
movl $SYSEXIT, %eax
movl $EXIT_SUCCESS, %ebx
int $0x80
【问题讨论】: