write a program to remove occurrences the word from entered
text?
Answer Posted / jitendra
#include"stdio.h"
#define n 100
void del_char(char str1[n],char str2[])
{
char str[n],*p1,*q,i,j;
p1=str1;
q=str;
*q=*p1;
i=0;
while(*p1!='\0')
{
{
if(*p1==str2[i])
{
p1++;
i++;
if(*p1==str2[i])
{
p1++;
i++;
if(*p1==str2[i])
{
p1++;
i++;
}
else
{
q++;
}
}
else
{
q++;
}
}
else
{
p1++;
q++;
}
*q=*p1;
}
i=0;
}
printf("%s\n",str);
}
main()
{
char str1[n],str2[]={"to "};
printf("please enter a text and includ 'to':\n");
gets(str1);
printf("remove 'to',remaining :\n");
del_char(str1,str2);
getch();}
| Is This Answer Correct ? | 5 Yes | 7 No |
Post New Answer View All Answers
What are the types of pointers?
What is the difference between procedural and functional programming?
What are the advantages of using Unions?
What is the difference between strcpy() and memcpy() function in c programming?
Differentiate fundamental data types and derived data types in C.
What is variable and explain rules to declare variable in c?
How do I round numbers?
Does sprintf put null character?
What is wrong with this initialization?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
Is it better to use malloc() or calloc()?
How do I copy files?
What are the string functions? List some string functions available in c.
Why pointers are used in c?
Explain what standard functions are available to manipulate strings?