PNG * original;
original->readFromFile("in.png");
int width = original->width();
int height = original->height();
I'm getting a segmentation fault in this bit of code. What am I doing wrong?
PNG * original;
original->readFromFile("in.png");
int width = original->width();
int height = original->height();
I'm getting a segmentation fault in this bit of code. What am I doing wrong?
You must allocate memory, because original
it's just a pointer.
Like this:
PNG *original = new PNG();
You are dereferencing original
without first having assigned anything to it.
You declared it as a PNG *
but did not assign an object instance to that pointer.
Perhaps you don't need to use a pointer
PNG original;
original.readFromFile("in.png");
int width = original.width();
int height = original.height();
Despite what some newbies seem to think pointers are not obligatory.