]> git.sur5r.net Git - c128-kasse/blob - general.c
printing implemented
[c128-kasse] / general.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4
5 #include "general.h"
6
7 /*
8  * Liest (maximal 31) Zeichen ein, bis Enter gedrückt wird. Der zurückgegebene 
9  * char-pointer muss anschließend ge-free()d werden!
10  *
11  */
12 char *get_input() {
13         BYTE i = 0;
14         char *output = malloc(32 * sizeof(char));
15         BYTE c;
16         if (output == NULL) {
17                 perror("malloc()");
18                 exit(1);
19         }
20         memset(output, '\0', 32);
21         while (1) {
22                 if (i == 31)
23                         break;
24                 c = getchar();
25                 if (c == 13)
26                         break;
27                 else output[i++] = c;
28         }
29         return output;
30 }
31
32 void c128_perror(BYTE c, char *msg) {
33         printf("\nError (Code %d) while: %s\nOS Error = %s\n", c, msg, _oserror);
34 }