小编Som*_*oii的帖子

C中变量的地址是计算机RAM中的实际地址吗?

在C中,当你得到一个变量的地址时,该地址确实存在于计算机的RAM中,或者只是C编译器中假存储器中的地址(如果这是真的有效)?你能用外行的话解释一下吗?

c memory memory-address

5
推荐指数
1
解决办法
95
查看次数

malloc错误:struct中读取文件的释放对象的校验和不正确

所以我有这个功能:

source_t * source_init(char * argsource)
{
    source_t * temp = (source_t *) malloc(sizeof(source_t *));
    temp->path = realpath(argsource, NULL);
    temp->dir = dirname(temp->path);
    temp->name = basename(temp->path);
    temp->ext = strrchr(temp->name, '.');
    temp->content = read_file(temp->path); // here
    temp->error = error_free();
    return temp;
}
Run Code Online (Sandbox Code Playgroud)

它的调用功能read_file():

char * read_file(char * sourcepath)
{
    char * buffer = NULL;
    long string_size, read_size;
    FILE * file = fopen(sourcepath, "r");
    fseek(file, 0, SEEK_END);
    string_size = ftell(file);
    rewind(file);
    buffer = (char *) malloc(sizeof(char) * (string_size + 1) ); …
Run Code Online (Sandbox Code Playgroud)

c malloc

0
推荐指数
1
解决办法
1708
查看次数

标签 统计

c ×2

malloc ×1

memory ×1

memory-address ×1