标签:std main amp node 区别 nod size clu pre
#include<iostream>
using namespace std;
struct Node{
int id;
};
int main(){
Node *t;
for(int i = 0; i < 2; i ++){
Node *node = (Node*)malloc(sizeof(Node));
node->id = i;
if(i == 0){
t = node;
}
cout<<"i:"<<i<<endl;
printf("%p\n", node);
}
cout<<t->id<<endl;
return 0;
}
与下端代码有区别
#include<iostream>
using namespace std;
struct Node{
int id;
};
int main(){
Node *t;
for(int i = 0; i < 2; i ++){
Node node;
node.id = i;
if(i == 0){
t = &node;
}
cout<<"i:"<<i<<endl;
printf("%p\n", &node);
}
cout<<t->id<<endl;
return 0;
}
标签:std main amp node 区别 nod size clu pre
原文地址:https://www.cnblogs.com/faberry/p/12342705.html