Results 1 to 7 of 7
helo guzy .. well i m doing basic scripts ...
plz help me in regards i use this thread for queries .. plz reply
i write
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
int ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 11-11-2005 #1Linux Newbie
- Join Date
- Feb 2005
- Posts
- 137
script help required error trace
helo guzy .. well i m doing basic scripts ...
plz help me in regards i use this thread for queries .. plz reply
i write
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
int main(int argc, char **argv)
{
int i, j;
i=atoi(argv[1]);
j=atoi(argv[2]);
printf("%d",i+j);
}
named it as parm.c ... give it ... exe rights chmod 700 parm.c
now run
./parm.c
gives error ....
./parm.c: line 4: syntax error near unexpected token `('
./parm.c: line 4: `int main(int argc, char **argv)'
what to do thnx for replying:: i dont know even a single word of linux ::
- 11-11-2005 #2Linux Newbie
- Join Date
- Oct 2004
- Posts
- 158
You have to compile it, then run the compiled executable file:
Code:gcc -o parm parm.c # this made a file called "parm" - that's what -o is for ./parm
The ./ thing in front of the file name is to make the shell look for the parm file in your current directory.
- 11-11-2005 #3Linux Newbie
- Join Date
- Feb 2005
- Posts
- 137
thnx
thnx for replying man although a dumb step i have missed
... anywayz thxn ..
done ... all u said
giving segmentation fault ... but it should produce .o file
i think its not
so ..:: i dont know even a single word of linux ::
- 11-12-2005 #4Code:
#include<stdio.h> #include<unistd.h> #include<stdlib.h> int main( int argc, char **argv ) { if ( argv[1] && argv[2] ) { int i = atoi( argv[1] ); int j = atoi( argv[2] ); printf( "%d\n", i + j ); } else printf( "%s\n", "Hey, we need 2 parms!" ); }noobus in perpetuum
- 11-12-2005 #5Linux Newbie
- Join Date
- Feb 2005
- Posts
- 137
solved
thnx a lot problem solved i'll post other queries regarding scripts .. in this same thread .. thnx
:: i dont know even a single word of linux ::
- 11-13-2005 #6Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
If you call your C source code a "script", you're going to confuse people. A script is generally shorthand for "shellscript", a file containing commands that link together in some way to perform a more complex task.
- 11-14-2005 #7A script really just refers to a file written in any interpreted language, one of which C is most definitely not.
Originally Posted by scm


Reply With Quote
