• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

vector and iterator For Fred

Started by James C. Fuller, January 23, 2017, 09:03:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

James C. Fuller

Fred,
  You need to read up on iterators also.
Range based for's are one of my favorite items.
You reduce an exe size by about 100k without including the io functions

James


#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif


#include <vector>
#include <windows.h>   
#include <tchar.h>
#include <cwctype>
using namespace std;

#pragma comment(lib,"kernel32.lib")
#pragma comment(lib,"user32.lib")
#pragma comment(lib,"gdi32.lib")

void    Pause (void);
int     _tmain (int, _TCHAR**);

void Pause(void)
{
    _tprintf(_T("\n%ls\n"), _T("Press any key to continue..."));
    _getwch();
}

int _tmain (int argc, _TCHAR** argv)
{
    wstring  ws;
    vector<wstring>  wsv;
    wsv.push_back(_T("one"));
    wsv.push_back(_T("two"));
    wsv.push_back(_T("three"));
    wsv.push_back(_T("four"));
    wsv.push_back(_T("five"));
    for (auto it : wsv)
    {
        _tprintf(_T("%ls\n"), it.c_str());
    }
     
    Pause();
}