c_cpp 在虚空中持有指针的实验
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 在虚空中持有指针的实验相关的知识,希望对你有一定的参考价值。
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
// simulates void casters
#define Val_NEW malloc(sizeof(Val))
typedef struct
{
int i;
char c;
struct Val* next;
} Val;
typedef struct
{
void* obj;
} Hold;
int main(int argc, char const *argv[])
{
Hold test;
Val* val = Val_NEW;
val->i = 51;
test.obj = val;
Val* newval = test.obj;
printf("The int is %d\n", newval->i);
const char* foo = "Hello!";
const char* doo = "Hello!!";
printf("is good %d\n", strcmp(foo, doo));
return 0;
}
以上是关于c_cpp 在虚空中持有指针的实验的主要内容,如果未能解决你的问题,请参考以下文章