| | |
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 29 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 29 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; 29 Days Ago at 7:46 pm.
0
#4 29 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 29 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 |
* ansi api array arrays bash binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile createcopyoffile createprocess() directory dynamic execv fflush file floatingpointvalidation fork forloop frequency function getlasterror getlogicaldrivestrin givemetehcodez grade graphics gtkgcurlcompiling gtkwinlinux hardware highest histogram homework i/o ide inches include infiniteloop initialization input intmain() iso keyboard km license linked linkedlist linux list looping loopinsideloop. lowest matrix microsoft mysql oddnumber open opendocumentformat openwebfoundation pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string suggestions test threads unix urboc user variable whythiscodecausesegmentationfault win32api windows.h windowsapi






