Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
odi3
Dec 17, 2003
Is there a better method to put a struct into a buffer in c using sprintf instead of referencing each of the doubles seperately?
This method seems to defeat the idea of using a structure....

code:

struct Car {
	int PlayerID;
	double PositionX;
	double PositionY;
	double PositionZ;
	double VelocityX;
	double VelocityY;
	double VelocityZ;
	double OrientationX;
	double OrientationY;
	double OrientationZ;
} myCar;

sprintf (buffer, "%d/%d/%d/%d/%d/%d/%d/%d/%d/%d ", 
myCar.PlayerID, myCar.PositionX, myCar.PositionY, myCar.PositionZ, 
myCar.VelocityX, myCar.VelocityY, myCar.VelocityZ, myCar.OrientationX, 
myCar.OrientationY, myCar.OrientationZ);

odi3 fucked around with this message at 05:21 on Mar 8, 2008

Adbot
ADBOT LOVES YOU

odi3
Dec 17, 2003
C Question:

I am trying to send and receive a string of data using blocking sockets and send and recv functions..

buffer is 512 bytes and contains 9 doubles
when I trace, the send function shows the first double as 44.234
but after i receive it, the buffer 44. (it chops off the decimal.

Anyone know what causes this? do i have to format the doubles in some fashion before sending them? If there are any sections of code u need let me know.


code:
void mySend(struct Car myCar){
	sprintf (buffer, "%lf%lf%lf%lf%lf%lf%lf%lf%lf", myCar.positionX, myCar.positionY, myCar.positionZ, 
													myCar.velocityX, myCar.velocityY, myCar.velocityZ, 
													myCar.orientationX, myCar.orientationY, myCar.orientationZ);
	

	send (s, buffer, sizeof(buffer), 0);
}

void myReceive(int playerID, SOCKET s, char buffer[BUFSIZ])
{
			int error = recv (s, buffer, sizeof(buffer),0); // tcp

	sscanf(buffer, "%le%le%le%le%le%le%le%le%le", &cars[playerID].positionX, &cars[playerID].positionY, &cars[playerID].positionZ, 
												&cars[playerID].velocityX, &cars[playerID].velocityY, &cars[playerID].velocityZ, 
												&cars[playerID].orientationX, &cars[playerID].orientationY, &cars[playerID].orientationZ);
}

//In main client
send (s, buffer, sizeof(buffer), 0);

//In main for Server
int error = recv (s, buffer, sizeof(buffer),0)
Thanks!

odi3 fucked around with this message at 06:53 on Mar 13, 2008

odi3
Dec 17, 2003
How would i do that?
when i debug and print the code before i send and receive, its correct. I assumed that sscan and sprintf were working properly?

odi3 fucked around with this message at 07:21 on Mar 13, 2008

odi3
Dec 17, 2003
i read that sscanf ignores spaces. I am pretty new to all this so i probably misunderstood/misread my book.

Thanks for the help! ill try it out

Edit: so i attempted to send 9 doubles
1.1
2.2
3.3
etc

the buffer before the send command showed 9, but only 1.1 came out on the rec side.

odi3 fucked around with this message at 08:10 on Mar 13, 2008

odi3
Dec 17, 2003
I am having difficulty adding conditional background formatting to a matrix in an SSRS Report in Visual Studio 2013.

A simple version of report display looks like this:

The report has Three Fields fields
"Data", "Group", "Amount"

The Data looks like this:
Data Group Amount
Datavalue1 GroupValue1 1
Datavalue2 GroupValue2 4
Datavalue1 GroupValue2 3
Datavalue2 GroupValue1 2



The report in design mode looks like this:

Group
Data =sum(amount)


The displayed Matrix in preview mode looks like this:


GroupValue1 GroupValue2
DataValue1 | 1 | 3
DataValue2 | 2 | 4


When the report is displayed, I would like the background for items under groupValue1 to display as red if the corresponding item under groupvalue2 equals 3.
The problem is that in design mode, I dont know how to differentiate between referencing fields under groupvalue1 or groupvalue2

Anyone know some code I can put in the BackgroundColor Properties of the value field that could accomplish this?

Any help is greatly appreciated!!

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply