这个哪里有问题吗
编写函数,其功能是从字符串中查找指定的字符并且将其删除,若未找到则不删除。在主函数中输入字符串及指定字符,调用函数完成相应功能后在主函数中输出结果。
【输入输出示例】
I am a student.I am learning program c. ↙
I↙
str= am a student. am learning program c.
#include <stdio.h>
#include <string.h>
int main(int argc, char const *argv[])
{
static char sentence;
gets(sentence);
char word;
scanf("%c",&word);
void select(char a[],char b);
select(sentence,word);
puts(sentence);
return 0;
}
void select(char a[],char c)
{
for (int i = 0; i<strlen(a);)
{
if (a==c)
{
for (int j = 0; j < strlen(a); ++j)
{
a=a;
}
}
++i;
}
} 本帖最后由 jhq999 于 2022-5-30 16:13 编辑
void select(char a[],char c)
{
int i = 0,j=0;
for (i=0;a;i++)
if(c==a)
for(j=i; a;j++)a=a;
}
void select(char a[],char c)
{
int i = 0,j=0;
for (i=0,j=0;a;i++,j++)
{
if(c==a)j++;
a=a;
}
a='\0';
} select函数里面的第二个循环是不是应该从j = i开始,而不是0
页:
[1]