Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) StringLiteralExample1

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppStringLiteralExample1/CppStringLiteralExample1.pro

 

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra -Weffc++ -Werror
SOURCES += main.cpp

 

 

 

 

 

./CppStringLiteralExample1/main.cpp

 

#include <cassert>

int main()
{
  const char c[] = "ABC";

  static_assert(sizeof(c) == 4,
    "A string literal contains one more character than it appears to have");

  assert(c[0] == 'A');
  assert(c[1] == 'B');
  assert(c[2] == 'C');
  assert(c[3] == '\0');
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml