*s1=i在C语言中是什么意思?

Python08

*s1=i在C语言中是什么意思?,第1张

假设变量i的类型是int类型,s1的类型是int *类型,则此赋值语句的意思是:

前提:指针变量s1中已经存放了一个地址,这个地址单元可以存放int型数据,

赋值:取出变量i中存储的数值,存放到s1指向的单元中去。

while(!s1)的意思是当!s1为真时循环,否则跳出循环。

while循环语句,是计算机的一种基本循环模式。当满足条件时进入循环,不满足跳出循环。while语句的一般表达式为:

while(表达式)

{

    循环体

}

!在计算机中表示非操作,!真=假,!假=真。一般情况下,计算机中0表示假,非0表示真。

输入样例:

Thisisatest is

输出样例:

Thatest

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

int main()

{

//char s[]="hello world"

//printf("%s\n",s)

char s1[80]={0,}

char s2[80]={0,}

int i,num

scanf("%s",s1)

scanf("%s",s2)

//char *p=strstr(s1,s2)

while (strstr(s1,s2)){

i=0

num=strlen(s1)

char *p=strstr(s1,s2) //返回在s1中找到的第一个s2字符串地址

int cnt=strlen(p) //cnt等于所找到的当前s2字符串地址之后所有的字符串个数

while (i!=strlen(s2)){

*p++='\0' //对p中的s2字符串置'\0',并将p移至下一个地址

i++

}

strcpy(s1+(num-cnt),p) //往前移位,即num-cnt为当前s1字符串的字符个数

}

num=strlen(s1)

// printf("%s\n",p)

for (i=0i<=numi++){

printf("%c",s1[i])

}

return 0

}