Re: subsets of array
TJW wrote in message ...
"BobR" <RemoveBadBobR@worldnet.att.net> writes:
#include <iostream> // C++
#include <ostream> // std::endl
void Weiner(int array = 43){
std::cout<<"33 33 33 75 78 79 76 80 32 33 101 114 "
"101 104 32 112 108 101 104 32 111 110 "
"32 115 116 101 103 32 101 100 117 116 "
"105 116 116 97 32 110 97 32 104 116 105 "
"119 32 116 111 105 100 105 32 110 65 "<<std::endl;
Weiner(array+1);
return;
}
int main(){
Weiner(42);
return 0;
}
Please forgive a C programming who has been lurking for a while
to refresh his OO memory ... but what specifically will this print
and why? I see the recursive call, but am not used to initializing
variables in a function declaration ... will array be 43 always or
42, 43, 44, ... and with cout << will the integers be translated
into ASCII characters?
Sorry to ruin a good joke that I don't get ...
Thanks,
TJW
I agree with the explanation that MeDevil gave you, so, I won't repeat it
here.
[ If you still 'don't get it', ask more. ]
To help you 'decode' the message, here is the code I used to get the numbers:
std::string Rev("< the secret string was here >");
std::reverse(Rev.begin(), Rev.end());
for(size_t i(0); i < Rev.size(); ++i){
std::cout<<int( Rev.at(i) )<<" ";
}
std::cout<<std::endl;
You could get back the 'ASCII' with something like:
std::cout<<char(65)<<char(110)<<std::endl; // etc.
The default parameter in the arg list (int array = 43) is just for
distraction, it don't do nuthin' <G>
Coming to C++ from C? Do you know about Mr. Eckel's book? (It was pretty much
designed to take you from C to C++)
Get "Thinking in C++", 2nd ed. Volume 1(&2) by Bruce Eckel
(available for free here. You can buy it in hardcopy too.):
http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
--
Bob R
POVrookie