Added: C++ projects
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
// console output
|
||||
std::cout << "Hello, World!" << std::endl;
|
||||
std::cout << 1234 << std::endl;
|
||||
std::cout << "Another test!\n";
|
||||
|
||||
cout << "It is also working without std::" << endl;
|
||||
|
||||
int number = 10;
|
||||
cout << "number: " << number << endl;
|
||||
|
||||
// cout << L"This is a wide character string, but it is not supported by cout." << endl;
|
||||
|
||||
// console input
|
||||
cin >> number;
|
||||
cout << "number: " << number << endl;
|
||||
|
||||
char c;
|
||||
cin >> c;
|
||||
cout << "c: " << c << endl;
|
||||
|
||||
cin >> c >> number;
|
||||
cout << "c: " << c << endl;
|
||||
cout << "number: " << number << endl;
|
||||
|
||||
// boolean
|
||||
bool b = 1; // 0 -> false, anything else -> true
|
||||
cout << "b: " << b << endl;
|
||||
|
||||
if (number != 0)
|
||||
{
|
||||
// true
|
||||
}
|
||||
else
|
||||
{
|
||||
// false
|
||||
}
|
||||
|
||||
// zero-terminated string
|
||||
const char str[] = "Hello";
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user