Friday, January 6, 2012

Basic input/output: cin & cout

Example:
Basic input/output: cin & cout
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
 int input1;
 float input2;
 char input3;
 
 char retry;
 do{
  cout << "Hello! Enter: int, float and char" << endl;
  cin >> input1 >> input2 >> input3;
  cout << "You enter: " << endl;
  cout << input1 << endl;
  cout << input2 << endl;
  cout << input3 << endl << endl;

  cout << "Retry? <y>" << endl;
  cin >> retry;
 } while ((retry==(char)'y')||(retry==(char)'Y'));

 system("PAUSE");
 return 0;
}


Thursday, January 5, 2012

Wide character - wchar_t

According to Wikipedia:

A wide character is a computer character datatype that generally has a size greater than the traditional 8-bit character. The increased datatype size allows for the use of larger coded character sets.

in C/C++:
The standard library of the C programming language includes a lot of facilities for dealing with wide characters and strings composed of them. The wide characters are defined using datatype wchar_t, which in the original C90 standard was defined as 16-bit value due to historical compatibility reasons. C and C++ compilers that comply with the 10646-1:2000 Unicode standard generally assume 32-bit values.

However, the ISO/IEC 10646:2003 Unicode standard 4.0 says that:

"ANSI/ISO C leaves the semantics of the wide character set to the specific implementation but requires that the characters from the portable C execution set correspond to their wide character equivalents by zero extension."

and that

"The width of wchar_t is compiler-specific and can be as small as 8 bits. Consequently, programs that need to be portable across any C or C++ compiler should not use wchar_t for storing Unicode text. The wchar_t type is intended for storing compiler-defined wide characters, which may be Unicode characters in some compilers."


Example:
Wide character - wchar_t
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
 
 cout << "_WCHAR_T_SIZE: " << _WCHAR_T_SIZE << endl;
 cout << "WCHAR_MIN= " << WCHAR_MIN << endl;
 cout << "WCHAR_MAX= " << WCHAR_MAX << endl << endl;

 wchar_t wideChar_heart = L'?';
 cout << wideChar_heart << endl;
 wprintf(L"wideChar_heart: %lc \n", wideChar_heart);

 system("PAUSE");
 return 0;
}



Size and range of integer; INT, SHORT, LONG and LONGLONG

Size and range of integer; INT, SHORT, LONG and LONGLONG

It's tested under Windows 8 (Developer Preview) and Visual Studio 11 Developer Preview.
Size and range of integer; INT, SHORT, LONG and LONGLONG
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{

 cout << "_INT_SIZE: " << _INT_SIZE << endl;
 cout << "INT_MIN= " << INT_MIN << endl;
 cout << "INT_MAX= " << INT_MAX << endl << endl;

 cout << "_SHORT_SIZE: " << _SHORT_SIZE << endl;
 cout << "SHRT_MIN= " << SHRT_MIN << endl;
 cout << "SHRT_MAX= " << SHRT_MAX << endl;
 cout << "USHRT_MAX= " << USHRT_MAX << endl << endl;

 cout << "_LONG_SIZE: " << _LONG_SIZE << endl;
 cout << "LONG_MIN= " << LONG_MIN << endl;
 cout << "LONG_MAX= " << LONG_MAX << endl;
 cout << "ULONG_MAX" << ULONG_MAX << endl << endl;

 cout << "_LONGLONG_SIZE: " << _LONGLONG_SIZE << endl;
 cout << "LLONG_MIN= " << LLONG_MIN << endl;
 cout << "LLONG_MAX= " << LLONG_MAX << endl;
 cout << "ULLONG_MAX= " << ULLONG_MAX << endl << endl;

 system("PAUSE");
 return 0;
}


C/C++ Fundamental data type, int

C/C++ Fundamental data type, int

In C/C++, variable of int can be defined and initiated using the form:
int i1 = 10;
int i2(20);


In Windows 8(Developer Preview), it's size id 4 byte.

Example:
C/C++ Fundamental data type, int
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int i1 = 10;
int i2(20);

cout << "size of i1(int): " << sizeof(i1) << endl;
cout << "i1 = " << i1 << endl;
cout << "size of i2(int): " << sizeof(i2) << endl;
cout << "i2 = " << i2 << endl;
system("PAUSE");
return 0;
}

Wednesday, January 4, 2012

Create Win32 C++ Console application using Microsoft Vistal Studio 11 Developer Preview

- Start Microsoft Vistal Studio 11 Developer Preview

- Click New Project... in the start-up page.
New Project...

- Select template of Visuall C++ Win32 Console Application, enter Name, and optionally enter Location, and click OK.
New Project Wizard: Visuall C++ Win32 Console Application

- Review the project settings and click Next.
Project Settings

- Review and accept the default application settings, click Finish.
Application Settings

- The Wizard will generate a default project:
Auto-generated project

- Modify the code:
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>


int _tmain(int argc, _TCHAR* argv[])
{
 std::cout << "Hello World!" << std::endl;
 system("PAUSE");
 return 0;
}

Add the code

- Finally, Save, Build and Run the first Visuall C++ Win32 Console Application:
Run

Thursday, December 29, 2011

Hello World! Small Basic.

- Start Microsoft Small Basic. It's the beautiful start-up screen of Small Basic.Start-up screen of Microsoft Small Basic
- The square area is the Editor, where we write our code here.
- When you type your code in Editor, Small Basic's intellisense feature pop-up helpful tips for you.Small Basic's intellisense
- Enter the code in Editor
TextWindow.WriteLine("Hello World!")
Enter code
- And click on the RUN button (or press F5 key)Running Hello World!
- It's our first program of Small Basic.

Tuesday, December 27, 2011

TOP 100 Global Innovators

This proprietary program (TOP 100 GLOBAL INNOVATORS) recognizes the 100 most innovative companies in the world, according to a series of patent-related metrics that get to the essence of what it means to be truly innovative.

Web Site: http://top100innovators.com/

Download FREE copy of Thomson Reuters 2011 Top 100 Global Innovators.
Thomson Reuters 2011 Top 100 Global Innovators