|
well, thanks david for ur replies.
In my search through the net, I found that there is a documentation fault in MSDN, MSDN says that this function is supported under wince 4.0 and above, actually it is declared in the header file, but it is not implemented in the .lib file - this is according to many sites on the net. So, it is not a linker problem.
Is there a simple alternative?
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
so i got a pointer
void *p;
and a structure
struct d{
blah....blah..
};
d st;
and i use it with
memcpy(p,&st,sizeof(d));
so my trouble is:
after using memcpy i need to advance the pointer with sizeof(d), so i can copy another one.
tryed p+=sizeof(d) but got :
error C2036: 'void *' : unknown size
help pls .
|
|
|
|
|
If you want to use the pointer that way just declare the pointer as char* instead of void *. You could also just cast the pointer variable to char* if you really want to declare the pointer as void *.
Chipper Martin
|
|
|
|
|
is there another way to shift it?
|
|
|
|
|
have you noticed that in your sample, p is not assigned, so memcpy() is writing nowhere (and there, will crash in a memory violation access) ?
do p = new d; first...
|
|
|
|
|
p is used in a buffer lock in DirectX
Vertexbuffer->Lock((0,sizeof(g_cubeVertices),(void**)&p,0);
so its good :P
|
|
|
|
|
Since you will probably be doing this in an array (I assume this is for DirectX vertices?) if st is an array of d's instead of single ones, just call it this way:
d st[100];
memcpy(p, &st, sizeof(d) * 100);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I'm not sure if this is what he's after; I think he wants to fill the array with multiple copies of the same element.
On a side note, I'd do what you're trying to do like this:
d st[100];
memcpy(p, &st, sizeof(st));
This way you can change the size of the array in one place and thus it's harder to make a mistake by only changing it in one.
Steve
|
|
|
|
|
Stephen Hewitt wrote: d st[100];// fill in each st somewhere// p is allocated in a Vertex buffermemcpy(p, &st, sizeof(st));
That works until you do something like this:
d* st = new d[100];
memcpy(p, st, sizeof(st));
memcpy(p, st, sizeof(d) * 100);
If you want to change the size of the array, it is better to do this:
const unsigned long ARRAY_SIZE = 100;
d st[ARRAY_SIZE];
memcpy(p, st, sizeof(d) * ARRAY_SIZE);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Don't use a void pointer, use a pointer of the correct type then use the ++ operator.
Steve
|
|
|
|
|
Build Dependencies Problem
I have a build problem in a .Net (2003) MFC/c++ project I don't understand.
Each time I build, the linker runs, so it's somehow finding something out-of-date.
I'm an old hand at VC 6.0, but relatively new to .Net (in this case, 2003)
The project is an MFC project with 10 sub-projects. The same project builds correctly in VC 6.0. The dependencies seem correct. But I've got something amiss.
.Net question - is nmake still used?
In any event, does anyone know how to get a report from the builder about the update rules it is using?
-Brooks
Brooks
|
|
|
|
|
I found the (partial) answer -
Syntax for entries in Linker Additional Dependencies is different form (my) expectations.
Don't start the entry with a back-slash. It works with full-path, ie: "c:\MyDir\MyLib.lib". I didn't yet experiment to figure out how to get a relative path to behave.
See -
http://groups.google.com/group/microsoft.public.dotnet.languages.vc/browse_thread/thread/22d0d877beb5c5fc/f09d50aec36ea08e%23f09d50aec36ea08e
-Brooks
Brooks
|
|
|
|
|
snippet:
while(1)
{
for(i=0;i<95;i++) // Looping To Check Visual Keys
{
shift = GetKeyState(VK_SHIFT); // Check Whether Shift Is Pressed
x = SpecialKeys[i]; // Match The Key
if (GetAsyncKeyState(x) & 0x8000) // Check Combination Keys
{
// See Whether CapsLocak Or Shift Is Pressed
if (((GetKeyState(VK_CAPITAL) != 0) && (shift > -1) && (x > 64) && (x < 91))) //Caps Lock And Shift Is Not Pressed
{
bKstate[x] = 1; //Uppercase Characters A-Z
}
}
else
{}
}
}
The function GetAsyncKeyState(x) is called in the system service and paremeter GetAsyncKeyState(x) & 0x8000 nerver be true, why?
Thank you!
|
|
|
|
|
Is your service set to interact with the desktop?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
who can answer this question?
thank you!
|
|
|
|
|
i have write code as follow-->
if ( (fp = fopen(filename,"r")) != NULL)
{
while(fgets(sendline,MAXLINE,fp) != NULL)
if( (send(sockfd,sendline,strlen(sendline),0)) == SOCKET_ERROR)
{
printf("Send Error!");
CleanUp();
return;
}
if ( ferror(fp) != 0)
printf("file get error,retry!");
else
if ( feof(fp) !=0)
{
printf("file trans complete!");
fclose(fp);
return;
}
if((n = recv(sockfd, recvline, MAXLINE,0)) > 0)
{
recvline[n] = 0; /* null terminate */
printf("terminate revceive data\r\n");
if (fputs(recvline, stdout) == EOF)
printf("fputs error");
}
printf("\r\n\r\nterminate send data\r\n");
}
else
printf((char *)GetLastError());
it works on .txt well,but when i transmit .rar it doesn't work. i recieve the file,open with notepad.exe.only "Rar!" saved. why!!something must be wrong with fopen()!!!i send test.rar-->contains "Rar! 蠍s
?t ? M?50 test.txt ??WinXYhappyGo_sleep?{ @ "(open with notepad.exe).must i Serialize the file i want to send??how to use Serialize() on Win32 console APP.
Right here waiting......@_@
Or mail me!
thanks!
|
|
|
|
|
open the file in binary...
|
|
|
|
|
which function can help me.
for example:........
thanks!
@@
|
|
|
|
|
fopen() buddy, ,but tell him to use "rb" instead of "r" only
same for the sender...
|
|
|
|
|
WinXYhappy wrote: strlen(sendline)
a .rar file is not a text file. you can't use string functions on the data from a non text file.
led mike
|
|
|
|
|
then how can write this code:
--->if( (send(sockfd,sendline,strlen(sendline),0)) == SOCKET_ERROR)
by the way:
i have change the line:
if ( (fp = fopen(filename,"r")) != NULL)--->
if ( (fp = fopen(filename,"rb")) != NULL)
|
|
|
|
|
Change strlen(...) to just use MAXLINE (what you are requesting from fgets). For network efficiency, you should make sure that constant is at least 700 bytes, but less than 1000.
Or, alternatively, read in the entire file first and then send it over the socket.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
thanks
i'm trying.
waiting for further explanation....
|
|
|
|
|
Zac, I don't think it's that simple. I am not familiar with RAR file format but I imagine it has a header that contains numeric values (multi-byte) and therefore byte ordering would be required.
led mike
|
|
|
|