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

int main()
{
    int zahl = 1235;
    char str[] = "Dies ist ein String";

#if USE_MALLOC
    /* Allokiere Speicherblock fuer 10 Zeichen + '\0'-Terminator */
    char *ptr = malloc(10+1);
    if (!ptr) {
	fprintf(stderr, "Allokation fehlgeschlagen.\n");
	return EXIT_FAILURE;
    }
    memset(ptr, '\0', 11);
    strncpy(ptr, "0123456789", 10);
#endif /* USE_MALLOC */

    /* Ausgabe */
    printf("Zahl:   %d\n", zahl);
    printf("String: %s\n", str);
#if USE_MALLOC
    if (ptr != NULL) {
	printf("Dynamische allokierter String: %s\n", ptr);
	free(ptr);
    }
#endif

    return EXIT_SUCCESS;
}


