Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) StdVectorExample1

 

Cpp98Qt CreatorLubuntuWindows

 

std::vector example 1: basics is a std::vector example that demonstrates writing to and reading from a std::vector

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppStdVectorExample1/CppStdVectorExample1.pro

 

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

 

 

 

 

 

./CppStdVectorExample1/main.cpp

 

#include <iostream>
#include <vector>

int main()
{
  const std::size_t size = 10;
  std::vector<int> v(size);
  for (int i=0; i!=size; ++i)
  {
    v[i]=i; //Store in v
    std::cout << v[i] << std::endl; //Read from v
  }
}

/* Screen output:

0
1
2
3
4
5
6
7
8
9
Press <RETURN> to close this window...

*/

 

 

 

 

 

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