Skip to content

Instantly share code, notes, and snippets.

@jozefizso
Created October 26, 2013 13:19
Show Gist options
  • Save jozefizso/7169384 to your computer and use it in GitHub Desktop.
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.
//
// 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