File: filegen.c

package info (click to toggle)
prrte 3.0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,128 kB
  • sloc: ansic: 80,431; sh: 4,289; perl: 3,195; makefile: 1,829; lex: 352; python: 239
file content (40 lines) | stat: -rw-r--r-- 817 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright (c) 2022      Nanook Consulting.  All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 *
 */

#define _GNU_SOURCE
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

int main(int argc, char **argv)
{
    int n, limit, rc;
    char buffer[1024];

    if (argc < 2) {
        fprintf(stderr, "Usage: %s <number of 1024 buffers to write>\n", argv[0]);
        exit(1);
    }
    limit = strtol(argv[1], NULL, 10);
    memset(buffer, 'a', 1024);
    buffer[1023] = '\n';
    for (n=0; n < limit; n++) {
        rc = write(STDOUT_FILENO, buffer, 1024);
        if (0 > rc) {
            fprintf(stderr, "Write failed: %d\n", rc);
            exit(1);
        }
    }
    exit(0);
}