S
Stefan Ram
I was asked to explain pointers. I thought the following would
be a nice example for pointer arithmetics. But I have a question
below.
#include <iostream> /* ::std::cout */
#include <ostream> /* << */
#include <iomanip> /* ::std::setw */
#include <cstdio> /* ::std:
rintf */
const char * mon( int const m, int const lang )
{ return "Jan" "Feb" "Mar" "Apr" "Mai" "Jun" "Jul" "Aug" "Sep" "Okt" "Nov" "Dez"
"jan" "feb" "mar" "apr" "may" "jun" "jul" "aug" "sep" "oct" "nov" "dec"
+ 3 *( m - 1 )+ 3 * 12 * lang; }
int main()
{ ::std:
rintf( "%.3s\n", mon( 5, 0 ));
::std:
rintf( "%.3s\n", mon( 5, 1 )); }
This will print:
Mai
may
I know that I do not have to #include <ostream>.
But how do I »translate« the Cish printf into the C++ish <<?
(The problem is the translation of the maximum field width.)
be a nice example for pointer arithmetics. But I have a question
below.
#include <iostream> /* ::std::cout */
#include <ostream> /* << */
#include <iomanip> /* ::std::setw */
#include <cstdio> /* ::std:
const char * mon( int const m, int const lang )
{ return "Jan" "Feb" "Mar" "Apr" "Mai" "Jun" "Jul" "Aug" "Sep" "Okt" "Nov" "Dez"
"jan" "feb" "mar" "apr" "may" "jun" "jul" "aug" "sep" "oct" "nov" "dec"
+ 3 *( m - 1 )+ 3 * 12 * lang; }
int main()
{ ::std:
::std:
This will print:
Mai
may
I know that I do not have to #include <ostream>.
But how do I »translate« the Cish printf into the C++ish <<?
(The problem is the translation of the maximum field width.)