I11 Answer


#include <stdlib.h>
#include <stdio.h>
#include "basicImage.c"

int main ( int argc, char* argv[] )
{
  image img ;
  int r, c;
  int nrows, ncols, constVal;

  if ( argc != 5 )
  {
    printf("constImage fileName nrows ncols const\n");
    return EXIT_SUCCESS;
  }

  nrows = atoi( argv[2] );
  ncols = atoi( argv[3] );
  constVal = atoi( argv[4] );

  if ( newImage( &img, nrows, ncols ) == NULL )
  {
    printf(">>error<< can't allocate memory\n");
    system( "pause" );
    return;
  }

  for ( r = 0; r<img.nrows; r++ )
    for ( c = 0; c<img.ncols; c++ )
      setPixel( img, r, c, constVal );
 
  writePGMimage( img, argv[1]);
  freeImage( &img );
}


Comments:

If you are not using projects, make sure that the file basicImage.c is located in the same directory as the source file for your answer. See the introduction to this section for a discussion of basicImage.c .


back