If you are generating all number from x->y inclusive. Why not create an array of all the number and instead swap indexes some arbitrary number of times. It will speed it up vs determining if you already generated the number when you have 10000 numbers and only one number left to generate :-)
I am currently working with a WCF service and my searches both in this forum as well as on the web have no results specific enough to answer my question. Has anyone successfully passed attributes of a property via nettcp in WCF?
Here is the scenario. I have an attribute class with an ID...
Thanks for the responses guys :-) In either response, it just ends up being too much work. I have come to the same conclusion from a different angle.
I thought of the reusability of this code and it is a nightmare. It requires that every set call triggers this flag.
Ultimately, it all...
Hi All,
I have a base class I defined to maintain if a set property has been called. In each class that inherits from this base class, I add the line "IsDirty = true;".
Is it possible to have the base class define for all child classes, this line is added/executed by default? If so, is...
if it is a char**, try doing
lpBuff[0] = new char[dwCurBufSize];
The error might be more descriptive. Also, put a try catch block arround it, break in the catch and follow the call stack backwards to make sure that the buffer being passed is indeed a 2d array.
Matt
If you dont mind adding extra data to a struct you could do
struct structOne
{
size_t structSize;
// other data
structOne():structSize(sizeof(*this)){}
};
struct structTwo
{
size_t structSize;
// other data (different of course)
structTwo():structSize(sizeof(*this)){}
};
etc...
You still need to deal with padding issues. Most likely it will still have 8. Look into defining your own type within a struct using pramas
#pragma pack(push:1)
struct my_struct
{
unsigned fiveBits:5;
};
#pragma pack(pop)
I am not sure if this will work for you because (i think) it will...
Well, this can be a problem unless each record is somehow uniquely identified (i.e. a single file that you read in its entirety, a return value from a function that ensures a full binary/ascii return of the entire record, etc..)
If that is the case, you have a unique situation. Because "JRBP"...
int values[ROWS][COLS];
if this is what you mean, it is just the reverse of the row sum
int rowSum = 0;
for(int col = 0;col<COLS;col++)
{
rowSum += values[rowToSum][col];
}
for columns it would be
for(int row = 0;row<ROWS;row++)
{
colSum += values[row][colToSum];
}
Matt
To add all numbers 1 to n you can calculate it without a for loop by doing
int quickSum = (sumTo+1)*(sumTo/2) + ((sumTo+1)/2) * (sumTo%2);
Where sumTo in your case is equal to 1000
Now, take your array with one missing number, sum it and subtract it from quickSum... You have your missing...
MSDN
pack
#pragma pack( [ n] )
Specifies packing alignment for structure and union members. Whereas the packing alignment of structures and unions is set for an entire translation unit by the /Zp option, the packing alignment is set at the data-declaration level by the pack pragma. The pragma...
Could be a padding issue... try a
#pragma push(pack,2) before your struct (i think the syntax is right)
<your struct>
#pragma pop
Or use the BITMAPFILEHEADER struct
Matt
I ran into this problem before... I believe what I did was for template classes was move the default #include "stdafx.h" to the bottom of the cpp file. I dont have my code here at work so I dont know if this is the exact answer.
Matt
1. Not really any effect
2. Same
3. Global Data to this file only
4. Not really any effect.
For # 4, if declared somewhere else then main, the value remains the same every time you come back to the function.
Ex.
int myFxn()
{
static int number_of_calls = 0;
number_of_calls++...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.