I have the following code where I try to access the command line arguments but I am having trouble doing so.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char *argv) {
int fd = open("drawing.ppm", O_RDWR | O_CREAT | O_APPEND, 0700);
char colour[] = "0 0 0 ";
if(argv[1] == "red") {
char colour[] = "255 0 0 ";
}
printf("%s\n", &argv[1]);
int date = write(fd, colour, sizeof(colour));
close(fd);
}
When I run the code, the terminal displays 1▒
which is some weird unexpected symbol. Can someone please tell me why this isn't working?