Commit 693b4cd2 authored by Rachel Wil Sha Singh's avatar Rachel Wil Sha Singh 💬
Browse files

STL Vector example code

parent a59c266c
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="STL vector" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/STL vector" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/STL vector" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
// Vector
vector<string> nameList;
// Add to vector
nameList.push_back( "Bob1" );
nameList.push_back( "Bob2" );
nameList.push_back( "Bob3" );
nameList.push_back( "Bob4" );
// Access element
cout << nameList[0] << endl;
cout << nameList.size() << endl;
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment