Now let's see an example of a lexical library function.
So in this window we have two programs p1 dot see.
The lower half has p1 dot see and the upper half has p2 dot c program.
So here each program has a main function.
And in p1 dot c we have a print saying that the process we are mentioning we are printing the process
id and then the P1 dot c calls in x equal and passes the location of program two's binary file and and
gives r1, r2, and R3 as command line arguments for P2 program and the P2 program prints the process
id and it mentions that this is a program called from x equal, and then it prints the arguments.
Command line arguments.
Let's compile this program and see the output in order to understand the lexical function call, let's
compile the program.
We have compiled p1 dot c.
Let's compile p2 dot c.
So here the point is p1 dot c is a separate program, and p2 dot c is a separate program.
And and p1 dot c is calling p2 from using the lexical function call.
Now let's execute p1.
So after executing p1 let's analyze the output we are getting in main process PID equal to 6616.
So this is coming from the first program from this line.
And we have got the process ID as 6616.
Then after this the program one has executed x equal by executing the x equal.
The first program virtual memory is replaced by the second program's virtual memory.
So after this we can see the output I am a new program called by x equal.
So this output is coming from the second program from this line.
Then if you see the command line arguments here argv0 Argv1 argv two corresponds to the argument that
is passed from program one.
And we have to pass a null here from the program one x equal.
So by this we can also point to be noted is this line from the program.
One is not printed.
If you see the output here we do not have any line corresponding to this print.
Here this means the program once virtual memory that comprises of text stack heap is completely replaced
by the program two's virtual memory, which is which is the stack text and data memory.
So x equal here replaces the existing program by the new program.
But the it remains under the same process