Hi,

what does this error mean?

: error C2440: 'initializing' : cannot convert from 'char' to 'const char *'

i'm trying to read an image from a file using this code:


#include "itkImage.h"
#include "itkImageFileReader.h"

int main( int , char * argv)
{

typedef unsigned char PixelType;
const unsigned int Dimension = 2;

typedef itk::Image<unsigned short, 2> ImageType;

typedef itk::ImageFileReader< ImageType > ReaderType;

ReaderType::Pointer reader = ReaderType::New();

const char * filename = argv[1];
reader->SetFileName( filename );

reader->Update();

ImageType::Pointer image = reader->GetOutput();


return 0;
}

what is wrong?
I already took this code from the ITK librray.

jowana

Recommended Answers

All 2 Replies

You've defined argv as a pointer to char. It needs to be either an array of pointers to char, or a pointer to pointer to char:

int main(int argc, char *argv[])
int main(int argc, char **argv)

Thank you this was helpful .

but still, i cant build this program (0 succeeded), it gave me more errors now .
Is there anything wrong wih this program ?

Thank you

jowana

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.