diff options
| author | Miguel <m.i@gmx.at> | 2018-09-21 11:44:55 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-09-21 11:44:55 +0200 |
| commit | f5281689c95758f17628f0286e0265ecf3385a8e (patch) | |
| tree | 312b16fcbaf40b7e32c1b7e3fe783477e8d9674c /userspace | |
| parent | e68c8e3468076afa171ffff82b9bafa4cbc335bb (diff) | |
little div prog and cleaning userspace
Diffstat (limited to 'userspace')
| -rw-r--r-- | userspace/brainfuck.c | 2 | ||||
| -rw-r--r-- | userspace/checker.c | 20 | ||||
| -rw-r--r-- | userspace/clear.c | 2 | ||||
| -rw-r--r-- | userspace/div.c | 23 | ||||
| -rw-r--r-- | userspace/err.c | 9 | ||||
| -rw-r--r-- | userspace/exception.c | 4 |
6 files changed, 25 insertions, 35 deletions
diff --git a/userspace/brainfuck.c b/userspace/brainfuck.c index c608064..a30ea7c 100644 --- a/userspace/brainfuck.c +++ b/userspace/brainfuck.c @@ -5,8 +5,6 @@ Author: Felix Oghină License: (brain)fuck licenses! - - */ // taken from: http://it-ride.blogspot.com/2009/11/brainfuck-interpreter.html diff --git a/userspace/checker.c b/userspace/checker.c deleted file mode 100644 index ac0bcc9..0000000 --- a/userspace/checker.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <stdio.h> - -int main() - -{ -FILE *fp; /* The file handle for input data */ -fp=stdin; -int ch; /* Each character read. */ -int checksum = 0; /* The checksum mod 2^16. */ -int count=0; - -printf("this will calc a simple checksum of the enered text\nPress Left Control + D to signify end of file \n",checksum,count); -while ((ch = getc(fp)) != EOF) { - checksum = (checksum >> 1) + ((checksum & 1) << 15); - checksum +=(int) ch; - checksum &= 0xffff; /* Keep it within bounds. */ - count++; -} -printf("checksum : 0x%08X for %i bytes\n",checksum,count); -} diff --git a/userspace/clear.c b/userspace/clear.c index 9557760..1c794b8 100644 --- a/userspace/clear.c +++ b/userspace/clear.c @@ -1,3 +1,5 @@ +/** clear our console */ + #include <stdio.h> int main() { diff --git a/userspace/div.c b/userspace/div.c new file mode 100644 index 0000000..595084e --- /dev/null +++ b/userspace/div.c @@ -0,0 +1,23 @@ +// divide one param by another // +// can be easily be used to provoke division by zero excpetion // + +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char **argv) +{ + if (argc!=3) + { + printf("Divide two integers and print result \n"); + printf("usage : %s [quotient] [divisor]\n",argv[0]); + return EXIT_FAILURE; + } + + int q=atoi(argv[1]); + int d=atoi(argv[2]); + printf("Divide %i by %i\n",q,d); + printf("%i / %i = %i\n",q,d,q/d); + printf("%i mod %i = %i\n",q,d,q%d); + + return EXIT_SUCCESS; +} diff --git a/userspace/err.c b/userspace/err.c deleted file mode 100644 index 8e5d819..0000000 --- a/userspace/err.c +++ /dev/null @@ -1,9 +0,0 @@ -#include <stdio.h> - -int main(int argc, char **argv) -{ - char buf[]="This is a line written to stderr.\n"; - int l=fwrite(buf,sizeof(char),strlen(buf),stderr); // write stderr; - printf("Written %i chars to stderr.\n",l); - return 0; -} diff --git a/userspace/exception.c b/userspace/exception.c deleted file mode 100644 index 4f72c86..0000000 --- a/userspace/exception.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() -{ - return 10/0; -} |
