|
Pointers to structures can be incremented by simple expressions thus:
CSPair++;
that is all that is needed to point to the next entry in the array.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
|
thanks eugen for the reply
that was a typing mistake
issue is resolved by using
CheckSumpair[x].memberN;
.
.
.
since i am using [] operator to access pointer no need of using ->
|
|
|
|
|
The address CSPair[x] is a structure reference not a pointer, hence use the '.' member access operator.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Your code is really ugly.
rupeshkp728 wrote: #define UINT32 unsigned int
#define INT32 int
#define UCHAR unsigned char
Why do you use #define instead of typedef ?
rupeshkp728 wrote: typedef struct CheckSumPair
{
UINT32 weakcs; // The weak, rolling Adler32 checksum.
UCHAR StrongCS[10];
};
Typedef what?
rupeshkp728 wrote: CheckSumPair* CSPair = (CheckSumPair*)malloc(sizeof(CheckSumPair)*10);
Why are you using malloc? Do you really need to use C memory allocation functions?
rupeshkp728 wrote: strncpy((char*)CSPair->StrongCSString,(char*)"CEDVCD",10*2+1);
struct CheckSumPair has no StrongCSString member.
rupeshkp728 wrote: printf("%d %s %s\n\n",CSPair[x]->.weakcs,CSPair[x]->StrongCS,CSPair[x]->StrongCSString);
This is the ugliest part. What are you trying to do?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I think you have to print the values as follows:
for(int x = 0; x < 10; x++)
printf("%d %s %s\n\n",CSPair[x].weakcs, CSPair[x].StrongCS, CSPair[x].StrongCSString);
or
for(int x = 0; x < 10; x++)
{
printf("%d %s %s\n\n",CSPair->weakcs,CSPair->StrongCS,CSPair->StrongCSString);
CSPair++;
}
|
|
|
|
|
Don't you have a warning "warning C4091: 'typedef ' : ignored on left of 'CheckSumPair' when no variable is declared"?
Don't you have an error "error C2039: 'StrongCSString' : is not a member of 'CheckSumPair'"?
Type of CSPair[x] is CheckSumPair not CheckSumPair*, so you can't use "->", use "." instead.
Instruction "CSPair[x]->.weakcs" contains "->" and ".".
Why malloc? use the new operator instead:
CheckSumPair* CSPair = new CheckSumPair[10];
or better, if possible:
CheckSumPair CSPair[10];
And finally, you have to explain what are you trying to do with the two strncpy, maybe your code has to be like:
#define UINT32 unsigned int
#define INT32 int
#define UCHAR unsigned char
typedef struct
{
UINT32 weakcs;
UCHAR StrongCS[10 + 1];
UCHAR StrongCSString[10 + 1];
} CheckSumPair;
int main()
{
CheckSumPair CSPair[10];
for(int x = 0; x < 10; x++)
{
CSPair[x].weakcs = (UINT32)x+1;
strncpy((char*)CSPair[x].StrongCS, "XYZ", 10);
strncpy((char*)CSPair[x].StrongCSString, "CEDVCD", 10);
}
for(int x = 0; x < 10; x++)
{
printf("%d %s %s\n\n", CSPair[x].weakcs, CSPair[x].StrongCS, CSPair[x].StrongCSString);
}
return 0;
}
|
|
|
|
|
Hello Friends
While compiling 32bit code on 64 bit compiler,I came across one error is
error C2664: 'SetTimer' : cannot convert parameter 4 from 'void (__cdecl *)(HWND,UINT,UINT,DWORD)' to 'TIMERPROC'
Do u have any Ideas to resolve this?
Regards
Yogesh
|
|
|
|
|
Forgot to mention CALLBACK in TimerProc declaration?
|
|
|
|
|
That I am using CALLBACK in Declaration.
But I got it to work after casting fourth parameter to TIMERPROC.
IS this the right way?
Thanks
Yogesh
|
|
|
|
|
Nope.
However, as Rejeesh suggested, even in Microsoft samples there is the 'cast-hack'.
Anyway, at least on my system, the following declaration:
void CALLBACK myTimerFun(HWND , UINT , UINT_PTR , DWORD );
compiles fine, without the need of casting.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Wednesday, March 31, 2010 5:47 AM
|
|
|
|
|
Right
The third parameter may not be a UINT under x64 ,
it must be UINT_PTR
virtual void BeHappy() = 0;
|
|
|
|
|
I got it the way u defined and without casting.
thanks
Yogesh
modified on Wednesday, March 31, 2010 8:14 AM
|
|
|
|
|
|
So Rajneesh without Type casting ,Is there any other way to solve my prob?
As In my case I am using CALLBACK in declaration.
Thanks
Yogesh
|
|
|
|
|
As CPallini suggested change the function signature of Timer proc as follows:
VOID CALLBACK TimerProc(HWND hwnd,
UINT uMsg,
UINT_PTR idEvent,
DWORD dwTime
);
I hope, that would compile without casting.
|
|
|
|
|
Yeah,that CPallini method works.
THanks
|
|
|
|
|
In fact, if you look at the TIMERPROC definition in winuser.h it is as follows:
typedef VOID (CALLBACK* TIMERPROC)(HWND, UINT, UINT_PTR, DWORD);
|
|
|
|
|
|
CALLBACK should be present either in declaration (.h file) and definition (.cpp file).
Otherwise they are two different functions.
In your case the compiler knows about a CALLBACK prototype, by supply a __cdecl function to the linker (it wold have been __stdcall instead).
casting a __cdecl into a __stdcall is dangerous, since the stack is managed differently (you can overwrite some caller / callee local variables ... that could lead to very nasty bugs!
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
try giving 4th param as 0
|
|
|
|
|
Hello everyone, I wanted to know if the OnSelChange event of the combo box can be accessed outside of the dialog file, as i need to access and change the code in a different file within the same project.
|
|
|
|
|
You may 'forward' the notification: inside the OnSelChange method, nothing prevents you to call any (public) method of any object you may reference.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi
I am using a tree view control . there are three columns in my tree view control . is there any way to re arrange the coloumns of tree view control.like if i click on first coloumn and drag to second coloumn second coloumn should be at first coloumns position and first coloumn should be at second coloumns position
|
|
|
|
|
(Wow !) Could you post a screenshot please ?
virtual void BeHappy() = 0;
|
|
|
|