|
Hi-- I've been banging my head trying to solve this problem. Of course I'm a self trained pseudo programmer who just started to use STL. I have a huge file with 10 million entries that are paired, say 1 , 8 ; 1 , 5; 1 , 3; 2 , 0; 2 , 4; 3 , 0; 3 , 8; etc... They are stored as a two dimensional array of 10 million rows and two columns... you get the idea of the data. I need to find the records in the file that have one and only one of the tags in the first entry of the pair and put the second in another vector file in the order found. For example, if I need records with the tag 2, I'll create a vector with 0 and 4. I suppose I need to use a multimap, but do not know how to read the file and then store the results in a vector. Right now I have this simple code:
typedef vector<double> DVECTOR;
DVECTOR FDV;
int tag;
double FD;
int id = 3;
int idp = id + 1;
while(tag != idp)
{
GetData >> tag >> FD;
cout << tag << " " << FD << endl ;
if(tag == id)
FDV.push_back(FD);
}
This does what I want by scaning the file from the begining until it finds the target value and reads all the entries with such value. If the number is close to the first entry, cool it's fast, but if it is near the end it will take a long time (big program repeated many times...). The question is, would the multimap work better and faster to do the same task? If so... how do I do it???
Thank you so much!
Carlos
|
|
|
|
|
Hello! I wanna develop a Http client program! I use three classes (CInternetSession, ChttpConnection, Chttpfile) for doing this! Now I can connect to my web LAN server, send request, and get the response. However, when it finished, I use functions Chttpfile::Close() ChttpConnection::Close(), and CInternetSession::Close() to disconnect to the server. But It doesn't work at all. I also "delete" theses three classes. But the connection still exists until the server disconnect this connection, or I shutdown the program. Is there any solution to disconnect it? Thank you very much!
|
|
|
|
|
I am using cryptlib.lib in my VC7.0 project. I am getting following linker error .. please help to resolve the same
cryptlib.lib(cryptlib.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) private: void __thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::_Eos(unsigned int)" (__imp_?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z) referenced in function "public: __thiscall CryptoPP::BufferedTransformation::Err::Err(enum CryptoPP::BufferedTransformation::ErrorType,class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > const &)" (??0Err@BufferedTransformation@CryptoPP@@QAE@W4ErrorType@12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
Sandeep Naik
|
|
|
|
|
I'm having trouble integrating MySpell into my application.
I was following the example given by Steve King (Spell Edit) but i keep getting compilation errors. Any suggestions?????????/
|
|
|
|
|
rjnl wrote:
...i keep getting compilation errors
I'm having a hard time seeing those errors. Could you move your monitor a bit closer? Just kidding...
Exactly what (compiler) errors are you getting?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
my problem starts when i include the SpellEdit class into my project.
I get errors like undeclared identifiers
|
|
|
|
|
rjnl wrote:
I get errors like undeclared identifiers
Which is what happens when the compiler encounters a symbol that has not yet been defined.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/c2065.asp
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I'm doing a project where i'm developing a spell checker for our local language. It is to be as an add-in for MS Word. I'm Using MySpell for the spell checking.
I also want to customize the menus so that the names are in our local language.
Is it possible? Where can i get more information? I searched Microsoft's site but most of the things were too complicated for me (I'm just a beginner at the moment).
|
|
|
|
|
I have written a program using Visual C++. Are there any books guide me through creating a skin for my project so you do not see that blue exe file? Also are there any books that could guide me through having a tool bar across the top so the person will have the dropdown screen option of saving, save as, print etc. across the top? If all of this can be done using MFC is there a book that can show me how to accomplish this?
|
|
|
|
|
There are many articles about these topics here on CP.
Don't try it, just do it!
|
|
|
|
|
how would i select a number between 2 numbers? say between 0 and 40, numbers will vary, and keep selecting a unique number till it got them all but none repeated?
Any helps always apprecieated
shotgun
|
|
|
|
|
An easy way would be creating a dynamic-size array, put all the numbers in there, choose one, remove it from the array and then choose another one and so on....
Example:
Number 40-44
Put 40, 41, 42, 43, 44 in an array. The indexes will be 0, 1, 2, 3, 4.
Now get a random number between 0 and 4, fetch the number with that index from the array and remove it then.
The next round you get a random number between 0 and 3, and so on....
Don't try it, just do it!
|
|
|
|
|
...um thanks for the reply, if I'm going to get a random number between 0 and 4, why not just go for the gusto and get a random between 40 - 44, and save the in between and the array?
shotgun
|
|
|
|
|
You need the array to keep track of what numbers you've used. Most random number generators don't guarantee that you'll get a unique sequence. For example, you could get 0,5,12,3,4,5,...
Software Zen: delete this;
|
|
|
|
|
Hi All
This is a basic question but am I correct in saying that the difference between Build, Rebuild and Clean when building is as follows:
Build - Creates a pre-compiled file from scratch recreating all the intermediate files.
Rebuild - Just updates those intermediate files that require changes since last build.
Clean - Deletes all the intermediate files.
Regards
Jeremy
|
|
|
|
|
JSadleir wrote:
Clean - Deletes all the intermediate files. and also the output files!
Rebuild: Same as Clean, but a new Build is launched after it.
Build: Compile all changed files and link.
Build doesn't say anything about pre-compiled header files.
Don't try it, just do it!
|
|
|
|
|
I've been trying to make Visual Studio show refences to DLL function calls by name in the debugger in Disassembly just like in W32Dasm, but I don't find an option for it anywhere. Can anybody help?
|
|
|
|
|
As far as I know it is not (yet) possible to list references in Visual Studio.
Don't try it, just do it!
|
|
|
|
|
I want to restart the process using the information of the previoulsy suspended process i.e. baseAddr,region,state, allocationbase, e.t.c but now i am stuck. It does not start even though i provided info from the file where it has to read from.
my restart function is below here. What am i missing...
<br />
<br />
case 6:
<br />
lpBaseAddress = 0;<br />
hProcess = mbi.BaseAddress;<br />
SetThreadContext( <br />
hThread, <br />
lpContext <br />
);<br />
<br />
<br />
if (OpenProcess(dwDesiredAccess, bInheritHandle,dwThreadId, GetlastError()) == NULL) <br />
printf("Unable to open thread\n");<br />
<br />
SuspendThread(pi.hThread);
<br />
fp = fopen("info.bin","r");<br />
if( fp )<br />
nSize = 10000;
lpBuffer = 0;
<br />
WriteProcessMemory(<br />
dwDesiredAccess,
lpBaseAddress,
lpBuffer,
nSize,
lpNumberOfBytesWritten
);<br />
<br />
printf("Numbers of bytes writen: ",lpNumberOfBytesWritten);<br />
<br />
ResumeThread(dwDesiredAccess);
GetLastError();<br />
<br />
break;<br />
<br />
oam
|
|
|
|
|
I have a SDI application in which I need to be able to allow the user to interact with controls within a dockable control bar at all times. At times, the app displays modal dialogs. During the modal dialog display, I still need the user to be able to interact with the control bar. Does anyone have any suggestions as to whether or not it is possible to have a modal dialog displayed while having certain pieces of the main app still active?
--
Art Poley
New River Kinematics
309 McLaws Circle
Suite B
Williamsburg, VA 23185
www.kinematics.com
|
|
|
|
|
It isn't, by definition.
From Here[^]
When creating the modal dialog box, the system makes it the active window. The dialog box remains active until the dialog box procedure calls the EndDialog function or the system activates a window in another application. Neither the user nor the application can make the owner window active until the modal dialog box is destroyed.
What you need is a "modeless" dialog.
Steve T
|
|
|
|
|
Unfortunately, I don't have the luxury of making every dialog modeless. I have, however, figured out a way to defeat the disabling of the parent (EnableWindow) that the modal dialog does. I've overridden the ON_WM_CANCELMODE and ON_WM_ACTIVATE callbacks within the mainframe. Doing so, I know when a modal dialog is invoked, since the OnCancelMode is invoked. Then when the OnActivate is invoked, letting me know the frame has become inactive, I can EnableWindow(TRUE) the mainframe and then the modal dialog behaves like a modeless. But, I don't want the entire app to be accessible by the user... just the items within the controlbar. Thus, I'm looking to see if anyone has figured out a nice way to work around the issue.
|
|
|
|
|
Hi all,
I'm developing an extension to Explorer on windows 2000 and I want to insert an icon in my option of the context menu. Everything is already working but the icon. Only to clarify, I want to do exactly the same WinZip does on the context menu (insert an option with an icon). Does anybody has an example of how I do this?
Thanks,
Luiz.
|
|
|
|
|
|
I created a template class like
template <class T><br />
class CProtectedBuffer <br />
{<br />
public: <br />
int DeQueue(T &cElement);<br />
int Enqueue(const T &newElem);<br />
CProtectedBuffer();<br />
virtual ~CProtectedBuffer();<br />
private :<br />
void Enter();<br />
void Leave();<br />
CRITICAL_SECTION cs ; <br />
T t[MAX_PBUF_SIZE] ; <br />
int objCount;<br />
<br />
int headIndex ;<br />
int tailIndex;<br />
int size ; <br />
<br />
};
Now I want to reuse this template to store objects of a custom class which is :
<br />
<br />
class RcvBuffer{<br />
<br />
public : <br />
RcvBuffer():toolName(""),buffer(0),packetSize(0)<br />
{<br />
}; <br />
~RcvBuffer(){<br />
if(buffer){<br />
delete buffer ;<br />
buffer = 0 ; <br />
}<br />
};<br />
<br />
const RcvBuffer& operator=(const RcvBuffer &rhs)<br />
{<br />
if(buffer){<br />
delete [] buffer ; <br />
buffer = 0;<br />
}<br />
int sz = rhs.GetPacketSize() ; <br />
if(sz){<br />
toolName = rhs.GetToolName();<br />
packetSize = sz ; <br />
buffer = new UINT8[sz] ;<br />
for(int i=0;i<sz;i++){<br />
buffer[i] = rhs.BufferValueAt(i);<br />
}<br />
} <br />
return (*this); <br />
<br />
};<br />
<br />
const int GetPacketSize() const <br />
{<br />
return packetSize ; <br />
};<br />
<br />
const UINT8 BufferValueAt(const int &index) const <br />
{<br />
if(index<packetSize ){<br />
return buffer[index];<br />
}<br />
return 0;<br />
};<br />
const string& GetToolName() const <br />
{<br />
return toolName;<br />
};<br />
<br />
int Clear() <br />
{<br />
if(buffer){<br />
delete buffer ;<br />
buffer = 0 ; <br />
}<br />
packetSize = 0; <br />
toolName ="";<br />
<br />
};<br />
private : <br />
string toolName ;<br />
UINT8 *buffer ;<br />
int packetSize ; <br />
};
Here is the part implementation of the template class
template <class T><br />
CProtectedBuffer<T>::CProtectedBuffer():headIndex(0),tailIndex(0),size(0)<br />
{<br />
::InitializeCriticalSection(&cs);<br />
<br />
<br />
<br />
}<br />
template <class T><br />
CProtectedBuffer<T>::~CProtectedBuffer()<br />
{<br />
..<br />
..<br />
..<br />
}
I am using the code like
CProtectedBuffer<RcvBuffer > bBuff ;
I am getting the following linker errors :
linking...<br />
<small>EepromServer.obj : error LNK2001: unresolved external symbol "public: __thiscall CProtectedBuffer<class RcvBuffer>::CProtectedBuffer<class RcvBuffer>(void)" (??0?$CProtectedBuffer@VRcvBuffer@@@@QAE@XZ)<br />
EepromServer.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CProtectedBuffer<class RcvBuffer>::~CProtectedBuffer<class RcvBuffer>(void)" (??1?$CProtectedBuffer@VRcvBuffer@@@@UAE@XZ)<br />
Debug/EepromServer.exe : fatal error LNK1120: 2 unresolved externals<br />
Error executing link.exe.</small>
If someone can advise
|
|
|
|