Click here to Skip to main content
15,885,953 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Passing function with parameters as parameter Pin
Greg Utas18-Apr-20 10:24
professionalGreg Utas18-Apr-20 10:24 
GeneralRe: Passing function with parameters as parameter Pin
Vaclav_18-Apr-20 10:52
Vaclav_18-Apr-20 10:52 
GeneralRe: Passing function with parameters as parameter Pin
Greg Utas18-Apr-20 11:04
professionalGreg Utas18-Apr-20 11:04 
GeneralRe: Passing function with parameters as parameter Pin
Vaclav_19-Apr-20 5:47
Vaclav_19-Apr-20 5:47 
GeneralRe: Passing function with parameters as parameter Pin
Greg Utas19-Apr-20 6:05
professionalGreg Utas19-Apr-20 6:05 
GeneralSOLVED Re: Passing function with parameters as parameter Pin
Vaclav_19-Apr-20 9:03
Vaclav_19-Apr-20 9:03 
AnswerRe: Passing function with parameters as parameter Pin
Richard MacCutchan18-Apr-20 21:21
mveRichard MacCutchan18-Apr-20 21:21 
QuestionMath problem with C code Pin
Vaclav_18-Apr-20 6:47
Vaclav_18-Apr-20 6:47 
Just FYI, this is NOT a repost.
As usual I have posted the original in WRONG pew.
However, I found another even weirder failure of simple math case and I really do not have a clue what I am doing wrong.
Are my local variable assignments incorrect ?
Is "printf" lying to me ?

Here is the entire test code
C++
#define MAX_CIRCLES 5

struct TAG_Circles {
	float radius;
	float center;
	float center_x;
	float center_y;

} REAL_Circle[MAX_CIRCLES], IMG_Circle[MAX_CIRCLES];

void OpenGL_Stencil_Circle_Build(void);
// copy last circle to stencil
void OpenGL_Stencil_Circle_Build(void) {
	//
	int index = 5;
	{
		// last circle
		float radius = IMG_circle[index].radius;
		float center_x = IMG_circle[index].center_x;
		float center_y = IMG_circle[index].center_y;
		printf("\n Last circle #%i  radius struct %f radius  %f", index,
				REAL_Circle[index].radius, radius);
		printf("\n Last circle #%i center_x  struct %f center_x  %f", index,
				REAL_Circle[index].center_x, center_x);
		printf("\n Last circle #%i center_y  struct %f center_y  %f", index,
				REAL_Circle[index].center_y, center_y);

	}
}


Here is the output
Last circle #5  radius struct 0.065789 radius  0.131579
Last circle #5 center_x  struct 0.000000 center_x  0.118421
Last circle #5 center_y  struct 0.000000 center_y  0.000000


The questions are NOT what I am trying to accomplish with the code ,
the questions are:

1. why values printed FROM struct DO NOT match assigned values ?
2. why is "radius" TWICE of the value assigned from struct?

PS
Only
radius struct 0.065789
is of correct value.

Cheers
AnswerRe: Math problem with C code Pin
k505418-Apr-20 7:00
mvek505418-Apr-20 7:00 
GeneralSOLVED Re: Math problem with C code Pin
Vaclav_18-Apr-20 8:16
Vaclav_18-Apr-20 8:16 
QuestionRe: Math problem with C code Pin
Richard MacCutchan18-Apr-20 7:02
mveRichard MacCutchan18-Apr-20 7:02 
QuestionPass a struct as a function parameter or just use it as a global variable? Pin
Vaclav_18-Apr-20 5:23
Vaclav_18-Apr-20 5:23 
AnswerRe: Pass a struct as a function parameter or just use it as a global variable? Pin
k505418-Apr-20 6:17
mvek505418-Apr-20 6:17 
GeneralRe: Pass a struct as a function parameter or just use it as a global variable? Pin
Vaclav_18-Apr-20 6:30
Vaclav_18-Apr-20 6:30 
Questioncomputational cost of math functions Pin
Calin Negru17-Apr-20 5:06
Calin Negru17-Apr-20 5:06 
AnswerRe: computational cost of math functions Pin
OriginalGriff17-Apr-20 5:10
mveOriginalGriff17-Apr-20 5:10 
GeneralRe: computational cost of math functions Pin
Calin Negru17-Apr-20 6:58
Calin Negru17-Apr-20 6:58 
GeneralRe: computational cost of math functions Pin
leon de boer17-Apr-20 7:04
leon de boer17-Apr-20 7:04 
GeneralRe: computational cost of math functions Pin
Calin Negru17-Apr-20 8:14
Calin Negru17-Apr-20 8:14 
GeneralRe: computational cost of math functions Pin
Joe Woodbury17-Apr-20 10:43
professionalJoe Woodbury17-Apr-20 10:43 
GeneralRe: computational cost of math functions Pin
kalberts17-Apr-20 11:47
kalberts17-Apr-20 11:47 
GeneralRe: computational cost of math functions Pin
Joe Woodbury17-Apr-20 12:53
professionalJoe Woodbury17-Apr-20 12:53 
GeneralRe: computational cost of math functions Pin
kalberts17-Apr-20 13:03
kalberts17-Apr-20 13:03 
AnswerRe: computational cost of math functions Pin
CPallini17-Apr-20 7:04
mveCPallini17-Apr-20 7:04 
AnswerRe: computational cost of math functions Pin
kalberts17-Apr-20 12:37
kalberts17-Apr-20 12:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.