I have written a code that maps to a shared memory location,so that the first program opens a shared memory block and stores some data in it.And the second program reads the shared data.
Whats the difference between the two command lines:
1.
if(argc<2)
{
printf("USAGE:%s text-to-share\n",argv[0]);
}
This code gives me a Segmentation Fault if I run it without the second argument.
However it works fine when I enter in some data.
2.
if(argc<2)
return printf("USAGE:%s text-to-share\n",argv[0]);
This one serves my purpose.
But I fail to understand the difference between the two.
I’m a novice.For me the two are same,because ideally they should have the same output.
Please Help!
why first statment giving you segmentation fault,in C it name of the program which you are executing,so it should be absolutely fine.I am able to execute this testcase properly
it output :
except you are doing something wrong in the code executed before this.