N
Niklas Borson
Hi gurus! I'm a C++ newbie and I've heard that a good
first program is one that prints "Hello World!"
I tried typing in a program I found in a book, but
for some reason it wouldn't compile. So I just changed
things at random until it compiled and almost worked.
That is, it prints out two words, but they're not
"Hello World!" I don't know how to fix this, and am
afraid to change anthing else lest my compiler just
start yelling at me again!
Here's my program. Can anyone please help?
#include <cstdio>
template<int N,int D>
void p(char c)
{
p<0,97>(N%26+D);
p<N/26,97>(c);
}
template<>
void p<0,97>(char c)
{
std::fputc(c, stdout);
}
int main()
{
p<5179226,65>(32);
p<8428737,65>(33);
return 0;
}
first program is one that prints "Hello World!"
I tried typing in a program I found in a book, but
for some reason it wouldn't compile. So I just changed
things at random until it compiled and almost worked.
That is, it prints out two words, but they're not
"Hello World!" I don't know how to fix this, and am
afraid to change anthing else lest my compiler just
start yelling at me again!
Here's my program. Can anyone please help?
#include <cstdio>
template<int N,int D>
void p(char c)
{
p<0,97>(N%26+D);
p<N/26,97>(c);
}
template<>
void p<0,97>(char c)
{
std::fputc(c, stdout);
}
int main()
{
p<5179226,65>(32);
p<8428737,65>(33);
return 0;
}