Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   help needed with code (http://www.go4expert.com/forums/help-code-t14708/)

micsom 23Oct2008 14:27

help needed with code
 
friends..i am breaking my head from the morning over a little piece of code..

the requirement is ..if the input is "MIKE"...it will store the string as MIKE.*
if the input is "MIKE.TXT"(or any extension)....it will retain the filename with that extension..

please help me here

imrose_suleman 23Oct2008 15:52

Re: help needed with code
 
dude....its very easy thing dude ....y r u breaking ur head...
here is the code...
try this..
code:

Code:

#include<iostream>
#include<string>
using namespace std;
main()
{
string s;
cout<<"enter string"<<endl;
cin>>s;
string s1=".*";
int count=0;
for(int i=0;i<s.length();i++)
{
if(s.at(i)==s1.at(0)) count++;
}
if(count==0) s.insert(s.length(),s1);
cout<<s<<endl;
}



All times are GMT +5.5. The time now is 16:08.