Hello everyone!
I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.
I have a global static variable of type
static wchar_t d_sondi[50]
, and a global static vector defined as
static vector<wchar_t*> vDubinaSonde;
. In my GUI, a button was added that should fill vector with text from edit control.
By checking the size of the vector, I have determined that fill works fine, but output of strings is not good.
When I output vectors content, it outputs last entry, instead of all elements.
Text is retreived by using GetDlgItemText();
Here is the handler for button control:
case IDC_BUTTON9:
{
if( tip_gte == L"'Литогеотермална енергија'")
{
memset( &n_sondi, '\0', sizeof(n_sondi) );
GetDlgItemText( hwnd, IDC_EDIT15, n_sondi, 50 );
if( !wcslen(n_sondi) )
wsprintf( n_sondi, L"%s", L"0" );
memset( &d_sondi, '\0', sizeof(d_sondi) );
GetDlgItemText( hwnd, IDC_EDIT16, d_sondi, 50 );
if( !wcslen(d_sondi) )
wsprintf( d_sondi, L"%s", L"0" );
vBrojSonde.push_back(n_sondi);
vDubinaSonde.push_back(d_sondi);
for( vector<wchar_t*>::size_type in = 0;
in < vDubinaSonde.size(); in ++ )
MessageBox( hwnd, vDubinaSonde[in], L"", MB_OK );
}
}
break;
I have tried this code in console, and it works the way it should :
#include <iostream>
#include <vector>
using std::vector;
using std::endl;
using std::wcout;
int main()
{
vector<wchar_t*> v;
wchar_t test[4] = L"123";
v.push_back(test);
v.push_back(test);
v.push_back(test);
for( vector<wchar_t*>::size_type i = 0; i < v.size(); i++ )
wcout << v[i] << endl;
return 0;
}
So why does it display only the last value in the vector, in the above code for button handler?
I work in MS Visual Studio Express 2008, on Windows XP, in C++, using pure WIN32 API.
If any other information is required ( source code or something similar ), please ask for it, I will more than gladly supply it.