Hello,
I wrote this simple program which prints all the arguments given to a program.
My code is straightforward and this is it
Code:
#include <stdio.h>
#include <malloc.h>
int i = 0;
int main(int argc, char** argv)
{
printf("\nargc == [%d]",argc);
printf("\nthe arguments are ");
for(i=0;i<argc;i++)
{
printf(&q
hi,
I am new in the shell script, and c programming with linux.
What my main is supposed to do is either read from stdin using system calls. Or if file arguments are given open the file arguments. I had already coded this to read from one file argument. But now I need it to open from multiple file arguments and I am short on the logic as to how to do this.
/*
* program accept argument from stdin as well as command line
* run it with
* echo "1 2 3" | ./a.out
* OR
* ./a.out 1 2 3
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
int fromstdin = 0;
int i = 1;
char infile[200];
if (argc == 1) fromstdin = 1;
if (fromstdin)
{
memset(infile, 0, 200);
while (scanf("%s", infile) != EOF
see i have below code
#include<stdio.h>
int main ( int argc, char *argv[] )
{
int i=0;
for(i=1;i<argc-1;i++)
printf(" %s \n",argv[i]);
return 0;
}
compiles and run as follows
gcc test.c
./a.out 1 * 2
and now its o/p is scarred..!
o/p is :
1
a.out
Desktop
Documents
Downloads
ipmsg.log
linux-fusion-3.2.6
Music
Pictures
Public
Te
Iam trying to execute a file that include many files but it seems my main copy.c can't read anyone of them
-----------------------------------------------------------------------------------------
Copy.c
Code:
#include <sys/stat.h>
#include <fcntl.h>
#include "tlpi_hdr.h"
#ifndef BUF_SIZE /* Allow "cc -D" to override definition */
#define BUF_SIZE 102
Code of baul :)
Code:
/*
* Hanx [Proyecto Fedora Peru] wth Code
* crc.c - app
*
* This program is private version, for anti-educational purposes and without any
* explicit or implicit warranty; in no event shall the author or
* contributors be liable for any direct, indirect or incidetal damages
I have a problem that when I run my script with no arguments I get the error
Code:
argv: Subscript out of range.
Code:
#!/bin/csh
set rdir = "/uniprg/chrisd/radon/trunk-radon/fradon/source-frt/new-frt"
if ($#argv == 0) then
echo "no arguments passed to radon3d-linear.com"
$rdir/uniseis << EOJ
echo "no arguments
I have a problem that when I run my script with no arguments I get the error
Code:
argv: Subscript out of range.
Code:
#!/bin/csh
set rdir = "/uniprg/chrisd/radon/trunk-radon/fradon/source-frt/new-frt"
if ($#argv == 0) then
echo "no arguments passed to radon3d-linear.com"
$rdir/uniseis << EOJ
echo "no arguments