[ create a new paste ] login | about

Link: http://codepad.org/ALctcYUx    [ raw code | output | fork ]

C, pasted on Jan 6:
#include <iostream>
using namespace std;

int main()
{
	int x = 1;
	float y = 2;
	char c = 'A';

	// Con trỏ void đọc là con trỏ vô kiểu. Nó có thể trỏ đến bất cứ ô nhớ kiểu nào. Nhưng khi lấy ra giá trị nó trỏ đến
	// thì ta phải ép kiểu.
	void* p;
	p = &x;
	cout<<*((int*)p); // 1

	p = &y;
	cout<<endl<<*((float*)p);

	p = &c;
	cout<<endl<<*((char*)p);

	system("pause");
	return 0;
}


Output:
1
2
3
4
5
6
7
Line 19: error: iostream: No such file or directory
Line 2: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'
In function 'main':
Line 14: error: 'cout' undeclared (first use in this function)
Line 14: error: (Each undeclared identifier is reported only once
Line 14: error: for each function it appears in.)
Line 17: error: 'endl' undeclared (first use in this function)


Create a new paste based on this one


Comments: