C language: pointer to realize output ladder string

Implemented with pointers, the implementation does not need to copy the substring into a new string. (10 points)

Topic content:

Implemented with pointers, the implementation does not need to copy the substring into a new string.

 

Input format:

string

 

Output format:

substring

 

Input sample:

computer

 

Sample output:

computer

omputer

mputer

puter

uterus

to have

is

r

 

 

code

#include "stdio.h"
intmain()
{
	char s[30];
	char * p =s;
    scanf("%s",p);
    int i;
	for (i=0;i<sizeof(p);i++)
	{
		printf("%s\n",p+i );
	}
	return 0;	
}

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325851521&siteId=291194637