#c
5116 (changes)
4975 (one coffee-bean)
2999 (some cities)
| item | no |
|---|---|
| prague | 1 |
| amsterdam | 1 |
| london | 1 |
| paris | 1 |
| berlin | 1 |
| hamburg | 1 |
| kiel | 1 |
| baltrum | 1 |
| enger | 1 |
| san francisco | 0 |
2983 (fingeruebung)
this is the windows-thang for a keypress-read without enter. output char and ascii-value. loop terminated by ‘#’.
//offensichtlich ein windowsding
#include<stdio.h>//standardinout
//windows for kbhit and getchar
#include<conio.h>
//for sleep
#include<windows.h>
//linux
//#include <termios.h>
//#include <string.h>
int main() {
int countdown;
char ch;
int wert;
char b;
do {
while(countdown++ <= 1000)
{
if(b=kbhit())
break;
Sleep(1);
}
ch = getch();
wert = ch;
if (b != 0)
{ printf("key %c ascii %d\n", ch, wert);}
} while (ch != '#');
printf ("programmende\n");
return 0;
}
2960 (c specifiers)
| item | format | comment |
|---|---|---|
| %d(%i) | signed int,(short,long) | decimal |
| %u | unsigned int | positive decimal |
| %x,%X | unsigned int | hexadecimal |
| %o | unsigned int | octal |
| %c | char | single character |
| %s | array of char | string(sequence of chacters) |
| %f | signed float,double | floating point |
| %e,%E | float,double | floating point(exponential) |
| %g,%G | float,double | {([%f or %e])} |
| %p | ? | pointer address stored in pointer |
2704 (BASIC GET in c)
The following c-program reads a single keystroke without enter. Output is the key and its ascii-value. The keys are read in a loop that is interrupted by the #-sign. Note that this is not trivial.
#include <stdio.h>
#include <termios.h>
#include <string.h>
int kbhit(void);
int kbhit(void) {
struct termios term, oterm;
int fd = 0;
int c = 0;
tcgetattr(fd, &oterm);
memcpy(&term, &oterm, sizeof(term));
term.c_lflag = term.c_lflag & (!ICANON);
term.c_cc[VMIN] = 0;
term.c_cc[VTIME] = 1;
tcsetattr(fd, TCSANOW, &term);
c = getchar();
tcsetattr(fd, TCSANOW, &oterm);
if (c != -1)
ungetc(c, stdin);
return ((c != -1) ? 1 : 0);
}
int getch();
int getch()
{
static int ch = -1, fd = 0;
struct termios neu, alt;
fd = fileno(stdin);
tcgetattr(fd, &alt);
neu = alt;
neu.c_lflag &= ~(ICANON|ECHO);
tcsetattr(fd, TCSANOW, &neu);
ch = getchar();
tcsetattr(fd, TCSANOW, &alt);
return ch;
}
int rechne(char v);
int rechne(char v) {
int vback;
vback = v;
return vback;
}
int main() {
char c;
int interr;
interr = 1;
do {
do {
c = getch();
if (c == '#') {
interr = 0;
break;
}
int wert;
wert = rechne(c);
printf("char '%c' key '%d'\n", c, wert);
}
while(kbhit());
}
while(interr);
printf("programmende\n");
return 0;
}
2539 (little table)
| item | ascii-code | no | reverse no |
|---|---|---|---|
| a | 97 | 1 | 5 |
| b | 98 | 2 | 4 |
| c | 99 | 3 | 3 |
| d | 100 | 4 | 2 |
| e | 101 | 5 | 1 |
2514 (23)
friday.
peace on earth.
music.
dance.
pray.
sing.
write.
wonder.
for those gone.
text only.
2495 (cocktail)
| item | no |
|---|---|
| olanzapin 10 | 2 |
| fluanxol 5 | 3 |
| truxal 15 | 4 |
| pantoprazol 20 | 5 |
| oxaliplatin | 6 |
| 5fu | 7 |
| kalinor retard p 600 | 8 |
| taxilan x (bedarf) | 9 |
| tavor 1,0 (bedarf) | 10 |
| emend 80 (schwarze tage) | 11 |
| dexamethason 8 (schwarze tage) | 1 |
