1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
/*
The end result of this application should accept a character and convert it to its ASCII counterpart.
*/
/* Standard Includes */
#include "stdafx.h" //Here by default, not sure why
#include <ctype.h> //For using toupper
#include <iostream> //Used for cin and cout
#include <string> //Used for string access
/* Custom Includes */
/* This include file has been excluded for posting purposes. I originally had my tascii function in a seperate cpp file to keep it clean*/
//#include "functions.cpp"//Custom file
using namespace std; //So standard namespace classes can be used
/*
This function here should take a character and return its ASCII table equivalent.
*/
int tascii(char nchar[1])
{
int result;
if(strcmp(nchar,"A"))
{
result = 65;
}
if(strcmp(nchar,"B"))
{
result = 66;
}
if(strcmp(nchar,"C"))
{
result = 67;
}
if(strcmp(nchar,"D"))
{
result = 68;
}
if(strcmp(nchar,"E"))
{
result = 69;
}
if(strcmp(nchar,"F"))
{
result = 70;
}
if(strcmp(nchar,"G"))
{
result = 71;
}
if(strcmp(nchar,"H"))
{
result = 72;
}
if(strcmp(nchar,"I"))
{
result = 73;
}
if(strcmp(nchar,"J"))
{
result = 74;
}
if(strcmp(nchar,"K"))
{
result = 75;
}
if(strcmp(nchar,"L"))
{
result = 76;
}
if(strcmp(nchar,"M"))
{
result = 77;
}
if(strcmp(nchar,"N"))
{
result = 78;
}
if(strcmp(nchar,"O"))
{
result = 79;
}
if(strcmp(nchar,"P"))
{
result = 80;
}
if(strcmp(nchar,"Q"))
{
result = 81;
}
if(strcmp(nchar,"R"))
{
result = 82;
}
if(strcmp(nchar,"S"))
{
result = 83;
}
if(strcmp(nchar,"T"))
{
result = 84;
}
if(strcmp(nchar,"U"))
{
result = 85;
}
if(strcmp(nchar,"V"))
{
result = 86;
}
if(strcmp(nchar,"W"))
{
result = 87;
}
if(strcmp(nchar,"X"))
{
result = 88;
}
if(strcmp(nchar,"Y"))
{
result = 89;
}
if(strcmp(nchar,"Z"))
{
result = 90;
}
return result;
}
int _tmain()
{
char letter[1];
int result;
cout << "Hello, I will be taking your text and turning it into its ASCII counterpart." << endl;
cout << "Input a letter, single letter only please:\t";
cin >> letter[1];
cout << endl << "The letter you typed is:\t" << letter[1] << endl;
result = tascii(letter);
cout << "That letter converts to " << result << " in ASCII." << endl;
return 0;
}
| |