Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) StdStrcmpExample1

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppStdStrcmpExample1/CppStdStrcmpExample1.pro

 

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

 

 

 

 

 

./CppStdStrcmpExample1/main.cpp

 

#include <cassert>
#include <cstring>

int main()
{
  const char a[] = "Aaron A. Aardvark";
  const char b[] = "Zachary Zziiz";

  assert(std::strcmp(a,a) ==  0 && "first == second yield   0");
  assert(std::strcmp(a,b) == -1 && "first  < second yields -1");
  assert(std::strcmp(b,a) ==  1 && "second < first  yields  1");
  assert(std::strcmp(b,b) ==  0 && "first == second yields  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