Article 5RWES Problem with a little piece of code in C

Problem with a little piece of code in C

by
FFX
from LinuxQuestions.org on (#5RWES)
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.

Benlatest?d=yIl2AUoC8zA latest?i=Nih3dpadvv8:hdTzZDwFLzQ:F7zBnMy latest?i=Nih3dpadvv8:hdTzZDwFLzQ:V_sGLiP latest?d=qj6IDK7rITs latest?i=Nih3dpadvv8:hdTzZDwFLzQ:gIN9vFw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments