Hello, I have a problem to print the whole string in argv[4]. here's my code
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define XMAX 65
#define YMAX 32
char screen[XMAX][YMAX];
void printScreen(void);
void fill(int, int, char[]);
int main(int argc, char *argv[])
{ FILE *in;
int x, y,z;
char a;
if (argc!= 5)
{ fprintf(stderr,"Usage:\n\t%s <65x32 text file> <x> <y> <letter>\n",argv[0]);
exit(1);
}
in = fopen(argv[1],"r");
if (in == NULL)
{ perror("opening input file");
exit(1);
}
for (y=0; y<YMAX; y++)
{ for (x=0; x<XMAX; x++)
screen[x][y] = fgetc(in);
}
if (fclose(in))
{ perror("closing input file");
exit(1);
}
printScreen();
x = atoi(argv[2]);
y = atoi(argv[3]);
a = argv[4][0];
fill(x,y,a);
printScreen();
}
void printScreen(void)
{ int x,y;
for (y=0; y<YMAX; y++)
for (x=0; x<XMAX; x++)
if(screen[x][y]!= EOF)
putchar(screen[x][y]);
else
puts("\n");
}
void fill(int x, int y, char a)
{
if ((screen[x][y] != ' '))
return;
screen[x][y] = a;
fill(x,y+1,a);
fill(x,y-1,a);
fill(x+1,y,a);
fill(x-1,y,a);
}
In my code, i only able to print a character. How shoulld i change my code so that i can print the whole string in argv[4]. If i use argv[4][0], then it will only print the first element of the string in argv[4]