please help.

hello, i am have trouble with a program i wrote and can not get it to compile.

#include<iostream>

using namespace std;
void reverse_string(char);
int main()

{
char mystring[]="abcdefghijklmnop";
mystring[0]='n';
cout << "\nthe forward string is:"<< mystring;
cout <<"\n\n\n";

reverse_string(mystring[17]);
cout << "the string in reverse is:"<< "\n\n";
cout << mystring<<"\n\n";

cout <<"\n\n\n";
system("pause");
return 0;
}

// reverse string function
void reverse_string(char ch_ptr)
{
char front;
char end;
char temp;

front=end=ch_ptr;

while(end != '\0')
++end;

--end;

while(front<end)
{
temp=front;
front=end;
end=temp;
++front;
--end;
}
return ;
}

the problem is that the output shows nbcdefghijklmnop rather then abcdefghijklmnop i dont know why its replacing the a with n and it does the same in reverse.
Last edited on
1
2
char mystring[]="abcdefghijklmnop";
mystring[0]='n';


What do you think this does?

Also
i am have trouble with a program i wrote and can not get it to compile.


the problem is that the output shows nbcdefghijklmnop rather then abcdefghijklmnop


Which is it?
Last edited on
ya i figured it out the mystring[0]='n'; didnt need to be there. thanks.
Topic archived. No new replies allowed.