Click here to Skip to main content
15,884,298 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
AnswerRe: Changing the style of a DateTimePicker Pin
User 74293387-Jan-11 12:17
professionalUser 74293387-Jan-11 12:17 
GeneralRe: Changing the style of a DateTimePicker Pin
Jim Crafton7-Jan-11 14:36
Jim Crafton7-Jan-11 14:36 
QuestionNeed to pass private member of a Class as a argument to function of another class and get modified there Pin
ptr_Electron4-Jan-11 21:38
ptr_Electron4-Jan-11 21:38 
AnswerRe: Need to pass private member of a Class as a argument to function of another class and get modified there Pin
Nuri Ismail4-Jan-11 21:49
Nuri Ismail4-Jan-11 21:49 
QuestionHow to get the delagate value via property Pin
ptr_Electron4-Jan-11 1:09
ptr_Electron4-Jan-11 1:09 
AnswerRe: How to get the delagate value via property Pin
Espen Harlinn4-Jan-11 11:01
professionalEspen Harlinn4-Jan-11 11:01 
QuestionFinding index of an array element?? Pin
Raza56801-Jan-11 16:25
Raza56801-Jan-11 16:25 
AnswerRe: Finding index of an array element?? Pin
Nuri Ismail3-Jan-11 1:57
Nuri Ismail3-Jan-11 1:57 
You can use a combination of std::find[^] and std::distance[^] in order to search for an element and get its index.
The standard algorithms will work both on standard containers and arrays. Here is a quick example for you, which demonstrates the usage of std::find and std::distance with std::vector and regular array:

    // Prepare the test array
int arr[] = {31, 53, 7, 9, 45, 20};
const int size = (sizeof(arr) / sizeof(arr[0]));
int* arr_beg = arr;
int* arr_end = arr + size;

// Prepare the test vector
std::vector<int> vec;
std::copy(arr, arr + size, std::back_inserter(vec));

// Search the array
std::cout << "\n Searching the array for element with value 7...";
int* res1 = std::find(arr, arr + size, 7);
if(res1 != arr_end)
    std::cout << "\n The element is found at index: " << std::distance(arr_beg, res1);
else
    std::cout << "\n The element is not found";

std::cout << "\n Searching the array for element with value 8...";
int* res2 = std::find(arr, arr + size, 8);
if(res2 != arr_end)
        std::cout << "\n The element is found at index: " << std::distance(arr_beg, res2);
else
    std::cout << "\n The element is not found";


// Search the vector
std::cout << "\n Searching the vector for element with value 7...";
std::vector<int>::iterator it1 = std::find(vec.begin(), vec.end(), 7);
if(it1 != vec.end())
    std::cout << "\n The element is found at index: " << std::distance(vec.begin(), it1);
else
    std::cout << "\n The element is not found";

std::cout << "\n Searching the vector for element with value 8...";
std::vector<int>::iterator it2 = std::find(vec.begin(), vec.end(), 8);
if(it2 != vec.end())
    std::cout << "\n The element is found at index: " << std::distance(vec.begin(), it2);
else
    std::cout << "\n The element is not found";


I hope this helps. Smile | :)
AnswerRe: Finding index of an array element?? Pin
jk chan4-Jan-11 5:46
jk chan4-Jan-11 5:46 
QuestionBasic string help -- Did I step into the Twilight Zone? Pin
Xpnctoc29-Dec-10 11:13
Xpnctoc29-Dec-10 11:13 
AnswerRe: Basic string help -- Did I step into the Twilight Zone? Pin
jk chan29-Dec-10 21:08
jk chan29-Dec-10 21:08 
AnswerRe: Basic string help -- Did I step into the Twilight Zone? Pin
Stephen Hewitt30-Dec-10 3:14
Stephen Hewitt30-Dec-10 3:14 
AnswerRe: Basic string help -- Did I step into the Twilight Zone? Pin
Xpnctoc30-Dec-10 6:14
Xpnctoc30-Dec-10 6:14 
QuestionCCommand execute stored procedure is failed! Pin
sergey-ka28-Dec-10 4:08
sergey-ka28-Dec-10 4:08 
AnswerRe: CCommand execute stored procedure is failed! Pin
jerry_ch3-Oct-11 20:42
jerry_ch3-Oct-11 20:42 
QuestionOLE DB Provider with BOOKMARK capability Pin
RezaAsAdi22-Dec-10 8:53
RezaAsAdi22-Dec-10 8:53 
QuestionProblem in registering a 32 bit C++ COM/ATL Service on Windows7 64 bit? Pin
Aseem Sharma21-Dec-10 19:25
Aseem Sharma21-Dec-10 19:25 
AnswerRe: Problem in registering a 32 bit C++ COM/ATL Service on Windows7 64 bit? Pin
pacchij27-Dec-10 11:25
pacchij27-Dec-10 11:25 
GeneralRe: Problem in registering a 32 bit C++ COM/ATL Service on Windows7 64 bit? Pin
Aseem Sharma28-Dec-10 19:32
Aseem Sharma28-Dec-10 19:32 
GeneralRe: Problem in registering a 32 bit C++ COM/ATL Service on Windows7 64 bit? Pin
pacchij29-Dec-10 12:11
pacchij29-Dec-10 12:11 
Questioni have a quesstion about gcc warning Pin
lxlenovostar21-Dec-10 6:00
lxlenovostar21-Dec-10 6:00 
AnswerRe: i have a quesstion about gcc warning Pin
Richard MacCutchan21-Dec-10 8:23
mveRichard MacCutchan21-Dec-10 8:23 
QuestionPress a key using virtual key with SendInput Pin
vtalau20-Dec-10 23:37
vtalau20-Dec-10 23:37 
QuestionI have a question about the adobe reader Pin
quickzhao322316-Dec-10 22:42
quickzhao322316-Dec-10 22:42 
AnswerRe: I have a question about the adobe reader Pin
mav@octaval17-Dec-10 0:07
mav@octaval17-Dec-10 0:07 

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.