|
I think the difference is that multiple identical elements in a multi set can serve as their own sort keys, so the keys are not unique.
|
|
|
|
|
List gives you fast insertion (O(1)), potentially slow lookup (O(n)). Multiset gives you sorted insertion, and reasonably fast lookup (both O(log n)).
But who is the king of all of these folks?
|
|
|
|
|
#include <time.h>
#include<stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <Windows.h>
void main()
{
time_t curr, bir;
struct tm *curr_tm, *bir_tm;
curr = time(NULL);
bir = time(NULL);
curr_tm = localtime(&curr);
bir_tm = localtime(&bir);
// printf("%s\n", asctime(curr_tm));
// printf("%s\n", asctime(bir_tm));
bir_tm->tm_year = 83;
bir_tm->tm_mon = 11;
bir_tm->tm_mday = 26;
printf("%s\n", asctime(curr_tm));
printf("%s\n", asctime(bir_tm));
}//main
i don't know why
printf("%s\n", asctime(curr_tm));
printf("%s\n", asctime(bir_tm));
's result is same~
definitly curr_tm, bir_tm 's paramata is different~
example)
curr_tm = localtime(&curr);
bir_tm = localtime(&bir);
firstly, i am sorry, i am from korea.
and i am not good in wriitting english so please understand~
Thank you everyone~
|
|
|
|
|
curr_tm = localtime(&curr);
bir_tm = localtime(&bir);
from the MSDN[^]:
gmtime, mktime, and localtime all use a single statically allocated tm structure for the conversion. Each call to one of these routines destroys the result of the previous call.
in other words, curr_tm and bir_tm have the same value because they are pointing at the same structure, because localtime returns the same structure each time you call it.
|
|
|
|
|
Chris Losinger wrote: gmtime, mktime, and localtime all use a single statically allocated tm structure for the conversion. Each call to one of these routines destroys the result of the previous call.
Though the assertion are in fact related, in the OP particular case, IMHO the
Chris Losinger wrote: use a single statically allocated tm structure
is more relevant than
Chris Losinger wrote: Each call to one of these routines destroys the result of the previous call .
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.
[my articles]
|
|
|
|
|
From localtime documentation [^]
gmtime, mktime, and localtime all use a single statically allocated tm structure for the conversion. Each call to one of these routines destroys the result of the previous call.
hence both curr_tm and bir_tm point to the same static struct .
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.
[my articles]
|
|
|
|
|
I have the following class member function:
void CTreeGraft::DetermineOverlay(OptionType WhichOption) {
double Temp1;
double Temp2;
Temp1 = 0.0;
Temp2 = 0.0;
for(int col = 0; col < 2; col++) {
int Limit = static_cast<int>(Graft[col].size()) - 1;
for(int row = 1; row < Limit; row++) {
Temp1 = Graft[col+1][row+1]->GetUnderlyingPrice();
Temp2 = Graft[col+1][row+3]->GetUnderlyingPrice();
switch(WhichOption){
case 0:
if (m_dStrike < Temp1 && m_dStrike > Temp2) {
FineMesh[col].push_back(Graft[col][row]);
}
break;
case 1:
if (m_dStrike > Temp1 && m_dStrike < Temp2) {
FineMesh[col].push_back(Graft[col][row]);
}
break;
}
}
}
}
I instantiate a new member of the class and call this function. The app bombs. On debugging, the VS 2005 debugger is telling me that variable Temp1 "needs a stack frame" and variable Temp2 cannot be found. Furthermore, when it gets to the for loop, the index variables don't initialize properly at all. Is there something obvious I'm missing here? It's very strange behaviour...
Oh man am I tired. I glanced up and noticed the Solution Configuration was set to "release" instead of "debug".
modified on Thursday, January 31, 2008 8:19:54 AM
|
|
|
|
|
73Zeppelin wrote: The app bombs.
73Zeppelin wrote: int Limit = static_cast<int>(Graft[col].size()) - 1;
for(int row = 1; row < Limit; row++) {
Temp1 = Graft[col+1][row+1]->GetUnderlyingPrice();
Hint: the above three lines give the error definition.
Temp2 = Graft[col+1][row+3]->GetUnderlyingPrice();
row+1 is bad, row+3 is evil.
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.
[my articles]
|
|
|
|
|
CPallini wrote: Hint: the above three lines give the error definition.
Temp2 = Graft[col+1][row+3]->GetUnderlyingPrice();
row+1 is bad, row+3 is evil.
Actually, I guarantee the row length in another function so row+3 is always okay.
I found the problem - I had the build configured to "release" instead of "debug".
|
|
|
|
|
73Zeppelin wrote: Actually, I guarantee the row length in another function so row+3 is always okay.
Well, of course you're right. But don't blame me if I don't like such (IMHO, at least) misleading code.
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.
[my articles]
|
|
|
|
|
CPallini wrote: Well, of course you're right. But don't blame me if I don't like such (IMHO, at least) misleading code.
I know it's messy - that's the nature of the project. I have a coarse lattice structure (like a grid) and over the coarse structure I overlay a finer mesh (a grid with higher resolution). Each column of the grid varies in length and sometimes I have to compare rows of different columns that are several integers (i.e. 3) apart. It's a complicated calculation and I make alot of effort to ensure that I don't exceed array bounds.
It's someone else's algorithm, but I have to implement it - I have no choice. I have to compare this method to my own method (which is much, much simpler ).
|
|
|
|
|
Pardon, I gave a second look at your code and noticed the col+1 that makes indeed a big difference, my bad .
BTW Physics, I suppose.
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.
[my articles]
|
|
|
|
|
CPallini wrote: Pardon, I gave a second look at your code and noticed the col+1 that makes indeed a big difference, my bad
No problem. I had to strike it all out once I found the error.
CPallini wrote: BTW Physics, I suppose.
No, in this case it's a financial calculation.
|
|
|
|
|
Hi All,
I'm trying to compile a project, which is in VC++.Net using Visual Studio 2005. In Visual VC++6.0 there is an option 'Export Makefile' under the Project menu, for creating the makefile for a project. I'm using a custom build application, which will scan for all the .mak file and try to build the components.
As a part of migration to VC++.Net, I need to generate the makefiles for the projects. But the menu option for the same is not available in .Net.
I tried creating a new project in VC.Net, but ultimatly went in vain. I dont what option I should provide. I am new to .Net.
Kindly let anyone know how to create a makefile in VC.Net?
thanks and regards,
Rajesh
|
|
|
|
|
Wasn't support for makefiles removed in VC.net? I think you have to use a command line option like "vcbuild". There is more information here[^].
Alternatively, this[^] may be of use.
|
|
|
|
|
He wanted to export the settings (to get a mak-File).
Greetings from Germany
|
|
|
|
|
KarstenK wrote: He wanted to export the settings (to get a mak-File)
Did I not understand his question? I think he wanted to generate a c++ makefile, but there is no support for makefiles in VC.net (or if there is I am not aware of it).
|
|
|
|
|
Hi KarstenK,
I'm looking for a Microsoft Developer Studio Generated NMAKE File. There was an option to generate the .mak file in Visual C++ 6.0 Version [Project->Export MakeFile], that option is not available in Visual Studio.Net. I'm looking for that.
Please share if you know how to generate .
thanks and regards,
Rajesh
|
|
|
|
|
Rajesh_Parameswaran wrote: i KarstenK,
I'm looking for a Microsoft Developer Studio Generated NMAKE File. There was an option to generate the .mak file in Visual C++ 6.0 Version [Project->Export MakeFile], that option is not available in Visual Studio.Net. I'm looking for that.
Please share if you know how to generate .
I'm 90% sure you can't do this in VC.net
|
|
|
|
|
I am using a picture box and a static control. I am trying to render the video on the picture box so whenever the video is render the picture box gets painted . I have placed a static control on top of the picture box and I have painted the frame of the static control. My problem is whenever the picture box is painted during render the video my static control also gets painted and the painted frame is washed out. I want the painted frame to remain the same even the picture box is painted.I getting flickers if i repaint the static control.
|
|
|
|
|
I didnt underatsn why u r keeping the static control on top of the picture box
but the way u can make static control trasparent is.. over ride the OnCtlColor handlr and do the followin
HBRUSH UrDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hBr = CDialog::OnCtlColor( pDC, pWnd, nCtlColor );
if (nCtlColor == CTLCOLOR_DLG || nCtlColor == CTLCOLOR_STATIC)
{
//hBr = m_BkGndBrush;
pDC->SetBkMode(TRANSPARENT);
}
return hBr;
}
|
|
|
|
|
Hi, I had a problem in printing a String class string to a file where I had declared:
string str1[10], str2[10];
And in str1[6] and str2[6] has the values which I wanna store the values by writing them to a txt file using the format:
// write to apsignal.txt
newfile= fopen("apsignal.txt","w");
if (newfile==NULL)
{
cout<<"Error opening apsignal.txt";
fclose(newfile);
return -1;
}
//Print to file with the signal strengths and corresponding clientIDs.
fprintf(newfile,"1" " %s" " %s", &str1[6], &str2[6] );
fclose(newfile);
however, it seems like it cannot print out the values in the txt file as it is a string class? So I was wondering if anyone can give me other alternatives to write the values into this text file?
Thanks! I had put in the coding below and pls take a look at the apsignal.txt and you will know what I mean. Thanks for any help!
ap1.txt:
Variable = .iso.org.dod.internet.private.enterprises.9.9.273.1.3.1.1.3.1.8.105.118.116.108.95.97.112.49.0.32.166.80.182.220<br />
Value = Integer32 -38<br />
<br />
End of MIB subtree.<br />
ap2.txt:
Variable = .iso.org.dod.internet.private.enterprises.9.9.273.1.3.1.1.3.1.8.105.118.116.108.95.97.112.49.0.32.166.80.182.220<br />
Value = Integer32 -40<br />
End of MIB subtree.<br />
apsignal.txt:
1 ÌÌÌÌa<I ÌÌÌÌÑ_I
The program:
#include <stdio.h><br />
#include <stdlib.h><br />
#include <cstdio><br />
#include <conio.h><br />
#include <time.h><br />
#include <fstream><br />
#include <iostream><br />
#include <windows.h><br />
#include <string><br />
#include "carpark.h"<br />
#include <cstdlib><br />
<br />
<br />
int temp (void);<br />
int output(void);<br />
<br />
using namespace std;<br />
<br />
int clientID = 1;<br />
int row,col;<br />
<br />
<br />
float signalstrength[2][2];<br />
int main(void)<br />
{<br />
int count=1;<br />
while(count<20)<br />
{<br />
count++;<br />
<br />
output();<br />
<br />
Sleep(1);<br />
<br />
}<br />
<br />
<br />
return 0;<br />
<br />
}<br />
<br />
<br />
int temp(void)<br />
{<br />
<br />
<br />
system("snmputil walk 192.168.200.91 public .1.3.6.1.4.1.9.9.273.1.3.1.1.3 > ap1.txt");<br />
<br />
system("snmputil walk 192.168.200.92 public .1.3.6.1.4.1.9.9.273.1.3.1.1.3 > ap2.txt");<br />
<br />
<br />
return 0;<br />
<br />
<br />
<br />
<br />
}<br />
<br />
<br />
int output(void)<br />
{<br />
string str1[10], str2[10];<br />
float num1,num2;<br />
FILE *newfile; <br />
<br />
ifstream ap1File("ap1.txt");<br />
if(! ap1File)<br />
{<br />
cout<<"Error opening ap1.txt!"<<endl;<br />
ap1File.close();<br />
return -1;<br />
}<br />
<br />
while(! ap1File.eof())<br />
{<br />
for (row = 0; row<8; row++)<br />
{<br />
<br />
ap1File>>str1[row];<br />
<br />
}<br />
cout<<str1[6]<<endl; <br />
}<br />
ap1File.close();<br />
<br />
ifstream ap2File("ap2.txt");<br />
<br />
if(! ap2File)<br />
{<br />
cout<<"Error opening ap2.txt!"<<endl;<br />
ap2File.close();<br />
return -1;<br />
}<br />
<br />
while(!ap2File.eof())<br />
{<br />
for (row=0;row<8;row++)<br />
{<br />
ap2File>>str2[row];<br />
<br />
<br />
}
<br />
<br />
}<br />
ap2File.close();<br />
cout<<str2[6]<<endl;<br />
<br />
newfile= fopen("apsignal.txt","w");<br />
if (newfile==NULL)<br />
{<br />
cout<<"Error opening apsignal.txt";<br />
fclose(newfile);<br />
return -1;<br />
}<br />
<br />
<br />
fprintf(newfile,"1" " %s" " %s", &str1[6], &str2[6] );<br />
fclose(newfile);<br />
<br />
<br />
cout <<"complete output()"<<endl;<br />
<br />
return 0;<br />
}
|
|
|
|
|
1/ You don't need that amount of code.
2/ Use pre tag, instead of code.
By doing string str [16] , you made 16 separate strings, not one string 16 characters long.
You have two choices...
a/ Use chars, and be class C code.
char str1 [16], str2 [16];
strcpy (str1, "hello");
strcpy (str2, "world");
newfile= fopen("apsignal.txt","w");
fprintf (newfile, "Test: %s %s\n", str1, str2);
b/ Use the string class.
std::string str1, str2;
str1 = "hello";
str2 = "world";
newfile= fopen("apsignal.txt","w");
fprintf (newfile, "Test: %s %s\n", str1.c_str(), str2.c_str());
That's from memory - it might be cstr instead of c_str.
I hope that helps,
Iain.
|
|
|
|
|
Sorry for the late reply...well...I've followed the way u coded by changing the fprintf to fprintf (newfile, "Test: %s %s\n", str1.c_str(), str2.c_str()); but it doesn't seem to work. Is there anything I need to import or I've left it out?
|
|
|
|
|
(1)
Cabomba wrote: fprintf(newfile,"1" " %s" " %s", &str1[6], &str2[6] );
Sould probably be
fprintf(newfile, "1 %s %s", str1[6].c_str(), str2[6].c_str() );
(2) Why don't you use ofstream class to write to file?
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.
[my articles]
|
|
|
|
|