Need some help initializing an array
Hi, Im trying to initialize the counter array to all zeros, but I keep getting this error when trying to compile:
xray.cpp:30: error: variable-sized object ‘counter’ may not be initialized
Code:
#include <iostream>
#include <stdio.h>
#include "CImg.h"
using namespace cimg_library;
//main program
int main()
{
CImg<double> img("xray.jpg");
//retrieve image dimensions
const unsigned int width = img.dimx();
const unsigned int height = img.dimy();
//converts the image to black and white
img.RGBtoYCbCr().channel(0).resize(-100,-100,1,3).RGBtoLUT(CImg<>(2,1,1,3).fill(0.0f,255.0f),false);
//displays image
CImgDisplay display(img,"Black and White");
while (!display.is_closed)
display.wait();
//display dimensions
printf("The height of the image is %d\n",height);
printf("The width of the image is %d\n",width);
//initialize counter array of size height
int counter[height]={0};
//go through image one row at a time from left to right
for (int i=0;i<width;i++)
{
for (int j=0;j<height;j++)
{
//if pixel equals white
//add total number of white pixels to counter
}
}
return 0;
}