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