Hello everyone. I have a program that is getting errors when I try to call in functions. The functions are in a parse.o file that has been given to me. I am getting the following errors and I am having trouble understanding how to fix them. If anyone could help me with this I would be very grateful. Thank you
transform.c: In function âmainâ:
transform.c:14:14: error: expected expression before âFILEâ
transform.c:18:25: error: invalid operands to binary * (have âstruct pixel_t (*)[(long unsigned int)(g_width)]â and âlong unsigned intâ)
transform.c:20:13: error: expected expression before âFILEâ
transform.c:20:13: error: too few arguments to function âparseImageâ
transform.h:21:6: note: declared here
Here is the main file:
Code:
#include <stdio.h>
#include <stdlib.h>
#include "transform.h"
//void mirror(pixel_t *image, int x, int y);
int main(int argc, char *argv[])
{
int n;
int m;
char *input;
input=argv[1];
parseHeader(FILE *input);
pixel_t theArray[g_height][g_width];
input = malloc(theArray*sizeof(pixel_t));
parseImage(FILE *input, pixel *theArray);
//char r = theArray[x][y].r
//char g = theArray[x][y].g
//char b = theArray[x][y].b
printf("P6");
printf("%d %d\n 255", g_height, g_width);
switch (*argv[1])
{
case '1':
for(n=0; n <= g_height-1; n++)
{
for(m=0; m <= g_width-1; m++)
{
printf("%c%c%c", theArray[n][m].r, theArray[n][m].g, theArray[n][m].b);
++m;
}
}
//mirror(image, width, height);
break;
case '2':
//flip(image, width, height);
break;
case '3':
//rotate(image, height, width);
break;
default:
printf("Invalid command line argument. User must enter a 1, 2, or 3.\n");
break;
}
}
and here is my header file
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
unsigned char r;
unsigned char b;
unsigned char g;
} pixel_t;
pixel_t *input;
struct pixel {
char r, g, b;
};
int g_width, g_height;
void parseHeader( FILE *input );
void parseImage( FILE *input, struct pixel *theArray);