|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
|
It's simple. A character that you're using in your program already have an ASCII-value, but you sees it like a character. If you want to have the value itself, you can simply convert the character to an integer.
Code:
// C, with C type-casting char cMyCharacter = 'A'; int iMyAsciiValue = (int)cMyCharacter; // C++, with C++ type-casting char cMyCharacter = 'A'; int iMyAsciiValue = static_cast<int>(cMyCharacter);
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
|
|||
|
The same thing, just in reverse. You can either explicitly cast an int as a char or simply assign an int variable to a char variable.
C++ Code:
|
|
|||
|
Hey Guys,
I am new to learning C++ and I am trying to make a C++ program to display an Ascii image. Can someone help me get started on how to make this work? Thanks. I have included the image I am trying to make and the code that I have created. Can you tell me what I am doing wrong and how to get started correctly if I am doing this wrong? It is supposed to be the Ubuntu image but in ascii. Image .-. .-'``(|||) ,`\ \ `-`. 88 88 / \ '``-. ` 88 88 .-. , `___: 88 88 88,888, 88 88 ,88888, 88888 88 88 (:: : ___ 88 88 88 88 88 88 88 88 88 88 88 `-` ` , : 88 88 88 88 88 88 88 88 88 88 88 \ / ,..-` , 88 88 88 88 88 88 88 88 88 88 88 `./ / .-.` '88888' '88888' '88888' 88 88 '8888 '88888' LGB `-..-( ) `-` Code #include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { cout << " .-. "; cout << " .-'``(|||) "; cout << " ,`\ \ `-`. 88 88 "; cout << " / \ '``-. ` 88 88 "; cout << " .-. , `___: 88 88 88,888, 88 88 ,88888, 88888 88 88 "; cout << " (:: : ___ 88 88 88 88 88 88 88 88 88 88 88 ";cout << " `-` ` , : 88 88 88 88 88 88 88 88 88 88 88 "; cout << " \ / ,..-` , 88 88 88 88 88 88 88 88 88 88 88 "; cout << " `./ / .-.` '88888' '88888' '88888' 88 88 '8888 '88888' "; cout << " LGB `-..-( ) "; cout << " `-` "; system("PAUSE"); return EXIT_SUCCESS; } |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to convert your photoshop document to a CSS in less than 30 seconds | clookid | Photoshop Tutorials | 17 | 06-04-2008 11:36 AM |
| Convert matlab code to C/C++ on Linux | Kank | C and C++ | 2 | 10-11-2007 02:09 AM |
| Convert XLS in PDF | master.jimmy | Visual Basic Programming | 1 | 09-10-2007 03:00 AM |
| Please Help With A C Program!! | siren | C and C++ | 7 | 04-17-2007 08:45 AM |
| John | ........ | 223.00000 |
| dargueta | ........ | 168.00000 |
| Xav | ........ | 164.00000 |
| gaylo565 | ........ | 18.00000 |
| WingedPanther | ........ | 15.00000 |
| |pH| | ........ | 15.00000 |
| Johnnyboy | ........ | 3.00000 |
| navghost | ........ | 1.00000 |
Goal: 100,000 Posts
Complete: 66%