Total pointer

This is directed to an array of pointers string of summary made

There are three examples 

They represent different ways of writing

My compiler is Visual Studio 2019 Community

This is the first paragraph of the standard C language wording

    #include <iostream>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
using namespace std;


int main()
{
int i;
     char p[12][30] = { "January","February","March","April","May","June","July","August","September","October","November","December" };
    printf("please input your number of month:");
    cin >> i;
    char* a;
    a = p[12];
    printf("\n");
    printf("The month is:%s\n", *(p+i - 1))
return0;
}

The second paragraph C ++ wording

#include <iostream>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
int i;
    const char* p[12] = { "January","February","March","April","May","June","July","August","September","October","November","December" };
    printf("please input your number of month:");
    cin >> i;
    printf("\n");
    printf("The month is:%s\n", p[i-1]);
return0;
}

The third paragraph is C ++ wording

#include <iostream>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
int i;
    const char* p[12] = { "January","February","March","April","May","June","July","August","September","October","November","December" };
    printf("please input your number of month:");
    cin >> i;
    printf("\n");
    printf("The month is:%s\n", *p+i-1);
return0;
}

 

 

Guess you like

Origin www.cnblogs.com/Loving-Q/p/11962788.html