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
|
Go4Expert Member
|
|
| 23Oct2008,15:52 | #2 |
|
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;
}
Last edited by shabbir; 23Oct2008 at 18:30.. Reason: Code block |
