Results 1 to 1 of 1
Hai
i have some problem in C coding in Linux . I have three files m.c ,m2.sh and m3.c.
tha m.c contain any int value (take 10 ).
m2.sh contain ...
- 08-14-2005 #1Just Joined!
- Join Date
- Aug 2005
- Posts
- 19
coding in C
Hai
i have some problem in C coding in Linux . I have three files m.c ,m2.sh and m3.c.
tha m.c contain any int value (take 10 ).
m2.sh contain the shell script in below
read x < m.c
echo now we are in shell $x
here i change the mode of m2.sh using the Linux system call
i.e
$chmod 777 m2.sh
m3.c contains the C program
#include <stdio.h>
main(int argc,char *argv[])
{
int y;
FILe *fp;
fp=fopen("m.c","w");
y=atoi(argv[1]);
y=y+1;
fprintf(fp,"%d",y);
fclose(fp);
if(y<20)
{
printf("the y value is %d\n",y);
execlp("./m2.sh","m2.sh",NULL);
}
else
printf("the y value is %d\n",y);
}
the output of the C program is(if i pass the command line argument is 10)
the y value is 11
now we are in shell
now i check the m.c file
cat m.c that output is nothing(i.e empty in the file m.c, that is overwriting the empty space in tha vale 10 (if file value 10))
***********can anyone help me please*********************


Reply With Quote
