Example: auto

The following example shows an auto variable,retry, being used in a for loop.

    #define MAX_RETRIES 5
    static int logon_done = 0;
    auto int retry; // Attempt to logon MAX_TRIES 
    if (!logon_done) {
        // logon to server here and break out of loop if successful 
        for (retry=0; retry<MAX_RETRIES; retry++)
            lr_output_message ("Retry number %d", retry);
        logon_done = 1;
    }
Example: Output:
Action.c(12): Retry number 0
Action.c(12): Retry number 1
Action.c(12): Retry number 2
Action.c(12): Retry number 3
Action.c(12): Retry number 4