Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Philipp Sosna Sudiengruppe 1A Parktikumsgruppe II
- Lerngruppe: Tim Zaska, Philipp Sosna, Christane Sagan
- Programm für Geocache
- */
- // compiler params: -std=g99
- #include <stdio.h>
- int main () {
- char text[99];
- int laenge = 0; // leerzeichen
- int ASCIIwert;
- printf("Geben Sie einen Text ein:\n");
- gets(text); // lass das leerzeichen zwischen gets (text) weg
- laenge = strlen(text);
- if(laenge >= sizeof(text)) // anstatt >= 100 nimmst du hier am besten die definierte Arraylänge, dann muss man es nicht jedes mal ändern, das ist wichtig wenn du mehrere arrays hast
- {
- printf("ERROR zuviele Zeichen!\n"); // um ein Tab rein verschieben sieht besser aus
- return 0; // lass da die leerzeile weg
- }
- printf("\n\nCache:\t");
- for(int i = 0; i < laenge; i++) // nimm for anstatt while (du musst dem compiler angeben, dass du mit -std=g99 arbeitesr)
- {
- ASCIIwert = (int) text[i]; // leerzeichen zwischen ASCIIwert und dem =
- if(ASCIIwert >= 65 && ASCIIwert <= 77 || ASCIIwert >= 97 && ASCIIwert <= 109)
- {
- ASCIIwert += 13; // nimm += anstatt ASCIIwert = ASCIIwert+13
- text[i] = (char) ASCIIwert;
- }// spar dir die leerzeilen, if ist in der c Schreibform eh so platzfressend
- else if(ASCIIwert >= 78 && ASCIIwert <= 90 || ASCIIwert >= 110 && ASCIIwert <= 122)
- {
- ASCIIwert -= 13;
- text[i] = (char) ASCIIwert;
- }
- printf("%c", text[i]);
- // else ist unnötig, nimm einfach einmal ein printf, ist eh immer das selbe ^^
- }
- printf("\n"); // brauchst du eig nicht zwingend
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement