Answer to Question #12514 in C++ for JX
How to correct the error? TQ
#include <iostream>
using namespace std;
void recursiveToLower(char str[])
{
if ( str[0] != '\0' ) {
str[0] = toupper( str[0] ); // do this char
recursiveToLower( str+1 ); // recursively do the remaining chars
}
}
int main()
{
char word[10] ;
cin >> word
cout << recursiveToLower(word);
system ("pause");
return 0;
}
1
2012-07-27T10:03:11-0400
Here is corrected code:
#include <iostream>
using namespace std;
&
char* recursiveToLower(char str[])
{
& if ( str[0] != '\0' ) {
str[0] = toupper( str[0] );& // do this char
recursiveToLower( str+1 ); // recursively do the remaining chars
& }
& return &str[0];
}
&
int main()
{
char word[10] ;
cin >> word;
cout << recursiveToLower(word) <<"\n";
&
system ("pause");
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
You're welcome. We are glad to be helpful. If you really liked our service please press like-button beside answer field. Thank you!
Thank you very much for the answer. :)
Leave a comment