Hi everyone. I got a total newbe question and i am new to c programming. I want to write a program that will executing commands , written in separate text file.
Lets say, in perl i got something like that:
open (F,"<file.txt");
$x = <F>;
if ($x == "2"){
system "whatever";}
In c i've stuck with something like:
int main()
{
FILE *fp;
fp=fopen("file.txt","r");
char s[256];
while( fgets(s, sizeof(s),fp)!= NULL)
{
system("xterm");
}
fclose(fp);
return 0;
}
what i'm trying to do in my newbe eyes should look maybe like:
int main()
{
FILE *fp;
fp=fopen("file.txt","r");
char s[256];
if( fgets(s,fp)==1)
{
system("xterm");
}
fclose(fp);
return 0;
}
but i realy cannot find solution anywhere, so maybe someone can help me with that...