Created
October 26, 2013 13:19
-
-
Save jozefizso/7169384 to your computer and use it in GitHub Desktop.
Simple C program for reading user input and writing it out as number codes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.c | |
// Platform: OS X 10.9 | |
// | |
// Created by Jozef Izso on 26.10.2013. | |
// Copyright (c) 2013 Jozef Izso. All rights reserved. | |
// | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
int main(int argc, const char * argv[]) | |
{ | |
char action, inputChar; | |
printf("Choose encryption or decryption (e/d): "); | |
action = getchar(); | |
if (action == 'e') | |
{ | |
printf("Please, enter a word to encrypt: "); | |
fpurge(stdin); | |
while ((inputChar = getchar()) != '\n') | |
{ | |
if (isalpha(inputChar)) | |
{ | |
printf("%d ", inputChar); | |
} | |
} | |
printf("\n"); | |
return 0; | |
} | |
else if (action == 'd') | |
{ | |
printf("Decryption\n"); | |
return 0; | |
} | |
else | |
{ | |
printf("Invalid choice.\n"); | |
return -1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment