Files
compiler-the-translators/library/alphastdio.c
Scarlett 596434e152 shtuff
2025-05-06 15:21:36 -04:00

61 lines
903 B
C

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int printS(char *str) {
if (str == NULL) return -1;
printf("%s", str);
return 0;
}
char *inS() {
char *buffer = malloc(100);
if (buffer == NULL) return NULL;
if (fgets(buffer, 100, stdin) == NULL) {
free(buffer);
return NULL;
}
buffer[strcspn(buffer, "\n")] = 0;
return buffer;
}
int printI(int i) {
printf("%d", i);
return 0;
}
int inI() {
int i;
char buffer[100];
if (fgets(buffer, sizeof(buffer), stdin) == NULL) return 0;
if (sscanf(buffer, "%d", &i) != 1) return 0;
return i;
}
int printC(char c) {
printf("%c", c);
return 0;
}
char inC() {
char c;
if (scanf(" %c", &c) != 1) return 0;
return c;
}
int printB(bool b) {
if (b)
printf("true");
else
printf("false");
return 0;
}