Agh... My C++ class has asked me to provide an example of a "cool" script (we are 2 days in), so i had the idea for a simple dotted line generator. The script works fine in PHP
PHP Code:
<?php # Config $max = 250; ?> <html> <!-- # Dotted Slope Generator # Made By Adam Shannon # http://ashannon.us # adam@ashannon.us COPYRIGHT 2009 ALL RIGHTS RESERVED!!! --> <head> <title>Dotted Slope Generator</title> <style type="text/css"> h3 {text-align:center;} </style> </head> <body> <h3>Dotted Slope Generator</h3> <?php # Load sacred Vars $row = 1; $col = 1; # Start while ($row<$max+2) { # If the loop is just starting, don't print anything. if ($row != 1) {print $row-1 . ") ";} # Start the major loop while ($col<$row) { # Print each dot print "."; $col++; } # Reset for next line $col = 1; $row++; print "<br />\n"; } # End ?> </body> </html>
But when i try to convert it to C++ it makes an infinite loop.
PHP Code:
/* # Dotted Slope Generator # Made By Adam Shannon # http://ashannon.us # adam@ashannon.us COPYRIGHT 2009 ALL RIGHTS RESERVED!!! */
// Load Header Files/Commands #include <iostream> using namespace std;
// Begin int main() { // Load Vars int max = '10'; int row = '1'; int col = '1'; char end; char start;
// Title Message cout << "\t\t\t\tDotted Slope Generator\n"; cout << "Enter a character to start."; cin >> start; // Begin Loop while (row < max) {
// Start the major loop while (col < row) { // Print each dot cout << "."; col++; }
// Reset for next line col = '1'; row++; cout << "\n"; }
// Pause till exit command. cout << "Enter a character to exit."; cin >> end;
return 0; } // End
</span>
|