|
I really couldn't say for sure George I'm no C expert having started out with C++.
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
No problem, Matthew!
Let us just talk in C++ context.
1.
Whether my understanding is correct -- "I think the purpose of such struct definition is, defining struct and a variable of the type (in this sample type tFoo) altogether"?
2.
Any benefits of using such type of definition?
regards,
George
|
|
|
|
|
As C Pallini said
1. Yes
2. No
"The secret of happiness is freedom, and the secret of freedom, courage."
Thucydides (B.C. 460-400)
|
|
|
|
|
Thanks Matthew!
regards,
George
|
|
|
|
|
George_George wrote: int main(){ Foo; return 0;}
That's strange...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi CPallini,
Please ignore the code in main.
I mean the code outside main.
Let me clarify my question,
1. my question is whether the below understanding is correct?
I think the purpose of such struct definition is, defining struct and a
variable of the type (in this sample type tFoo) altogether
2. any other benefits of using such type of definition?
regards,
George
|
|
|
|
|
George_George wrote: 1. my question is whether the below understanding is correct?
I think the purpose of such struct definition is, defining struct and a
variable of the type (in this sample type tFoo) altogether
Yes.
George_George wrote: 2. any other benefits of using such type of definition?
No.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Cool, CPallini!
regards,
George
|
|
|
|
|
Hi,
I'm trying to read a file which contains lines like "0.14779E+02".
A made a function which return a vector\<float\>.
std::vector\<float\> readData() {
std::vector<float> fResult;
CString dataFile = _T("C:\\d2.txt");
std::ifstream input(dataFile);
if (!input) {
MessageBox(0, L"input file cannot be opened", L"error", MB_OK);
return fResult;
}
std::string c;
float fLesen;
while (!input.eof()) {
std::getline(input, c);
fLesen = atof((const char*)(LPCTSTR)c.c_str());
fResult.push_back(fLesen);
}
input.close();
return fResult;
}</float>
Every time I'm trying to print out the float with something like that:
std::vector\<float\> lines = readData();
for (int i = 0; i < sizeof(lines); i++) {
CString a;
a.Format(_T("%f"), lines[i]);
MessageBox((LPCTSTR)a, L"error", MB_OK);
}
the variable a is emtpy.
What am I doing wrong?
Thanks in advance.
|
|
|
|
|
Opa Knack wrote: the variable a is emtpy.
Have you run this in the debugger to see why?
Opa Knack wrote: for (int i = 0; i < sizeof(lines); i++) {
sizeof gives you the size of an object, not the number of elements in the vector.
Try
for (vector <float>::size_type i = 0; i < lines.size(); i++)
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
In the debugger I can see that 'lines' has the expected values stored in float format.
It's just that the MessageBoxes are always emtpy.
|
|
|
|
|
Opa Knack wrote: In the debugger I can see that 'lines' has the expected values stored in float format.
That must not be true.
I tested your code like this:
std::vector<float> lines;
lines.push_back(1.00);
lines.push_back(2.00);
lines.push_back(3.00);
for (vector <float>::size_type i = 0; i < lines.size(); i++) {
CString a;
a.Format(_T("%f"), lines[i]);
MessageBox(a, L"error", MB_OK);
}
and it works fine.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all..
I have the string of the following format.
example: http://server/sharanu/inbox/test.jpg
Now i want to get only the string inbox and sharanu..
can anyone help me..
thank you
|
|
|
|
|
|
|
|
|
Use CString::ReverFind alongwith CString::Right or CString::Left to extract the string you want.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Search for the '/' token
(plain C)
strtok [^]?
(ATL/MFC)
CStringT::Tokenize [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CString str = "http://server/sharanu/inbox/test.jpg";
int i = str.ReverseFind('/');
str = str.Left(i);
CString sValue1 = str.Right(str.GetLength() - str.ReverseFind('/') -1);
i = str.ReverseFind('/');
str = str.Left(i);
CString sValue2 = str.Right(str.GetLength() - str.ReverseFind('/') -1);
|
|
|
|
|
sir i am new in c++.we are just doing general program in c++ like adding two numbers or nested classes.sir can you help me in network nprogramming and how to learn about other headre files and reserved variables like time_now.if you have ebook please give me the link.
|
|
|
|
|
What has to do your message with its title?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Per your post's subject, see SetLocalTime() and SetSystemTime() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
How do I go about entirely disabling a Tree View's selection? I want my app to focus on a node via the user's mouse and not by the default of the keyboard selection. Otherwise, the keyboard selection does not follow the user's mouse clicks.
|
|
|
|
|
Hi,
I have a custom ListCtrlEx which embeds a combobox in it. When the selection of combobox changes I am sending a user defined message to its parent(ListCtrlEx here) using GetParent()->SendMessage() and from ListCtrlEx again to its parent that is the dialog box(here) and handling the message there for identifying the changed row and coloumn. Now my query is if I use 2 ListCtrlEx controls in one dialog box, How do I identify from which ListCtrlEx I got the notification from?? Whihc parameter should I pack in WPARAM so I can uniquely identify the ListCtrlEx which send the message.
Any help would be appreciated.
With Reagards
Vikas
|
|
|
|