|
Does anyone have the code for adding and multiplying matrices using vectors and arrays?
|
|
|
|
|
So long as all you need to do is add and multiply you could check out the boost uBLAS library. Reasonably efficient and it builds under MSVC6, the uBLAS library also lists some other good libraries under resources.
boost::numeric::uBLAS[^]
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
http://www.codeproject.com/cpp/MatrixClass.asp
|
|
|
|
|
Dear everyone,
we know that CDateTimeCtrl could display date or time and do some selection, it do convinient for us. But we find that we cound not display both date and time in CDateTimeCtrl.
So, could you tell me where we could find the class or OCX for display date and time at the same time?
Welcome any suggestion!
Good Luck
|
|
|
|
|
MyDateTimeCtrl.SetFormat("MM/dd/YYYY HH:mm");
|
|
|
|
|
thk u very much for ur help.
Good Luck
|
|
|
|
|
I am a newbie to Visual C++ and I am trying to create a program that uses only edit boxes and modeless dialogs. My problem is trying to figure out how to get the Save As... in the menu to work, oh I do use a menu. I have read and studied examples and they only confuse me, I know it involves serializing, but how do I serialize modeless dialog edit boxes. I have tried to find clases in my area but their are none, I am learning on my own so thats a challenge in itself. I am trying to get the program to work with Windows 95 and newer OS's, but first things first I need to crack this egg first, what I need is, what do I need to do, I have to serialize the data, how, etc, It took me 6 months to figure how how to create and display a modeless window with a button click from the parent modeless window.Any help is greatly appreciated, I don;t expect you to write the program but point me in the right direction, thanks again.I am using Visual C++ 6.0 Professional edition.
|
|
|
|
|
These are things that cannot be explained with just a few words. You said you have looked at examples, but have you looked at any books or tutorials on MFC programming?
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Sorry for being so late getting back to you, most of the books I have deal with Visual C++ 6.0 and I don't have any books on MFC, but after reading your reply I will get some books on MFC and study, thanks for answering.
|
|
|
|
|
Hi all,
I am working on a project for school(my final exam grade) and I have having a lot of trouble with it. We are making a hangman game and here is what I have to do.
One user inputs the # of letters that the word will be and then enters those words into an array of CHAR's. Then a different user will take the seat and start guessing the letters. How do I search the first array and if a letter is right, fill the second array with the appropriate letter? Does this make any sense? Half my class doesn't get it and the teacher wasn't very helpful. An answer ASAP would be great as my exam is at 1:00 tomorrow. THanks
Matt
Matt Millican
http://www.internetmill.com
|
|
|
|
|
|
I'm not sure if I understood you, but that's quite simple. An example:
------------------------------------------
#include <iostream.h>
#include <memory.h>
#include <stdlib.h>
void main()
{
char singleLetter;
bool wordCompleted = false;
unsigned int numOfLetters;
unsigned int numOfGuessedLetters = 0;
cout << "Number of letters: ";
cin >> numOfLetters;
char* pArray1 = new char[numOfLetters+1];
char* pArray2 = new char[numOfLetters+1];
memset(pArray2,'_',numOfLetters);
pArray2[numOfLetters] = '\0';
cout << "Type in the word: ";
cin >> pArray1;
system("cls"); // Should the other player see what word we've typed in?
while(wordCompleted==false)
{
cout << "Type in a letter: ";
cin >> singleLetter;
for(unsigned int i=0;i<numOfLetters;i++)
{
if(singleLetter==pArray1[i])
{
pArray2[i] = singleLetter;
numOfGuessedLetters++;
}
}
if(numOfGuessedLetters==numOfLetters)
{
cout << "\n\n";
cout << "Current status: " << pArray2 << endl;
cout << "Hey dude! You won!" << endl;
break;
}
else
cout << "Current status: " << pArray2 << endl;
}
delete [] pArray1;
delete [] pArray2;
}
|
|
|
|
|
Hi,
I changed some stuff around that was incorrect, compiled it and all I got when I ran it was The very end of the program. Any other things?
Matt
Matt Millican
http://www.internetmill.com
|
|
|
|
|
Hello,
I have a little problem on re-using a socket after a completed AcceptEx call. The number of maximum clients is equal to the number of sockets in my program. On every socket I made an AcceptEx() call to accept a new connection and receive the data. So far so good. After receiving the data I need a new AcceptEx() call which can receive data from other clients who are trying to connect.
But - something is going wrong! When I simply recall AcceptEx() on the same listener socket and the same accept socket I get an error (WSAEINVAL / 10022L).
Do I have to close the socket before I try to make a new AcceptEx() call on that socket? I would like to re-use this socket and leave it open, because it's queued in a completion port.
I hope you can help me.
Thanks for your attention!
bond006
|
|
|
|
|
Yes, you must close the socket before assigning a new socket to that same variable.
Kuphryn
|
|
|
|
|
Which socket? The listener socket or the accept socket? When I close the listener socket I have no sockets at all!
bond006
|
|
|
|
|
Hi,
well, you have two possibilities - first is to close the socket before you use the new AcceptEx using the closesocket() . But then you simply destroyed everything and there's no reuse.
Second is to re-use the socket - for this you can use this trick: Instead of calling closesocket() you can use this one:
TransmitFile( sock, NULL, 0, 0, NULL, NULL, TF_DISCONNECT | TF_REUSE_SOCKET )
This will close the socket, but makes it ready for AcceptEx reuse. Works only on NT, but as you wrote you use IOCP, so should not be a problem here
|
|
|
|
|
I am trying to create a multi threaded program.
First I have the thread that the program initializes, but I need another.
The second thread is needed to access memory that is on a PCI card.
I am already able to open the card, but not quite sure how to create a new thread. What include will I be needing?
thanks,
Steven
|
|
|
|
|
That's quite simple!
Try something like this:
// ------------------------------------------------------
#include <process.h>
UINT threadID;
unsigned WINAPI ThreadFunc(LPVOID param);
void main()
{
CPCICard pPCICard = new CPCICard();
_beginthreadex(NULL,0,ThreadFunc,NULL /*that's the parameter for the ThreadFunc*/,0,&threadID);
DoSomeWorkBlablabla();
delete pPCICard;
}
unsigned WINAPI ThreadFunc(LPVOID param)
{
DoSomeThreadWork();
RunningLoop();
return 0;
}
// ---------------------------------------------------
I don't know whether I helped you or not, but when you call _beginthreadex the ThreadFunc function is called and then two threads running on the same time, doing different things.
bond006
|
|
|
|
|
Sorry for the newbie problem, but I've been struggling with this for awhile. Do I need to set Directories (tools/options/Directory tab) differently than default?
My Error Message:
error C2065: 'sin' : undeclared
identifier
Excerpt of code:
#include math.h (greater than,less than signs)
double ken;
double j = 3.14;
ken = sin(j);
What's confusing is that the IDE seems to recognize sin (shows the function prototype)
Thanks for any help - Ken
|
|
|
|
|
If you right-click on the #include < math.h > statement and select Open Document, does that work? Is the sin() prototype found in the file?
|
|
|
|
|
Thanks for your help.
I discovered that by moving the #include from the .cpp file to the .h file, this made VC++ happy. I'm not sure why it wouldn't "see" math.h from the .cpp file...but I'm happy that it works... and I suppose the .h file is the more organized place for the include.
/KL
|
|
|
|
|
either you're messing around with precompiled headers (everything befoer stdafx.h is basically ignored), with namespaces, or maybe you do use sin() in a cpp file that didn't have the #include.
For the "more organized place":
- includes used in most files go into stdafx.h (append at bottom)
- other includes go into .cpp unless they are needed in .h, or by files that include that header.
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
If your working on aproject with precompiled headers, the compiler will ignore all statements upto the
#include "Stdafx.h"
line, so if you had #include math.h before this line it would have been ignored, it has to be after that line and then all would be ok.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Hiya I am writing records of lenght 100 in a file. I was just wondering when am I meant to use carriage returns and line feeds?? What is the advantages of putting them into ur files??
Is this a line feed = '\n' and is this the carriage return = '\r'??
So it would be:
char *line = "hello\r\n";
Also what is the difference between stream and ostream??
Thanks.
|
|
|
|