No, using C functions is very common. C functions are very very fast. Don't use C headers. ie #include <ctime> instead of #include <time.h>
Anyway, if I were you, I would write a structure to handle an array for you and a method to get specific items:
Code:
#include <iostream>
struct Array {
public:
Array(unsigned int width, unsigned int height){
w = width; h = height;
array = (int*)malloc(width * height * sizeof(int));
}
~Array(void){
free(array);
}
inline int & at(unsigned int x, unsigned int y){
assert(x < w);
assert(y < h);
return array[w * y + x];
}
private:
int * array;
unsigned int w, h;
};
int main(){
Array test(100, 150);
test.at(12, 43) = 15;
std::cout << test.at(12, 43) << std::endl;
return 0;
}
Bookmarks