0

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

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by jowana
0

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)
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.