Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


deallocation errors

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 04, 2008 8:46 pm    Post subject: deallocation errors Reply with quote

I'm zoning in on a method to deallocate the last element of an array's memory (in result, deleting it from the array). This is what I have. It doesn't actually deallocate the memory but it does the job. Just I'm getting these stupid errors that I can't figure out how to fix x_x Here's my code

Code:

void DeleteArrayIndex(int index) {
   if(index < count) {
      memmove(&array[index], &array[index+1], ((count-1)-index)*sizeof(int));
      int *temp = (int*)calloc(count-1, sizeof(int));
      int *temp2 = array;
      &array = temp;
      memcpy(array, temp2, (SIZE_T)temp);
      count--;
   }
   else if(index == count) {
      int *temp = (int*)calloc(count-1, sizeof(int));
      int *temp2 = array;
      &array = (int[count])temp;
      memcpy(array, temp2, (SIZE_T)temp);
   }
}


Here are my errors.

VC++ wrote:

------ Build started: Project: test, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\users\OIB\documents\visual studio 2008\projects\test\test\main.cpp(16) : error C2440: '=' : cannot convert from 'int *' to 'int (*)[10]'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\users\OIB\documents\visual studio 2008\projects\test\test\main.cpp(23) : error C2540: non-constant expression as array bound
c:\users\OIB\documents\visual studio 2008\projects\test\test\main.cpp(23) : error C2440: 'type cast' : cannot convert from 'int *' to 'int [1]'
There are no conversions to array types, although there are conversions to references or pointers to arrays
Build log was saved at "file://c:\Users\OIB\Documents\Visual Studio 2008\Projects\test\test\Debug\BuildLog.htm"
test - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites