shtuff
This commit is contained in:
61
library/alphastdio.c
Normal file
61
library/alphastdio.c
Normal file
@ -0,0 +1,61 @@
|
||||
#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;
|
||||
}
|
Reference in New Issue
Block a user