指针部分

# include "stdio.h"
# include "string.h"
# include "iostream.h"
void main()
{
    //指针定义与赋值
    int a=2;

    int * p=NULL;
    p=&a;
    cout<cout<<&a<cout<<*p<cout<int str[3]={2};
    int * p1=NULL;
    p1=str;
    cout<<*p1<//常见错误(把指针当做字符串)
    char * p=NULL;
    char s[10]={0};//先要给指针赋值
    p=s;
    strcpy(p,"hello");
    cout<//强制转换
    int arr[5]={1,2,3,4,5};
    char * p=NULL;
    p=(char *)arr;
    printf("%d",*(p+4*3));
    for(int i=0;i<17;i++)
    {
        printf("%d\n",*(p+i));
    }



}

你可能感兴趣的:(C++)