Jump to content

Recommended Posts

Posted (edited)

Just made this code.  I'll have to go back and see how you're doing timing (I normally use SDL libraries)

But this works it bangs Hello World out at the console.

I'll make an fopen version and check how you're doing timings like I said.

#include <fstream>

int main(int argc, char *argv[]) {
    for (int i = 0; i < 1000; i++) {
        fprintf(stderr, "Hello World\n");
    }

    fprintf(stderr, "Program exited\n");
    return 0;
} // END main(int argc, char *argv[])

The loop is so I have a chance to see it.

Edited by Xandy
Posted (edited)

Removes file stderr.txt (to delete contents each run)

Populates a stderr.txt file with output.

 

#include <fstream>

int main(int argc, char *argv[]) {

    // Blank out the file by removing it
    remove("stderr.txt");
    
    // Open stream to file for appending data
    FILE *file = fopen("stderr.txt", "a");

    for(int counter = 0; counter < 10000; counter++){
        // Percent d %d b/c counter is decimal number
        fprintf(file, "%d: Hello World\n", counter);
    }
    
    ; Close the file stream
    fclose(file);
    return 0;
} // END main(int argc, char *argv[])

I see timing isn't important in the code.  You're not doing it there so I ignored a timer.

It is SO fast.

Edited by Xandy

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...