testcase.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Wed, 26 May 2010 14:56:44 +0200
changeset 126 52722ac7693f
parent 77 49e0babccb23
child 169 df7c720bcaa6
permissions -rw-r--r--
mysql_db: get not more than num_fields fields from a row I haven't tested the old approach, because i have never installed or used mysql. But it's nice to see that it actually works with this small patch. committer: Markus Bröker <mbroeker@largo.homelinux.org>

/**
 * testcase.c
 * Copyright (C) 2008 Markus Broeker
 */

#define _XOPEN_SOURCE 500

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

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

    if (argc != 4) {
        printf ("Usage: %s <string> <delim> <delim>\n", argv[0]);
        return EXIT_FAILURE;
    }

    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]);
    }

    printf ("\nTest finished\n");

    return EXIT_SUCCESS;
}