|
wat do need help on
Game Tester
|
|
|
|
|
I need to accept XML formatted data over a socket connection and place the data into a dataset for parsing. The XML data is bracketed by a start character and an end character, but may range from 50 bytes to thousands of bytes. The app will need to be in C/C++ any thoughts
|
|
|
|
|
You can use expat[^].
pros:
-It is fast
-has a small memory footprint,
-and it comes with source code.
cons:
-it is not a validating parser. So you can't tell if the xml data is valid.
-i don't know if it can read from stream/buffers, i used it only with files.( but you have the source... )
"I don't want to achieve immortality through my work... I want to achieve it through not dying."
Woody Allen
|
|
|
|
|
HI... I wanted to know that can a dll have its own data space? well i guess i am not framing the question properly but what i am interested isn doing is storing some variable/value in a dll that can be persistant i.e i can set it during the first run of my program and then during successive runs read it or modify it .... CAN THIS BE DONE ?
~Ravi
|
|
|
|
|
I'm trying to read raw byte data off of a file. The machine which recorded the data stored them as signed 8-bit integers. I need to send the data into a function which accepts doubles. Obviously, I can't read straight into a double pointer. The values would get wrecked. I don't want to read them into a char pointer array and then cast the values into doubles as I read the values into double pointer array. Is there a better way to do this??? Thanks.
|
|
|
|
|
Anonymous wrote:
Is there a better way to do this???
No. Read them into a char array, convert them to doubles using a cast and store them in a new double array.
John
|
|
|
|
|
You might also look into word boundaries for the binary input. If you need to adjust word boundaries, then you can do this with the #pragma pack ( <args> ) statement.
|
|
|
|
|
A friend of mine is just learning how to code in C and I've been helping her a little bit along the way. There seems to be a problem with a chunk of her code, and I can't figure out how to fix it, it's been quite a while since I've looked at C so I'm a little 'fuzzy' on it.
The following bit of code is taken right from her source code.
int *suit[4];
for(int p = 0; p <= 3; p++)
{
suit[p] = &p;
}
...
then inside a loop which will execute the following loop x = 0 to x < 4 times:
printf(" %d", *suit[x]);
The program exits fine, with no errors, but the only problem is, when it prints out at the end, each entry in the suit array is set at being 4 (so the 4 will print out 4 times), when what she want to print out is 0 1 2 3, if she changes the loop to:
for(int p = 0; p <= 4; p++)
{
...
}
the print statement shows that a 5 prints out in each case. I'm sure the problem comes from this suit[p] = &p; but I don't know how to fix it.
Can anyone help us out? Thanks...
|
|
|
|
|
There's only one variable p , and every element of the array suit is made to point to that element. What exactly are you trying to do in this code?
|
|
|
|
|
What we would like to have happen is to have suit[0] = 0 and suit[1] = 1, etc... but suit[] is a pointer, int *suit[4];
So how, in that for loop, do we say that we want suit[p] = p itself, and not the address of p?
we also tried: *suit[p] = p;
and suit[p] = p;
neither of these works.
|
|
|
|
|
Generally in a loop c programmers will do this (remove the =):
int *suit[4];
for(int p = 0; p < 4; p++) This will run through all 4 suits (0..3).
John
|
|
|
|
|
essentially what you are doing is setting each of your array elements to the address of p; At the end of your loop you have an entire array of addresses to the p value. This is why you print out a bunch of 4's or 5's depending on your loop criteria.
If you are just trying to set the array locations to the value of the integers, then there is no need to use address. create your array as : int suit[4]; this is an array of integers. Now inside the for loop, suit[p]=p; will now set your array entry to the integer value of p and you will receive your expected results from your printf statement.
|
|
|
|
|
noahsarf wrote:
Now inside the for loop, suit[p]=p; will now set your array entry to the integer value of p
doing it that way gives the error:
'=' cannot convert from int to int*
that was one of the original ways we tried it.
|
|
|
|
|
|
As noahsarf said, you need to set each member of suit[] to the value of p, thus:
suit[p]=p;
the reason why this did not seem to work for you is that you need to also change your print statement; instead of
printf(" %d", *suit[x]);
you need to say
printf(" %d", suit[x]);
Good Luck!!
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Thank you so much!
As it turns out, she has no need to use pointers anyway, so we've gotten rid of all the pointers that she's been using.
|
|
|
|
|
This is C++:
int *suit[4];
for(int p = 0; p <= 3; p++)
{
suit[p] = &p;
}
This is C:
int *suit[4];
int p;
for(p = 0; p <= 3; p++)
{
suit[p] = &p;
}
This is what I think your are trying to do since what you are doing makes no since:
int suit[4];
int p;
for(p = 0; p <= 3; p++)
{
suit[p] = p;
}
One last note: Get out of the habit for writing p++ when not neccessary, use ++p instead. When your friend graduates from C to C++ it will eventualy save her a lot of head acks, because post increment can lead to a great deal of unexpected over head when using user define data types.
INTP
|
|
|
|
|
I am just beginning to use Visual C++ and want to make simple math programs. I need to know how to find the Sin and Cosine and basically the other functions a scientific calculator would have. So if someone could point me in the right direction, I'd appreciate it.
Thanks,
Trurl
|
|
|
|
|
|
"Floating-Point Support" in MSDN
KEYWORDS: sin, cos, tan, sqrt.
But even making a simple math program is a bit more complicated, unless you are just planing to douplicate the functionality of the calculator that comes with all Windows OSs.
INTP
|
|
|
|
|
Thanks for the help. Is there any other software program that lets you do simple problems. I was just going to use C++ to change the values of the variables. If I need further help with the code I will post here.
Thanks again,
Trurl
|
|
|
|
|
It's on may to do list.;)
There are some simple ones out there, but they are ususaly hard to find. I am pretty sure there is class at codeproject that supposed to help, but I cann't seem to find it right now. I wrote recursive descent parser years ago origanly based on the one presented in the book "Advanced C Programming" publish by "Prentice Hall Computer Publishing". The book is probably out of print now. Try searching the net for "recursive descent parser" or "equation parser". Also go to microsoft.com and look for the "PowerToys", there should be graphing calculator there (I personaly did not care for it much).
Ahh! PowerToys!
Now I am off to see if they have new ones, specificaly for XP.
Have Fun!
INTP
|
|
|
|
|
hello all,
i am stuck with a usual problem of creating a listening port in VC++.
i tried CSocket class and then Create()function as:
Create(5001,SOCK_STREAM,"127.0.0.1")
but this is not working
pls help!!!!
thanks
Deepesh Dhakad
Indian Institute of Information Technology,Allahabad
India
|
|
|
|
|
You should call GetLastError() to see whats wrong
|
|
|
|
|
m_hSocket = socket(AF_DLI, SOCK_STREAM, 0);
return (m_hSocket != INVALID_SOCKET);
#define AF_UNSPEC 0 /* unspecified */
#define AF_UNIX 1 /* local to host (pipes, portals) */
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
#define AF_IMPLINK 3 /* arpanet imp addresses */
#define AF_PUP 4 /* pup protocols: e.g. BSP */
#define AF_CHAOS 5 /* mit CHAOS protocols */
#define AF_IPX 6 /* IPX and SPX */
#define AF_NS 6 /* XEROX NS protocols */
#define AF_ISO 7 /* ISO protocols */
#define AF_OSI AF_ISO /* OSI is ISO */
#define AF_ECMA 8 /* european computer manufacturers */
#define AF_DATAKIT 9 /* datakit protocols */
#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
#define AF_SNA 11 /* IBM SNA */
#define AF_DECnet 12 /* DECnet */
#define AF_DLI 13 /* Direct data link interface */
#define AF_LAT 14 /* LAT */
#define AF_HYLINK 15 /* NSC Hyperchannel */
#define AF_APPLETALK 16 /* AppleTalk */
#define AF_NETBIOS 17 /* NetBios-style addresses */
#define AF_VOICEVIEW 18 /* VoiceView */
#define AF_FIREFOX 19 /* FireFox */
#define AF_UNKNOWN1 20 /* Somebody is using this! */
#define AF_BAN 21 /* Banyan */
Best Wishes,
ez_way
|
|
|
|