I'm reading an input string from the user with scanf().
I want to check if this string is NULL (\0) or not.
Here is my code:
#include<stdio.h>
char *argument; // argument for mycat
scanf("%s", &argument);
if(fork()==0) // at child
{
printf("Child process: about to execute \"mycat %s\"\n", &argument);
fflush(stdout);
if(strcmp(argument, "") == 0) // <-- Here is the problem
{
execlp("mycat", "mycat", &argument, NULL); // execute child process
}
execlp("mycat","mycat", NULL);
}
I'm compiling with g++ compiler on Red Hat 6.1
Edit: The problem is that I'm not able to dereference argument
either for the if
statement or even for use with strlen()
.