Created
May 23, 2017 15:16
-
-
Save dimenus/866cec1b75bfdc0c5394493cbc66909a to your computer and use it in GitHub Desktop.
dynamic array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct IntArray | |
{ | |
int Length; | |
int MaxLength; | |
int *Data; | |
}; | |
void PushToIntArray(struct IntArray *int_array, int value) | |
{ | |
if((int_array->Length + 1) >= int_array->MaxLength) { | |
//log errors or reallocate | |
return; | |
} | |
int_array->Data[int_array->Length] = value; | |
int_array->Length += 1; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment