c - int ** array changing value -


so have int **. contains pixel values. i'm trying change value of set number of pixel values; value 90, want change max level has create black edge of x amount of pixels. i've been messing around last hour , can't seem figure out how change actual value inside **

this have far:

int pgmdrawedge( int **pixels, int numrows, int numcols, int edgewidth, char **header ){     int i=0, j=0, count=0;      int intensity=atoi(header[2]);      while(count<edgewidth){         for(; i<numrows; i++){             for(; j<numcols; j++){                 pixels[i][j]=intensity;             }         }         count++;     }      return 0; } 

this main function call: pgmdrawcircle(pixel, rows, cols, circlecenterrow, circlecentercol, radius, header);

i think have right idea, mentioned above can't seem figure out how value change.

i don't think do, need allocate memory? it's being passed in main don't think need since full...correct?

as per request here pgmread:

int ** pgmread( char **header, int *numrows, int *numcols, file *in  ){     int i, j, temp, intensity;      fgets(header[0], maxsizeheadrow, in);     fgets(header[1], maxsizeheadrow, in);      fscanf(in, "%d %d", numcols, numrows);     fscanf(in, "%d", &intensity);     sprintf(header[2], "%d", intensity);      int **ptr=(int **)malloc(*numrows*sizeof(int *));     for(i=0; i<*numrows; i++){         ptr[i]=(int *)malloc(*numcols*sizeof(int));     }      for(i=0; i<*numrows; i++){         for(j=0; j<*numcols; j++){             fscanf(in, "%d", &temp);             ptr[i][j]=temp;          }     }      fclose(in);     return ptr; } 

in main function:

    int **pixel=null;     pixel=pgmread(header, &rows, &cols, in);  if(strcmp(argv[1],"-e")==0){     printf("edge drawing\n");     pgmdrawedge(pixel, rows, cols, edgewidth, header); } 

your pgmdrawedge pretty works test shows. problem elsewhere

#include <stdio.h> #include <stdlib.h> int pgmdrawedge( int **pixels, int numrows, int numcols, int edgewidth, char **header ){     int i=0, j=0, count=0;      int intensity=atoi(header[2]);      while(count<edgewidth){         for(; i<numrows; i++){             for(; j<numcols; j++){                 pixels[i][j]=intensity;             }         }         count++;     }      return 0; }  int main() {  char *header[]={"abc","def","90"};  int *x[2];  int l1[]={1,2,3,4};  int l2[]={5,6,7,8};  x[0]=l1;  x[1]=l2; pgmdrawedge(x,2,4,99,header); printf("result %d should %s", x[0][0], header[2] );     return(0) ; } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -