#include<bits/stdc++.h>
using namespace std;
int main(){
int a=10;
int *pp=&a;
cout<<*pp<<" "<<a<<endl;
cout<<&a<<" "<<&*pp<<endl;
*pp=18;
cout<<*pp<<" "<<a<<endl;
return 0;
}
运行结果 10 10
18 18
#include<bits/stdc++.h>
using namespace std;
int main(){
string s="123456";
char * pp=&s[0];
while(*pp!='\0'){
cout<<*pp<<" ";
pp++;
}
return 0;
}
运行结果 10 10
18 18
#include<bits/stdc++.h>
using namespace std;
struct node{
int x;
struct node * next=NULL;
};
int main(){
//freopen("abc.txt","r",stdin);
struct node *p1=new struct node;
p1->x=12;
struct node *p2=new struct node;
p2->x=13;
p2->next=p1;
struct node *p3=new struct node;
p3->x=14;
p3->next=p2;
cout<<p1<<" "<<p2<<" "<<p3<<endl;
struct node *p4=new struct node;
p4->x=15;
p4->next=p1;
p2->next=p4;
struct node *head=p3;
while(head!=NULL){
cout<<head->x<<" ";
head=head->next;
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
struct node{
int x;
struct node * next=NULL;
};
int main(){
//freopen("abc.txt","r",stdin);
struct node *p;
struct node n1;
n1.x=1;
struct node n2;
n2.x=2;
p=&n1;
p->next=&n2;
cout<<p->x<<" "<<p->next->x<<endl;
return 0;
}