|
Hi I have MS Visual C++ 1.32, is there any possible way I can upgrade to something newer without paying the cost of 6.0 itself. I mean, is there a free way to upgrade to 4.0 or 5.0 or even 6 without buying the full 6.0 version.
I may sound cheap, but I'm in a college class for C++ and It would really help me if I had a newer version. 1.32 doesn't work with all the code that 6.0 does.
Well if there is anyway to upgrade I would really appreaciate the help!
Sincerely
Matt
|
|
|
|
|
It's amazing that you have version 1.32! The oldest version I have is 1.52c. You can pick up version 6.0 Professional for about $50 at this EBay auction[^] if you hurry. Good luck!
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
For a definitive answer, check out this Web site! It looks like the oldest version they'll let you upgrade from is 5.
These may also be of interest to you:
http://www.msdnaa.net/factspage.aspx
http://www.microsoft.com/education/?ID=HowToBuy
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
|
Can somebody tell me what I am doing wrong what the correct syntax is for formatting your output in binary representation.
I have been using printf("%b\n",variable) like the the help files says in .NET but it just keeps outputing a b on the console.
And does anyone know the correct syntax in C for packing your structures?
Help.
Thanks.
|
|
|
|
|
I think you have been looking at the wrong printf format specification.
There is no format that outputs binary in C (neither std or ms extension).
There is no specific packing or alignment keywords in C.
Use the pack pragma and the align declspec.
|
|
|
|
|
Okay, I found something about that pragma but Im not sure how it works with packing the data. Hmmm. Got any ideas.
I found: pragma pack(push, 1) or something like that. Not sure what it does though.
Does C++ have binary formatting?
|
|
|
|
|
About formating, nope. Actually it is printf that lacks it and it's the same for both languages.
Concerning packing, what are you trying to accomplish? Kind of hard to try to help without more info...
|
|
|
|
|
What I'm trying to do is write a struct in C with a couple data types in it, i.e. int, char.
<pre>typedef struct
{
int x;
char c;
}_attribute_((packed))myStruct</pre>
This syntax is for djgpp compiler, I was wondering what you use for .NET or Visual C 6.
|
|
|
|
|
#pragma pack(push, 1)
What this does is set the struct packing to 1-byte boundaries (i.e., no padding), while saving the previous packing. Specify this before your struct, then use #pragma pack(pop) after the struct to restore the old packing. Example:
<br />
#pragma pack(push,1)<br />
struct MyStruct {<br />
int foo;<br />
char a;<br />
};<br />
#pragma pack(pop)<br />
- Mike
|
|
|
|
|
Thanks for the help, hopefully with I can get this thing working.
|
|
|
|
|
Sirrius wrote:
Can somebody tell me what I am doing wrong what the correct syntax is for formatting your output in binary representation.
I have been using printf("%b\n",variable) like the the help files says in .NET but it just keeps outputing a b on the console.
You'll need to write a xxxToBinary() conversion routine. Then you can use printf("%s\n", ...) to output the result.
Sirrius wrote:
And does anyone know the correct syntax in C for packing your structures?
By default, structures are aligned on 8-byte boundaries. To align on some other boundary, such as 4 bytes, use:
#pragma pack(4)
before the structure/union is declared.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks for the advice on the packing. Im not to clear on the xxxToBinary() conversion routine you talked about. How do I go about doing that?
Thanks for your help.
|
|
|
|
|
Here's a sample:
void DWORD_To_BinaryString(DWORD value,char string[])
{
for (int bit = 0; bit < 32; bit++) {
DWORD mask = 0x80000000 >> bit;
if ((value & mask) == mask) string[bit] = '1';
else string[bit] = '0';
}
string[32] = '\0';
} Note that this function converts any 32-bit value to a 32 character string or 1's and 0's. The destination array must be at least 33 characters long.
Software Zen: delete this;
|
|
|
|
|
I'm using embedded structures, and would like to access members of the embedded structure, but am having difficulties with the compiler accepting code regarding the instantiation of the embedded structure. Here's the code:
struct MajorStruct
{
struct MinorStruct
{
int cnt;
};
};
=====================
later on I do this:
====
MajorStruct majStruct;
majStruct.MinorStruct minStruct;
minStruct.cnt = 0;
The error from the compiler is that I cannot have a C-style cast right of the "." operator.
How do I instantiate the embedded structure so that access to its members can be obtained?
Thanks for any suggestion!
William
Fortes in fide et opere!
|
|
|
|
|
The nested struct is instantiated as part of its parent, so you don't want to instantiate it separately. To access its members try: majStruct::MinorStruct.cnt = 0;. Mind you I could be wrong here.;)
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Err, no, I think you're wrong.
What you have there is a nested class. The struct MinorStruct is scoped within the MajorStruct structure. This applies to the visibility of names.
However, it's just another struct. Just because it's declared inside MajorStruct doesn't mean that MajorStruct gets a MinorStruct member; you have to explicitly say so.
To create a variable of type MinorStruct , you need to declare it as
MajorStruct::MinorStruct minStruct; Note the use of the scope resolution operator :: and the use of the class name, not the object name, for the outer scope.
If you want MajorStruct to have a member of type MinorStruct , say:
struct MajorStruct
{
struct MinorStruct
{
int cnt;
};
MinorStruct m_minStruct;
}; You can refer to MinorStruct using simply its name within the scope of MajorStruct .
|
|
|
|
|
Thanks for replying. Your suggestion provided the solution!!
William
Fortes in fide et opere!
|
|
|
|
|
Yes your right of course. I shouldn't try answering questions before my first coffee or two of the day.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Why do you actually declare class inside another class?
I've always wondered why.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Usually for some information-hiding reason. For example, you might need to store data in a POD (Plain Old Data) structure in order to store it to and from some binary file format. However, you don't want users of your class to access this directly.
Normally you'd put the declaration in an implementation file, but you might want to have a member variable of that type. To do this, the structure must be declared in the header, so you put it in a private area of the header.
At other times, you might want a parameter class. You might have a method on one class that requires a large number of parameters, many of which are optional (which probably means you've overloaded the method too heavily, but sometimes it's necessary). The Refactoring people suggest that you should replace the large number of parameters with a single parameter of a class type.
The class is only used in this one method, so to avoid polluting the namespace, you declare the parameter class inside the class in which it's used (obviously here you would declare it public or protected , depending on the scope of the method that uses it as a parameter.
|
|
|
|
|
In my case, I'm doing it for a little of the second reason you gave and a third for encapsulation (meaning, the inner structure provides a kind of specialized service for the outter structure, which the outter structure assigns to it as a sort of "black box" requirement).
That "black box" requirement, has an interface which the outter structure uses, but which ANY other class or structure can use, which makes the usefullness of the inner structure "portable".
William
Fortes in fide et opere!
|
|
|
|
|
hy, to instatiate the embedded struct you must do this:
MajorStruct::MinorStruct minStruct;
greets
andreas
|
|
|
|
|
Thank you for your answer. It was a good answer, and I appreciate it.
William
Fortes in fide et opere!
|
|
|
|
|
I'm using WSAEventSelect() to register events, FD_READ, FD_WRITE, etc to handle in my program. I have a section of code like:
WSAEnumNetworkEvents(pConnect->m_oSkt, *pwsaEvents, &wsaNetEvent)
if((wsaNetEvent.lNetworkEvents & FD_READ) &&
wsaNetEvent.iErrorCode[FD_READ_BIT] == 0)
{
// do stuff
}
:
:
I get an FD_ACCEPT event on the server as I expect and an FD_WRITE on the client as I expect, but when I call send() on the client, I get wsaNetEvent.lNetworkEvents == 0 on the server. I don't understand why it would equal 0. Under what conditions would it equal 0? Any help would be appreciated.
Thanks,
melinda
|
|
|
|