Apr 13, 2014 at 12:29am UTC
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 Apr 13, 2014 at 12:36am UTC
Apr 13, 2014 at 1:17am UTC
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 Apr 13, 2014 at 1:18am UTC
Apr 13, 2014 at 2:51am UTC
ya i figured it out the mystring[0]='n'; didnt need to be there. thanks.