Skip to content

Commit

Permalink
Add typical C programming example
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Pettersson committed Feb 7, 2024
1 parent baea25d commit dac6810
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
30 changes: 30 additions & 0 deletions example2/translate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int rovarsprak(void)
{
const char consontants[] = "bcdfghjklmnpqrstvwxz";
char c;

while ((c = tolower(getchar()))) {
switch (c) {
case EOF:
case '!':
return 0;
}

for (int i = 0; i < strlen(consontants); i++)
if (c == consontants[i])
printf("%co", c);

putchar(c);
}

return 1;
}

int main(int argc, char **argv)
{
return rovarsprak();
}
12 changes: 12 additions & 0 deletions example2/translate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Test translate.c

~~~ {.sh}
$ echo | ./example2
$ echo "! Sepcial stop chacter" | ./example2
$ echo "Yay! Only wovels" | ./example2
yay
$ echo "Wow! With consonants" | ./example2
wowowow
~~~

0 comments on commit dac6810

Please sign in to comment.