| | |
Rot 13 Help
![]() |
•
•
Join Date: Jul 2009
Posts: 36
Reputation:
Solved Threads: 0
I made a program that finds the ROT 13, but theres a little thing thats messing it up for me. Its supposed to find the ROT 13 of each character but when i run it, it gives me some funky character in return
Can some one help me out please
C Syntax (Toggle Plain Text)
#include <stdio.h> #include <string.h> int rot13(int c) { if (c >= 'A' && c < 'N') { return c + 13; } if (c >= 'N' && c <= 'Z') { return c - 13; } if (c >= 'a' && c < 'n') { return c + 13; } if (c >= 'n' && c <= 'z') { return c - 13; } } int main(void) { int c; printf("Enter a character: "); while((c == getchar())!= EOF) { char a = rot13(c); printf("%c", a); c++; } return 0; }
0
#2 21 Days Ago
while((c = getchar())!= EOF) "One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
Join Date: Jul 2009
Posts: 36
Reputation:
Solved Threads: 0
0
#3 21 Days Ago
•
•
•
•
And what does your function return for non-alpha input?while((c = getchar())!= EOF)
if I input 10, it returns 10
if I input ? it returns ?
This program is supposed to do only one of the characters
If i input Apple, its supposed to return N and nothing else
Last edited by yasaswyg; 21 Days Ago at 7:46 pm.
0
#4 21 Days Ago
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
Join Date: Jul 2009
Posts: 36
Reputation:
Solved Threads: 0
0
#5 21 Days Ago
I put that in.
my new code looks like this
my new code looks like this
C Syntax (Toggle Plain Text)
#include <stdio.h> #include <string.h> int rot13(int c) { if (c >= 'A' && c < 'N') { return c + 13; } if (c >= 'N' && c <= 'Z') { return c - 13; } if (c >= 'a' && c < 'n') { return c + 13; } if (c >= 'n' && c <= 'z') { return c - 13; } return c; } int main(void) { int c; printf("ROT 13 Converter\n\nEnter a Character: "); while((c = getchar())!= EOF) { char a = rot13(c); printf("%c", a); c++; } return 0; }
![]() |
Other Threads in the C Forum
- Previous Thread: factorial series
- Next Thread: Remowing white spaces + separating sentences
| Thread Tools | Search this Thread |
#include adobe ansi api array asterisks binarysearch changingto char character cm copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic feet fflush fgets file fork forloop frequency function getlasterror givemetehcodez global grade graphics gtkgcurlcompiling hacking highest histogram homework i/o include incrementoperators infiniteloop input interest kernel keyboard kilometer linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft mqqueue mysql number odf owf pattern pdf performance pointer posix probleminc process program programming radix read recursion recv repetition research reversing scanf segmentationfault sequential shape socket socketprograming stack standard string systemcall threads turboc unix user voidmain() wab windows.h windowsapi






