#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char ch;
int i;
cout<<"enter your character form the key board";
cin>>ch;
i=int.ch;
cout<<"your character "<<ch<<" in ascii code is "<<i;
getch();
}
.cpp*Mod edit: fixed code tags:




Posted 30 May 2009 - 02:00 AM
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char ch;
int i;
cout<<"enter your character form the key board";
cin>>ch;
i=int.ch;
cout<<"your character "<<ch<<" in ascii code is "<<i;
getch();
}
.cpp
Posted 30 May 2009 - 02:50 AM
#include <iostream>
#include <windows.h>
/*---------------------
| NameSpace |
---------------------*/
using namespace std;
/*----------------------------
| Define Constants |
----------------------------*/
/*--------------------------
| Function Declarations |
--------------------------*/
/*-------------
| main |
-------------*/
int main(int argc, char *argv[])
{
int choice = 0;
bool exit = true;
do
{
system("CLS");
char ch = NULL;
cout << endl << endl << endl;
cout << " Enter your character form the key board" << endl << endl;
cout << " and press return => ";
cin >> ch;
cout << endl << endl << endl;
cout << " Your character is " << ch << endl << endl;
cout << " In ascii code it is " << int(ch);
cout << endl << endl << endl;
cout << " ";
system("PAUSE");
cout << endl << endl << endl;
cout << " Type the number 1 and press return to run this program again;" << endl << endl << endl;
cout << " or type any key and press return to exit ==> ";
cin >> choice;
if (choice == 1)
exit = true;
else
exit = false;
}while(exit == true);
return 0;
}
/*-------------
| Functions |
-------------*/
/*---------------------
| End of Program |
---------------------*/
Posted 30 May 2009 - 06:24 AM
Posted 30 May 2009 - 09:16 AM
for(int i='A'; i < 'Z'; i++)
printf("\n%c",i);
char x = 'A'; cout<<(int)x;
char c ='A';
int i = 70;
//Char to ASCII
printf("%c = %d",c,c);
//ASCII to char
printf("%d = %c",i,i);
Posted 30 May 2009 - 11:44 AM
This post has been edited by IngeniousHax: 30 May 2009 - 11:44 AM
Posted 30 May 2009 - 12:53 PM
int StrToInt(const char* &Str)
{
int sum = 0, factor = 1;
if(Str!=NULL)
{
int size = sizeof(Str);
while(size-->0)
{
if(Str[size]<48 || Str[size]>57)
break;
sum += ((Str[size] - 48) * factor);
factor *= 10;
}
return sum;
}
return 0;
}
char Str[] = "plus"; cout << "\n\n " << Str << '\t'; cout << "[ "; for(int i=0;Str[i]!='\0';i++) cout << (int)Str[i] << " | "; cout << " ]\n\n ";
This post has been edited by Plus: 30 May 2009 - 01:01 PM
