在非常基本的C程序上使用GDB进行温度转换时,出现指出“ printf.c:没有这样的文件或目录的错误

问题描述 投票:1回答:1
  • 这是GDB向我显示的内容
(gdb) break main
Breakpoint 1 at 0x722: file homework1.c, line 4.
(gdb) run
Starting program: /home/aj_the_kid/ECE_373/homework1 
Breakpoint 1, main () at homework1.c:4
4   {
(gdb) step
8     printf("Enter the temperature (for conversion) in Fahrenheit:  ");
(gdb) step
__printf (
    format=0x555555554838 "Enter the temperature (for conversion) in Fahrenheit:  ") at printf.c:28
28  printf.c: No such file or directory.
(gdb) bt
 #0  __printf (
    format=0x555555554838 "Enter the temperature (for conversion) in Fahrenheit:  ") at printf.c:28
 #1  0x0000555555554742 in main () at homework1.c:8
(gdb) next
32  in printf.c
(gdb) next
33  in printf.c
(gdb) step
_IO_vfprintf_internal (s=0x7ffff7dd0760 <_IO_2_1_stdout_>, 
    format=0x555555554838 "Enter the temperature (for conversion) in Fahrenheit:  ", ap=ap@entry=0x7fffffffde20) at vfprintf.c:1244
1244    vfprintf.c: No such file or directory.
(gdb) step
1275    in vfprintf.c
  • 这是我的Linux测试程序
#include <stdio.h>

int main()
{
  float temp_F, temp_C;

  // Prompt user for input (i.e. temp in Fahrenheit)
  printf("Enter the temperature (for conversion) in Fahrenheit:  ");
  scanf("%f\n", &temp_F);

  // Convert F to C
  temp_C = (temp_F - 32) * (5/9);
  printf("The temperature in Celsius is: %.2f\n", temp_C);

  return 0;

}
  • 编辑:支持浮点型算术的固定代码

但是我仍然遇到一个问题,它要求我再次以空行输入华氏度,就像它没有第一次捕获用户输入的内容一样。>

终端视图

aj_the_kid@AJs-Sandbox:~/ECE_373$ rm file1
aj_the_kid@AJs-Sandbox:~/ECE_373$ gcc -g -o file1 file1.c
aj_the_kid@AJs-Sandbox:~/ECE_373$ ./file1
Enter the temperature (for conversion) in Fahrenheit:  32

32
The temperature in celcius is: 0.00
aj_the_kid@AJs-Sandbox:~/ECE_373$

这是GDB向我显示的(gdb)在0x722处中断主断点1:文件homework1.c,第4行。(gdb)运行启动程序:/ home / aj_the_kid / ECE_373 / homework1断点1,主处(homework1) .c:4 ...

c linux debugging gdb lib
1个回答
1
投票

来自评论:

© www.soinside.com 2019 - 2024. All rights reserved.