Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<iostream.h>
- #include<string.h>
- char a[100] , b[10],c[10];
- void main()
- {
- clrscr();
- cout<<"please enter a string : ";
- gets(a);
- cout<<"please enter a word to delete : ";
- gets(b);
- for(int i = 0 ; i<strlen(a);i++)
- {
- for(int j = 0 ; a[i]!=' ' && a[i]!='\0' ; i++,j++)
- c[j] = a[i];
- c[j] ='\0';
- if(strcmp(c,b)==0)
- for(int h = 0 ;h<=strlen(b) ;h++)
- a[i-h] = '\n';
- }
- cout<<endl<<"the new sentence is : ";
- for(int u = 0;u<strlen(a);u++)
- if(a[u] != '\n')
- cout<<a[u];
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment