954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Newbie question... For vector of strings, how to search strings and replace symbol?

I have a vector of strings. Each vector element/string is a name, like: Mother_Hen.

I want to remove the _ and replace it with a space. Does anyone know how to do this? I have tried using find, but have had no success (I get no result). Thank you for any help.

Annettest
Light Poster
47 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

Iterate through the vector and use string find/replace

template<>
Junior Poster
165 posts since Feb 2011
Reputation Points: 84
Solved Threads: 26
 
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{char a[100],b;
 int c,d=0,e;
 gets(a);
 cout<<"enter the string to be found out";
 cin>>b;
 for(c=0;c<=strlen(a)-1;c++)
 {if(a[c]==b)
  d++;
 }
 if(d==0)
 cout<<"char not found";
 else
 cout<<"char found";
 getch();
}

i hope this works....have a nice time....

srivairam
Newbie Poster
3 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: