ASCII to character

Hi,

I wanna create program that will convert number from ASCII table to character, I've created simple program but instead of characters it's returning "pictures"

so if I enter 3 I'll get heart

1
2
3
4
5
6
7
8
9
10
11
12
#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
	int number;
	cin >> number;
	cout << char(number) << endl;
	system("pause");
	return 0;
}

I've tried it vice versa (text to ASCII) and it worked, so when I entered "a" I've got 97
Here's the ASCII chart: http://www.asciitable.com/

So you can see that a 3 is actually a heart and an 'a' is 97 so your program is working properly. Maybe you want something like stringstream?

EDIT: Sorry, here's stringstream: http://www.cplusplus.com/reference/iostream/stringstream/
Last edited on
ah, lol, thanks :D
Topic archived. No new replies allowed.