Hello Everyone im having a little problem . . .

im having a little trouble with this
reverse program can anyone tell me where i went wrong? -_-"
im a new IT student it would help me a lot if anyone can tell my error . .


#include<iostream.h>
#include<string.h>

void
rev_str(char *s)
{
if(*s!='\0')
rev_str(str);
cout<<*s;
}

main()
{
char str[50];


cout<<"Type strings without space and not more than 50 : ";
cin>>str;
rev_str(str);

return 0;
}
Holy shit who's teaching you C++? The man should be fired.

1
2
#include<iostream.h>
#include<string.h> 


should be

1
2
#include<iostream>
#include<string> 


 
main()


should be

 
int main()


Also you either need using namespace std; after your includes or put a std:: before all identifiers from the standard library.

As to your specific problem - this should probably be
 
rev_str(str+1);


But C strings are the devil anyways. We have std::strings for that. Also, put {} braces around your two statements, else you will cout the \0 character as well - that probably won't break anything, but that's not a printable character anyways.
Last edited on

rev_str(str+1);


Undefined symbol in 'str' function rev_str(char *)

whats up with that line how can i define it . .
Change that to s.
THANK YOU VERY MUCH SIR :DD!
Topic archived. No new replies allowed.