This Python code was fed to python2c.py:
# this is a test
x = -1
while x: # loop until 0 spam
x = input('\nHow much spam?')
if x:
print "We have:"
for i in range(0,x):
print 'spam',
if i == x-2: # (don't forget the beans!)
print "baked beans and",
else:
print "Enjoy!"
# all done!
...which spewed out the following C++ code in response:
// this is a test
x = -1;
while (x) // loop until 0 spam
{
cout << "\nHow much spam?"; cin >> x ;
if (x)
{
cout << "We have:" << endl;
for (i=0; i<x; i++) {
{
cout << "spam" << " ";
if (i == x-2) // (don't forget the beans!)
{
cout << "baked beans and" << " ";
}
}
}
else
{
cout << "Enjoy!" << endl;
}
}
// all done!