Click here to Skip to main content
16,005,316 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: sizeof(float)/sizeof(float[0]) Pin
James R. Twine10-Oct-06 3:14
James R. Twine10-Oct-06 3:14 
GeneralRe: sizeof(float)/sizeof(float[0]) Pin
Alex Cutovoi10-Oct-06 3:35
Alex Cutovoi10-Oct-06 3:35 
GeneralRe: sizeof(float)/sizeof(float[0]) Pin
James R. Twine10-Oct-06 3:36
James R. Twine10-Oct-06 3:36 
GeneralRe: sizeof(float)/sizeof(float[0]) Pin
Alex Cutovoi10-Oct-06 3:59
Alex Cutovoi10-Oct-06 3:59 
GeneralRe: sizeof(float)/sizeof(float[0]) Pin
Waldermort10-Oct-06 3:57
Waldermort10-Oct-06 3:57 
GeneralRe: sizeof(float)/sizeof(float[0]) Pin
Alex Cutovoi10-Oct-06 4:00
Alex Cutovoi10-Oct-06 4:00 
GeneralRe: sizeof(float)/sizeof(float[0]) Pin
Waldermort10-Oct-06 4:06
Waldermort10-Oct-06 4:06 
AnswerRe: sizeof(float)/sizeof(float[0]) Pin
Zac Howland10-Oct-06 4:22
Zac Howland10-Oct-06 4:22 
If the array is allocated on the heap, sizeof behaves differently than it does if it was on the stack.

int i = 0;

float stackArray[5];
i = sizeof(stackArray) / sizeof(stackArray[0]);	// i is 5
// sizeof(stackArray) will return (5 * sizeof(float))
// sizeof(stackArray[0]) will return sizeof(float)

float* heapArray = new float[5];
i = sizeof(heapArray) / sizeof(heapArray[0]);	// i is 1
// sizeof(heapArray) will return sizeof(float*)
// sizeof(heapArray[0]) will return sizeof(float)

// Interesting Note (forget bounds errors here)
int myFunction(float* myArray)
{
	return sizeof(myArray) / sizeof(myArray[0]);
}
// above function will return heap results regardless of where
// the float array is actually allocated (that is, always 1)


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

QuestionBringing child window foreground and model-less dialog background Pin
Veeresh Hiremath10-Oct-06 2:49
Veeresh Hiremath10-Oct-06 2:49 
AnswerRe: Bringing child window foreground and model-less dialog background Pin
Galatei10-Oct-06 3:49
Galatei10-Oct-06 3:49 
GeneralRe: Bringing child window foreground and model-less dialog background Pin
Veeresh Hiremath10-Oct-06 19:25
Veeresh Hiremath10-Oct-06 19:25 
GeneralRe: Bringing child window foreground and model-less dialog background Pin
Galatei11-Oct-06 2:42
Galatei11-Oct-06 2:42 
GeneralRe: Bringing child window foreground and model-less dialog background Pin
Veeresh Hiremath11-Oct-06 18:49
Veeresh Hiremath11-Oct-06 18:49 
QuestionHow to get path for the favourites of a system ? Pin
kiranin10-Oct-06 2:20
kiranin10-Oct-06 2:20 
AnswerRe: How to get path for the favourites of a system ? Pin
Mila02510-Oct-06 2:29
Mila02510-Oct-06 2:29 
GeneralRe: How to get path for the favourites of a system ? Pin
Mila02510-Oct-06 2:42
Mila02510-Oct-06 2:42 
AnswerRe: How to get path for the favourites of a system ? Pin
Rajesh R Subramanian10-Oct-06 2:32
professionalRajesh R Subramanian10-Oct-06 2:32 
QuestionHow to get Windows Installed Drive? Pin
Sarvan AL10-Oct-06 2:01
Sarvan AL10-Oct-06 2:01 
AnswerRe: How to get Windows Installed Drive? Pin
Rajesh R Subramanian10-Oct-06 2:08
professionalRajesh R Subramanian10-Oct-06 2:08 
GeneralRe: How to get Windows Installed Drive? Pin
Hamid_RT10-Oct-06 2:53
Hamid_RT10-Oct-06 2:53 
QuestionSystem Name & IP using gcc in Linux Pin
Andy Rama10-Oct-06 1:48
Andy Rama10-Oct-06 1:48 
AnswerRe: System Name & IP using gcc in Linux Pin
Galatei10-Oct-06 3:33
Galatei10-Oct-06 3:33 
GeneralRe: System Name & IP using gcc in Linux Pin
Andy Rama11-Oct-06 1:12
Andy Rama11-Oct-06 1:12 
GeneralRe: System Name & IP using gcc in Linux Pin
markkuk11-Oct-06 4:08
markkuk11-Oct-06 4:08 
GeneralRe: System Name & IP using gcc in Linux Pin
Galatei11-Oct-06 4:13
Galatei11-Oct-06 4:13 

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.