when I run with abc as the input argument nothing prints, why?
#include<stdio.h>
void main(int argc, char* argv[])
{
if (argv[1]=="abc")
{
printf("1");
}
}
when I run with abc as the input argument nothing prints, why?
#include<stdio.h>
void main(int argc, char* argv[])
{
if (argv[1]=="abc")
{
printf("1");
}
}
To compare strings use strcmp()
as
if (strcmp(argv[1], "abc") == 0)
printf("1");
The way your are checking using ==
will compare 2 char *
pointers argv[1]
and `"abc".