Hi All,
I just wrote a program of string. In the below program every blank space will be replace by char 'x'. The program compiled successfully but it dint not run, give error. What I am doing wrong plz suggest me.
#include<iostream.h>
using namespace std;
int f1( char *st);
int main()
{
cout<<"in main\n";
f1("this is a string of base");
return 0;
}
int f1( char *st)
{
while(*st)
{
if (*st==' ')
*st='x'; // <---My doubt is here...
cout<<*st;
st++;
}
return 0;
}
Error: in main
Bus error (core dumped)
Thanks for your help.