|
Why not use a vector ? Why does it matter that you need to do it in Win32 ? Then use getline() to read the file.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I don't know how to use vectors and I have to do it in win32 is because I already started on a project with it and I can't go back and change its type... it would take too long. I also don't know how to use getline().
|
|
|
|
|
Snyp wrote:
I have to do it in win32 is because I already started on a project with it and I can't go back and change its type
What I asked is why does it *matter* that you're using Win32 ? The Microsoft libraries sit on top of the C++ language and should only be your first port of call if you're trying to do something OS specific, like throw up a window. Stuff C++ doesn't support.
Snyp wrote:
I don't know how to use vectors
Snyp wrote:
I also don't know how to use getline().
I have articles on this site on both, use the search box above.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Ok I think I know how I'm going to do this, first if I find the getline() function and how it works I will get the line store it to first element and then on and on until the end of file is reached. I will then use a sort to sort the big list.
|
|
|
|
|
Yes, exactly. One benefit of the STL is you get your sorting algorithms for free.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Thankyou very much, I don't use the stl alot to none but I think you made me 'cross over'
|
|
|
|
|
Then my job here is done
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I need one more thing, I can't seem to find the getline function anywhere, can you tell me in which subtitle it is located in, like files or c++/mfc or whatever...
|
|
|
|
|
|
#include <vector>
#include <algorithm>
#include <functional>
What do those headers mean
|
|
|
|
|
vector contains the dynamic array vector class. algorithm contains all the algorithms that work on STL containers ( well, most of them ), and functional contains stuff you need to write your own function objects ( from memory ).
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Sry about that but I was looking at codeproject articles... wow what a nice collection there is at cplusplus.com
|
|
|
|
|
I need one more thing, I can't seem to find the getline function anywhere, can you tell me in which subtitle it is located in, like files or c++/mfc or whatever...
|
|
|
|
|
Snyp wrote:
...if I find the getline() function and how it works...
Try here.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
i tried to convert the code showed in this article (http://www.codeproject.com/bitmap/screencapture.asp) to non-mfc Standard Win32 code, with a bit of WTL. I came up with this:
void CMainDlg::CopyWndToClipboard(HWND pWnd )
{
CBitmap bitmap;
CClientDC dc(pWnd);
HDC memDC;
RECT rect;
memDC = ::CreateCompatibleDC(dc.m_hDC);
::GetWindowRect(pWnd,&rect);
bitmap.CreateCompatibleBitmap(dc.m_hDC, rect.right-rect.left,rect.top-rect.bottom );
CBitmap* pOldBitmap= (CBitmap*)(HBITMAP)::SelectObject(memDC,&bitmap);
::BitBlt(memDC,0, 0, rect.right-rect.left,rect.top-rect.bottom, dc.m_hDC, 0, 0, SRCCOPY);
::OpenClipboard(::GetParent(pWnd)) ;
EmptyClipboard() ;
SetClipboardData (CF_BITMAP, (HBITMAP)bitmap ) ;
CloseClipboard () ;
SelectObject(memDC,pOldBitmap);
bitmap.Detach();
}
Which doesn't seem to work. All is does is throw some rubbish on the clipboard.
Does somebody know a function to replace my code or does somebody know what i'm doing wrong?
Thanks
|
|
|
|
|
The problem i think its because of Detaching bitmap at the end.
Comment out that and try.
May be you can move Bitmap variable to class variable.
Hope this helps!!!
|
|
|
|
|
hello
I wants to compare tow names in two columns in a sheet of excel,and i want to find the name redundant in the two columns.
how we can do that with VC?
|
|
|
|
|
i need to find a form by it's title.
thanks.
|
|
|
|
|
how can i access the system.web classes from a managed c++ class library project? i am not able to add a reference from the project menu.
|
|
|
|
|
I think you want the Managed C++ Forum
My neighbours think I am crazy - but they don't know that I have a trampoline. All they see my head bobbing up and down over the fence every five seconds
|
|
|
|
|
hey there again-
My problem is I need to create a program that acts as a card dealer. The user will input how many cards he/she wants, then it will deal out those cards. I did a project kinda like this before, but now I have to do it using a main program, three header files (card.h, deck.h, and hand.h) and three specification files (card.cpp, hand.cpp, deck.cpp). I do not know exactly how to "create" the cards or how to tie all of these files together. I also hardly understand in which order the files will operate. If anyone has any advice or wisdom for me that would be great. Thanx.
ZackyD
|
|
|
|
|
Don't sleep in class.
Seriously, if you're coding and you get stuck, I'd love to help you. But if you don't know where to start, you need to either pay attention in class, or change schools.
*sigh*
OK - each file typically represents a class. You also need an entry point for your program, which is your int main() method. Now, the code you put in your main method is the start of program flow, and typically you'd include the three head files in the file that contains it. Now you can create and manipulate cards, decks and hands in your main program, because it can 'see' them. Putting them in seperate files makes them easy to include in multiple places, and also means you have no problems with trying to use one class so it can 'see' another.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
You can use a scheme to identify rank and suit by using div() on an range of integers from 0 to 51 (this is how the cards dll works - google for Cards.dll for tips on how a card can be represented) In this case you could wrap this up with a class with little more than an integer member and an overloaded member that would output the rank and suit.
Now then - what does a deck do? Well, it needs a number of cards, a way of shuffling them, and a way of doling one out - so, you might have a int GimmeACard() method, e.g.
A hand will need to RecieveACard(int) likewise.
The dealer (main.cpp) will need to:
have a deck to work with (for int GimmeACard() )
have hands to be dealt to (with ReceiveACard(int) )
Does this help? Note that the nice thing is that the details involved in the operations are hidden below the interfaces, leaving you with a nice little black box to work with. Take the case of the Deck class. It is free to worry about what type of randomization to use when the Shuffle() method is called. It takes care of knowing what cards are left in the deck after each one is doled out.
Your dealer can then just say:
// declare the object instances
Deck myDeck;
Hand myHand; // or make and array of pointers to hands and new 'em
// Shuffle the deck
myDeck.Shuffle(); // could take a seed parameter
// deal a card to a hand
myHand.RecieveACard(myDeck.GimmieACard());
Each .cpp file #includes its corresponding .h file.
Your main.cpp will #include the headers it needs, and when you instantate the objects they'll be ready for use. The linker will take care of tieing the files together - just make sure they're in the project.
Hope this helps - I'm just killing a little time here, having have had a bit of fun with this kind of thing in the past...
|
|
|
|
|
Hey Man thanks a million!!!!!!!!!!!!!!!!!!!!!!!
zackyD
|
|
|
|
|
Hey, I have a problem. A have a project in a computer science class and I am lost on how to organize all of these OOP files (header files, specification files) Anyways, if someone out there could somehow explain the main concepts behind OOP, that would be very helpful. If there is anyone out there that has a sample program to look at that would be great as well. I am really lost on this subject. Thanx.
ZackyD
|
|
|
|