相关疑难解决方法(0)

Valgrind报告了一个非常简单的C程序的错误

我正在从Learn C The Hard Way学习C语言.我正在练习6,虽然我可以使它工作,但valgrind会报告很多错误.

这是从文件中删除的最小程序ex6.c:

#include <stdio.h>

int main(int argc, char *argv[])
{
    char initial = 'A';
    float power = 2.345f;

    printf("Character is %c.\n", initial);
    printf("You have %f levels of power.\n", power);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

内容Makefile只是CFLAGS=-Wall -g.

我编译程序$ make ex6(没有编译器警告或错误).执行with $ ./ex6产生预期的输出.

当我运行程序时,$ valgrind ./ex6我得到了我无法解决的错误.这是完整的输出:

==69691== Memcheck, a memory error detector
==69691== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==69691== …
Run Code Online (Sandbox Code Playgroud)

c valgrind

11
推荐指数
2
解决办法
5821
查看次数

标签 统计

c ×1

valgrind ×1