Click here to Skip to main content
15,891,316 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
David Crow24-Jul-08 6:05
David Crow24-Jul-08 6:05 
AnswerRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
NiceNaidu24-Jul-08 6:13
NiceNaidu24-Jul-08 6:13 
GeneralRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
David Crow24-Jul-08 6:16
David Crow24-Jul-08 6:16 
GeneralRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
NiceNaidu24-Jul-08 6:26
NiceNaidu24-Jul-08 6:26 
GeneralRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
David Crow24-Jul-08 7:39
David Crow24-Jul-08 7:39 
JokeRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
Maximilien24-Jul-08 8:22
Maximilien24-Jul-08 8:22 
GeneralRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
NiceNaidu24-Jul-08 18:59
NiceNaidu24-Jul-08 18:59 
AnswerRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
Stephen Hewitt24-Jul-08 15:19
Stephen Hewitt24-Jul-08 15:19 
Try something like this:
// VanillaConsole.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
 
void main()
{
	typedef vector<string> words_t;
	words_t words;
 
	// Add some sample words.
	words.push_back("1");
	words.push_back("1");
	words.push_back("2");
	words.push_back("3");
	words.push_back("4");
	words.push_back("4");
 
	// Here's the magic.
	words_t::iterator i = words.begin();
	words_t::iterator e = words.end();
	sort(i, e);
	for (i=adjacent_find(i, e); i!=e; i=adjacent_find(i, e))
	{
		cout << *i << endl;
		i = find_if(i+1, e, bind2nd(not_equal_to<string>(), *i));
	}
}


Steve

GeneralRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
NiceNaidu24-Jul-08 18:55
NiceNaidu24-Jul-08 18:55 
GeneralRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
Stephen Hewitt24-Jul-08 19:02
Stephen Hewitt24-Jul-08 19:02 
GeneralRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
NiceNaidu24-Jul-08 22:56
NiceNaidu24-Jul-08 22:56 
GeneralRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
Stephen Hewitt27-Jul-08 14:08
Stephen Hewitt27-Jul-08 14:08 
GeneralRe: logic: Find out whether a string has duplicates in a string array (pure C++,no MFC supported) Pin
NiceNaidu4-Aug-08 4:40
NiceNaidu4-Aug-08 4:40 
Questionhow to use the vector in vc++.net 2005 Pin
Anamika200524-Jul-08 2:00
Anamika200524-Jul-08 2:00 
AnswerRe: how to use the vector in vc++.net 2005 Pin
Matthew Faithfull24-Jul-08 2:10
Matthew Faithfull24-Jul-08 2:10 
GeneralRe: how to use the vector in vc++.net 2005 Pin
Anamika200524-Jul-08 3:01
Anamika200524-Jul-08 3:01 
GeneralRe: how to use the vector in vc++.net 2005 Pin
Matthew Faithfull24-Jul-08 3:44
Matthew Faithfull24-Jul-08 3:44 
Questionpossible to override [] operator? Pin
Sauce!24-Jul-08 0:26
Sauce!24-Jul-08 0:26 
AnswerRe: possible to override [] operator? Pin
Matthew Faithfull24-Jul-08 0:30
Matthew Faithfull24-Jul-08 0:30 
GeneralRe: possible to override [] operator? Pin
Sauce!24-Jul-08 0:33
Sauce!24-Jul-08 0:33 
AnswerRe: possible to override [] operator? Pin
Cedric Moonen24-Jul-08 0:52
Cedric Moonen24-Jul-08 0:52 
GeneralRe: possible to override [] operator? Pin
Sauce!24-Jul-08 1:07
Sauce!24-Jul-08 1:07 
GeneralRe: possible to override [] operator? Pin
Cedric Moonen24-Jul-08 7:40
Cedric Moonen24-Jul-08 7:40 
GeneralRe: possible to override [] operator? Pin
Sauce!24-Jul-08 22:39
Sauce!24-Jul-08 22:39 
QuestionAdding buttons and scrollbar to a groupbox in MFC Pin
hari_honey24-Jul-08 0:25
hari_honey24-Jul-08 0:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.