parsing the format string at compile time...
John Kallen
jkl at csli.Stanford.EDU
Sun Oct 15 13:01:06 AEST 1989
In article <23054 at cup.portal.com> Tim_CDC_Roberts at cup.portal.com writes:
!Regarding Modula-2 requiring the programmer to parse format strings:
!
!C++ is very much like this, if you think about it.
!
! printf ("%d %s %d\n", 123, "What?", 456");
!
!becomes:
!
! cout << 123 << ' ' << "What?" << ' ' << 456;
!
!There are separate, overloaded definitions of the '<<' operator, each of
!which knows how to format a particular type.
I don't want to be picky, but at least as far as Cfront 2.0, G++ 1.36.0 and
Zortech C++ go, your C++ line would output:
12332What?32456
You probably want:
cout << 123 << " " << "What?" << " " << 456;
John.
_______________________________________________________________________________
| | | | |\ | | /|\ | John K{llen "If she weighs the same as a
| |\ \|/ \| * |/ | |/| | | PoBox 11215 a duck...she's made of wood"
| |\ /|\ |\ * |\ | | | | Stanford CA 94309 "And therefore?" "A WITCH!"
_|_|___|___|____|_\|___|__|__|_jkl at csli.stanford.edu___________________________
More information about the Comp.lang.c
mailing list