/MY PROGRAM ARE COMPILED IN FEDORA15 ..WITH 4.6 gcc compiler...../
/*A PROGRAM SHOWING USE OF POINTER OF ARRAY ...PREPAIRED FOR SINGLE ARGUMENT OF THREADS*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<pthread.h>
void anu(char*);
int main()
{
char* ptr;
int fd,wfd,count,i=0;
char *arr[5]={"fd","wfd","count","i","\0"};//THIS SINGLE ARGUMENT NOW COULD BE SEND THROUGH THREADS TO DO CLIENT -SERVER PROJECT USING THREADS
ptr=arr[0];
//for(i=0;i<=13;i++)
//printf("ptr=%c\n",*(ptr+i));
anu(ptr);
return 0;
}
void anu(char* str)
{
int i=0,j=0;
//for(i=0;i<=13;i++)
while(*(str+i))//1)suppose i=0.......it str+0 is not NULL..so enter into loop// 2)checks if ((str+3) has another string.....yes there is wfd...../// 3)NOW AT i=7 count..
{
sleep(1);
if(*(str+i)!='\0')// 1)further check// 2)2ND string wfd will be printed at address(str+3)..
{
printf("str=%s\n",(str+i));// 1)FROM (str+0) address...1st string is printed..///// 2)PRINT wfd
i=strlen(str+i);// 1)i=2 for fd//..len of string is calculated & put into i..// 2) strlen(wfd)==3
i++;// 1)AFTER that string one byte will NULL ..before other string start..i.e.after fd 1byte will be NULLHERE,....so increment to next...i=3//// 2)i==4..BUT i=4 do not have 3rd string..i.e.at i=7..so move.
i=i+j;// 1)j=0 already///i=3 still/// 2)i IS added to j which is 3 already bcz i was saved last time in j
j=i;// 1)j=6//SAVE value of i into j...to get string further//j=3 now...// 2)NOW j==7..so..on
When threads come into picture till that time linux is advanced so much such that it would b very difficult to incorporate thread library into it.
This is due to the fact that to incorporate it's library directly into linux lots of changes has to b made into linux operating system which was just like to start developing again linux from scratch as operating system which was not an advisible task.
So to use thread in linux we have to import thread library directly while compiling the code. ..
To import thread library we just use
-lpthread during compilation which means linkable posix thread..