|
alright;
now i need to read a sequence of numbers from a file and then store them in a linked list.
thanks
|
|
|
|
|
Hi.
I am experience recursive random number. It seems that only happens when rand() is in a loop.
For example:
--------------------------------------
srand(time(0));
int tempNUM = 0;
for (int i = 0; i < 1000; ++i)
{
tempNUM = 1 + rand() %9999999;
cout << tempNUM + 1;
}
--------------------------------------
In a program I am working on with a similar code to the one above, the program generates duplicates random numbers. It seems I have to *wait* one second clock until it generates a something new. Does that have something to do with time(0)?
I would like something that can generate a completely random number almost instantaneously even when it is in a for loop like the one above.
Thanks,
Kuphryn
|
|
|
|
|
If you read the time() docs, you'll see the return value is a time_t, which counts seconds.
--Mike--
"COM didn't solve the old version of DLL hell - it just provided us with a new and improved version of hell."
-- John Simmons, 1/22/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Make sure that srand() is called exactly once in your program. Your sample code works correctly because srand() is called outside of the loop.
|
|
|
|
|
Thanks.
You are right. I did not call srand() inside the for-loop, but I did call it at the beginning of a function that I think could be recursive. I was prepare for school lastnight and was not able to look up all the code. I am certain srand() is the problem. You are right on.
Kuphryn
|
|
|
|
|
I figured probably that most Win32 API gurus hang out here, and anyway, I posted a question in the VB forum (since the app i am talking about is written in VB) and as much as I hate to cross-post, I think it is an API problem, so allow me to post a link.
Please help if you can. Would be much appreciated
The thread
--
David Wengier
|
|
|
|
|
I am using ShellExecute to open another program which is located in a subdirectory. I do this by calling it with the file param as the filename, and the directory name as the subdirectory. It works under win2k/xp/nt but not on win95/98/ME....If anyone knows why and how I can fix it it would be of amazing help!
So imagine the directory is 'stuff' and the file is 'thing.exe'
I call ShellExecute(NULL,NULL,"thing.exe",NULL,"stuff",SW_SHOW);
This works fine in 2k but not 9x!!!!!! please someone help me!
: Wherever you go, there you are, and you wish you were somewhere else :
|
|
|
|
|
did you add the Microsoft layer for unicode to your 9x project.
here is the text that is found at that link:
- Add the following two files to your project:
- UnicoWS.dll -- the Microsoft Layer for Unicode DLL
- UnicoWS.lib -- the LIB file to which you link
Note that the Microsoft Layer for Unicode does not automatically load from the $(WINDOWS) or $(WINSYS) directories. Thus, do not put UnicoWS.dll there unless you are running from a system process that is located there. Instead, keep the UnicoWS.dll in your application directory and call LoadLibrary yourself to ensure that you load the correct .dll.
- Add the following to the link options for your application (note that these libraries are not separated by commas because that is how you add them to the link list):
- First, add the following: /nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib /nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib /nod:rasapi32.lib /nod:winmm.lib /nod:winspool.lib /nod:vfw32.lib /nod:secur32.lib /nod:oleacc.lib /nod:oledlg.lib /nod:sensapi.lib.
- Then add UnicoWS.lib.
- Finally, add the libraries that the Microsoft Layer for Unicode uses explicitly: kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib version.lib mpr.lib rasapi32.lib winmm.lib winspool.lib vfw32.lib secur32.lib oleacc.lib oledlg.lib sensapi.lib. In this step, omit any libraries listed after advapi32.lib whose APIs are not used in your application. However, if your application uses another component, such as MFC, ATL, or CRT, be sure to include any libraries on which the component depends.
- Compile your application.
There is other information on the Web page, I would follow the link from above.
Kilowatt
|
|
|
|
|
Use "open" as the verb, not NULL.
--Mike--
"COM didn't solve the old version of DLL hell - it just provided us with a new and improved version of hell."
-- John Simmons, 1/22/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
if you are reading some input like this:
"JOHN 444-44-4444 Student"
and you want to create some object with those 3 variables>
how can you assign every detail to the right variable provided you have all the accessors and mutators?
thanx
|
|
|
|
|
sscanf
: Wherever you go, there you are, and you wish you were somewhere else :
|
|
|
|
|
can some one tell me please how do you write the return type of a function that would return an array of characters?
thanks in advance!
|
|
|
|
|
I am assuming you want a standard "c" style array.
In that case, your function prototype should look like this:
char* SomeFunction();
|
|
|
|
|
Matt Gullett wrote:
char* SomeFunction();
I'm not so sure. How would he know the number of elements? Unless the array is zero-terminated, but then he would call it a string and not an array of characters.
I vote pro drink
|
|
|
|
|
You are correct, he asked for an "array of characters" and I assumed he wanted a string.
To return an array with no predefined terminators or size, you could do one of several things.
1. Create a custom class to deal with it.
2. Instead of using a return value, use function parameters
void SomeFunction(char** pszValue, int& iLen);
This would be good if the function needed to determine the length and allocate the memory.
OR
void SomeFunction(char* pszValue, int iMaxLen);
This would be good if the function just needed a pre-exising array of max size.
3. Use a byte array and use the first N bytes to specify the length.
I am sure there are many other ways to do this also.
Matt Gullett
|
|
|
|
|
I guess technically speaking there is a difference. PASCAL strings i think have a runlength encoding byte at index zero. I've always considered them to be synonymous while using Visuall C++.
your bad is my bad brutha!
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
I want to copy/move a file to another dir, how?
What api to use?
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
CopyFile or CopyFileEx to copy a file.
MoveFile or MoveFileEx to move a file.
|
|
|
|
|
TCHAR pszFrom[1024] = {0};
TCHAR pszTo[1024] = {0};
SHFILEOPSTRUCT shfo;
GetDlgItemText( IDC_SOURCE, pszFrom, 1024);
GetDlgItemText( IDC_DEST, pszTo, 1024);
ZeroMemory(&shfo, sizeof(SHFILEOPSTRUCT));
shfo.hwnd = AfxGetApp()->m_pMainWnd->m_hWnd;
shfo.wFunc = FO_COPY;
shfo.pFrom = pszFrom;
shfo.pTo = pszTo;
shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT;
SHFileOperation(&shfo);
See MSDN for details...
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
Yeah!
This was exactly what I was looking for!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
hello..
anybody can help me? Please help me to solve this error problem :
"error C2504: 'CRecordset' : base class undefined"
tq..
|
|
|
|
|
From MSDN
Compiler Error C2504
'class' : base class undefined
The specified base class was declared but never defined.
This error can be caused by a missing include file or an external base class that was not declared with the extern specifier.
The following is an example of this error:
class A; // error, A is undefined
class A {}; // OK, A is defined
class B : public A {}; // the error is detected here
You may need to include afxdb.h somewhere
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
your solution =
put #include <afxdb.h> at the top of your file. and read your msdn next time.
: Wherever you go, there you are, and you wish you were somewhere else :
|
|
|
|
|
I have a server that runs on a configurable number of threads, that process incoming requests and write them to database. Is it advisable to use one OLE-DB connection using the CDataSource class to send all the concurrent database updates? My question is: does one SQL query on the connection block another, if SQL server itself does not cause locking? or put in different words, do the connection wait for one command to finish before starting another?
Thanks for any help ...
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Hello.
I posted a topic about GUI Programming a few days ago. I was trying to decide if I should go ahead and take a Visual Basic GUI Programming college course. I am most interested in C++ as most people have gotten from my comments on C++.
With the release of .NET, is Microsoft still using MFC for GUI? I would like to know what is the best approach to learning GUI Programming using C++ and still be able to implement GUI easily using .NET. In other words, I want to know what book(s) I should buy to learn GUI using C++ that would apply to .NET, if not emphasizes .NET.
Thanks,
Kuphryn
|
|
|
|