Move io function into own module.

This commit is contained in:
paulusja 2026-04-09 13:46:34 +02:00
parent b67837d4d2
commit 9f63d5fa2b
3 changed files with 19 additions and 11 deletions

View File

@ -23,7 +23,7 @@
#include <stdio.h>
#include <ctype.h>
unsigned char getSingleChar();
#include "myio.h"
int main()
@ -48,13 +48,3 @@ int main()
return 0;
}
unsigned char getSingleChar()
{
unsigned char result = 'a';
result = getchar();
while(result != '\n' && getchar() != '\n') {}
return result;
}

12
02/myio.c Normal file
View File

@ -0,0 +1,12 @@
#include <stdio.h>
#include "myio.h"
unsigned char getSingleChar()
{
unsigned char result = 'a';
result = getchar();
while(result != '\n' && getchar() != '\n') {}
return result;
}

6
02/myio.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef MYIO_H
#define MYIO_H
unsigned char getSingleChar();
#endif