C/C++, KDEVELOP

Basics

  1. Simple Types
  2. Strings
  3. Arrays and Structs
  4. Operators

Program Flow

Functions

Classes and Objects

X Window

KDevelop


-----------------
© Alfred Nussbaumer
Updated:
09 December 2021
-----------------

Simple Types

There are several simple data types in C++:

  • char, signed char, unsigned char
  • short, signed short, unsigned short
  • int, usigned int
  • long, unsigned long
  • float
  • double
  • long double
  • enumerated types
  • bool

Type Casting

The general form of a type cast is (type) expression. For example,

(char) 65
forces the expression to be a character type, so the result is "A".

#include <iostream.h>

int alphabet();         

int main() {
  alphabet();
  return 0;
}

int alphabet() {
  for (int i=65;i<=90;i++) cout << (char) i;
  cout << endl;
  return 0;
}

ABCDEFGHIJKLMNOPQRSTUVWXYZ


© Alfred Nussbaumer, Weblog "MiniNuss"