testcase.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 12:58:26 +0100
changeset 0 af501b0c1716
child 8 96d16dfe787a
permissions -rw-r--r--
demos cvs copy committer: Markus Bröker <mbroeker@largo.homelinux.org>

/**
 *     $Id: testcase.c,v 1.1.1.1 2008-04-28 17:32:53 mbroeker Exp $
 * $Source: /development/c/demos/testcase.c,v $
 *
 */

#define _XOPEN_SOURCE 500

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (int argc, char **argv)
{
    char line[83];
    char *token;
    int i;

    if (argc != 4) {
        printf ("Usage: %s (char*)string (char*)delim1 (char*)delim2\n", argv[0]);
        return 0;
    }

    snprintf (line, 80, "%s\r\n", argv[1]);

    token = strtok (line, argv[2]);

    while (token) {
        printf ("TOKEN: %s\n", token);
        token = strtok (NULL, argv[3]);
    }

    i = 0;
    printf ("while i++ <5: ");
    while (i++ < 5)
        printf ("%d ", i);

    i = 0;
    printf ("\nwhile ++i <5: ");
    while (++i < 5)
        printf ("%d ", i);

    i = 0;
    printf ("\nwhile i <5  : ");
    while (i < 5)
        printf ("%d ", i++);

    i = 0;
    printf ("\nwhile i <5  : ");
    while (i < 5)
        printf ("%d ", ++i);

    printf ("\nTest finished\n");
    return 0;
}