Raised This Month: $51 Target: $400
 12% 

int array to float array from function


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Boonie
Member
Join Date: Aug 2015
Old 07-26-2017 , 06:24   int array to float array from function
Reply With Quote #1

I'm trying to convert an int array to a float array but I'm not quite sure how. Currently I have it so "out" gets the array value too, but this is what is making it not compile. If I remove the [i] from out, it will just use the last value from the int.

Code:
void int2float(const int[] array, int count) {
	float out;
	
	for (int i = 0; i < count; i++)
	{
		out[i] = float(array[i]);
	}
	
	return out;
}
Also is there any reason why you cant use sizeof in a for loop like so?

Code:
for (int i = 0; i < sizeof(array); i++)
Edit: Found out why it didn't work, forgot to specify the size of out. Now I get a warning on "return out" with a tag mismatch, yet its not mismatched? Should I just ignore it?

Last edited by Boonie; 07-26-2017 at 06:55.
Boonie is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode