Problem with a bit of code in C
by FFX from LinuxQuestions.org on (#5RWER)
Hi,
I am new to C programming and I came across a problem. When I comiple and run the following code I get the output: You have entered +:
Code:#include <stdio.h>
int main(int argc, char *argv[])
{
if ((*argv[1]) == '+'){
printf("You have entered +");
}
return 0;
}
But when I compile and run the following code I get not output at all:
Code:#include <stdio.h>
int main(int argc, char *argv[])
{
if ((*argv[1]) == '*'){
printf("You have entered *");
}
return 0;
}So what is the problem and how can I dissolve this?
Thanks.
Ben
I am new to C programming and I came across a problem. When I comiple and run the following code I get the output: You have entered +:
Code:#include <stdio.h>
int main(int argc, char *argv[])
{
if ((*argv[1]) == '+'){
printf("You have entered +");
}
return 0;
}
But when I compile and run the following code I get not output at all:
Code:#include <stdio.h>
int main(int argc, char *argv[])
{
if ((*argv[1]) == '*'){
printf("You have entered *");
}
return 0;
}So what is the problem and how can I dissolve this?
Thanks.
Ben