Praktikum 4 weitergearbeitet

This commit is contained in:
Didnt Read Readme 2022-03-16 15:50:13 +01:00
parent d4c2ce5bc4
commit 826ed82258
7 changed files with 29 additions and 20 deletions

View File

@ -12,6 +12,7 @@
* @brief Lab implementation * @brief Lab implementation
*/ */
// begin students to add code for task 4.1 // begin students to add code for task 4.1
#include <stdio.h>
#define EOL 10 #define EOL 10
#define PARSE_ERROR -1 #define PARSE_ERROR -1
#define READ_ERROR -2 #define READ_ERROR -2
@ -20,30 +21,13 @@
#define ASCII_DIGIT_9 57 #define ASCII_DIGIT_9 57
#define NO_POS -1 #define NO_POS -1
#define BUFFERSIZE 10 #define BUFFERSIZE 10
#define EOF -1
int getInt(int maxResult) { int getInt(int maxResult) {
// end of input
//int EOF = -1; // end of file
//int EOL = 10; // end of line
// abnormal return values
//int PARSE_ERROR = -1;
//int READ_ERROR = -2;
// ASCII Codes
//int ASCII_SPACE = 32; // ' '
//int ASCII_DIGIT_0 = 48; // '0'
//int ASCII_DIGIT_9 = 57; // '9'
// conversion buffer
//int NO_POS = -1;
//int BUFFERSIZE = 10;
char buffer[BUFFERSIZE] = {0}; char buffer[BUFFERSIZE] = {0};
int result = 0; int result = 0;
// read line: up to EOL or EOF (i.e. error while reading) // read line: up to EOL or EOF (i.e. error while reading)
int bytes = 0; int bytes = 0;
int input; int input = getchar();
scanf("%d", &input);
while ((input != EOL) && (input != EOF)) { // read whole line while ((input != EOL) && (input != EOF)) { // read whole line
if (bytes < BUFFERSIZE) { // only buffer first n characters if (bytes < BUFFERSIZE) { // only buffer first n characters
buffer[bytes] = (char)input; buffer[bytes] = (char)input;
@ -51,7 +35,7 @@ int getInt(int maxResult) {
} else { } else {
result = PARSE_ERROR; // exceed buffer size, continue read line result = PARSE_ERROR; // exceed buffer size, continue read line
} }
scanf("%d", &input); input = getchar();
} }
if (input == EOF) { if (input == EOF) {
result = READ_ERROR; result = READ_ERROR;

View File

@ -1 +1,18 @@
src/read.o: src/read.c /usr/include/stdc-predef.h src/read.o: src/read.c /usr/include/stdc-predef.h /usr/include/stdio.h \
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
/usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/bits/long-double.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
/usr/include/x86_64-linux-gnu/bits/types/FILE.h \
/usr/include/x86_64-linux-gnu/bits/libio.h \
/usr/include/x86_64-linux-gnu/bits/_G_config.h \
/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h \
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h

Binary file not shown.

View File

@ -0,0 +1,8 @@
Dreiecksbestimmung (CTRL-C: Abbruch)
Seite a: Seite a: Seite a: Seite a: Seite a: Seite b: Seite b: Seite b: Seite b: Seite b: Seite c: Seite c: -> Dreieck 3-4-5 ist rechtwinklig
Dreiecksbestimmung (CTRL-C: Abbruch)
Seite a:
bye bye