Delete a Word from a String
Write a C++ Program to Delete a Word from a String. Here’s simple C++ Program to Delete a Word from a String in C++ Programming Language.
C++ Strings :
String is a sequence of characters. char
data type is used to represent one single character in C++. So if you want to use a string in your program then you can use an array of characters.
The declaration and definition of the string using an array of chars is similar to declaration and definition of an array of any other data type.
Any string ends with a terminating null character ‘\0’. An array definition in such a way should include null character ‘\0’ as the last element.
C++ provides following two types of string representations:
- The C-style character string.
- The string class type introduced with Standard C++.
The C-style character string originated within the C language and continues to be supported within C++. This string is actually a one-dimensional array of characters which is terminated by a null character ‘\0’. Thus a null-terminated string contains the characters that comprise the string followed by a null.
Here is source code of the C++ Program to Delete a Word from a String. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.
SOURCE CODE : :
/* C++ Program to Delete a Word from a String */ #include<iostream> #include<string.h> using namespace std; int main() { int i, j = 0, k = 0, count = 0; char str[100], str1[10][20], word[20]; cout<<"\nEnter any String :: "; gets(str); for (i=0; str[i]!='\0'; i++) { if (str[i]==' ') { str1[k][j] = '\0'; k++; j=0; } else { str1[k][j]=str[i]; j++; } } str1[k][j] = '\0'; cout<<"\nEnter a word to delete :: "; cin>>word; for (i=0; i<k+1; i++) { if (strcmp(str1[i], word) == 0) { for (j=i; j<k+1; j++) { strcpy(str1[j], str1[j + 1]); k--; } } } cout<<"\nThe new String after deleting the word [ "<<word<<" ] :: \n\n"; for (i=0; i<k+1; i++) { cout<<str1[i]<<" "; } cout<<"\n"; return 0; }
OUTPUT : :
/* C++ Program to Delete a Word from a String */ Enter any String :: This is a test String Enter a word to delete :: test The new String after deleting the word [ test ] :: This is a String Process returned 0
Above is the source code for C++ Program to Delete a Word from a String which is successfully compiled and run on Windows System.The Output of the program is shown above .
If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.
Thanks for reading the post….
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhsAAADbCAYAAADEUF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qwccNjTYVoN902TutfimqQf0gB445wGHDYcNhw09oAf0gB7QAzs98H8AmqHTHBPKelYAAAAASUVORK5CYII=
I have a little problem with the codes, why did my ‘e’ also disappear when I only ask to delete the ‘b’
I have a little problem with the codes, why did my ‘e’ also disappear when I only ask to delete the ‘b’
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int len;
string str,str1;
getline(cin,str);
cout<<“Entered String is : “<<str<<endl;
cout<<“enter the word to be deleted :”;
getline(cin,str1);
len=str1.length();
int found = str.find(str1);
cout<<found;
for(int i=found;i<=found+len;++i)
{
str[i]=’\0′;
}
cout<<str;
return 0;
}