Solved

invoke a process with a single argument?

Posted on 2000-03-15
4
305 Views
Last Modified: 2010-04-15
how can I invoke a process with a single argument
on the command line representing a number?
I mean,   the filename of the program is "game.c"
how can I input "game 1234"  to invoke this program
instead of inputting:
game
1234

Thanks!
0
Comment
Question by:huhulucy90
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 48 total points
ID: 2621616
#include <stdlib.h>
#include <stdio.h>
void main(int argc, char *argv[]){
  int number;
  if( argc != 2 ){
      printf("usage: %s 1234\n",argv[0]);
      exit(EXIT_FAILURE);
   }
   number = atoi(argv[1]);
   printf("%d\n",number);
   exit(EXIT_SUCCESS);
}
0
 
LVL 3

Expert Comment

by:terajiv
ID: 2622218
Hi,
invoke a process with a single argument...
U want the command line arguments and the example of which is given above by ozo. That is fine.
Have a Nice time...

Rajiv
0
 
LVL 1

Expert Comment

by:ntdragon
ID: 2622490
yeah you should use ozo's code for taht
and it you want to execute it from your prog use the command execl(...)
the "1234" goes as a parameter
0
 

Author Comment

by:huhulucy90
ID: 2624153
Thank you!
surprised to see the answer this fast!
so happy to find this place!
Lucy
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Compile VxWorks Toronado project under Visual Studio 11 194
Global Keyboard Hooks Blocked 4 76
IIS Log files on Exchange 2013 server 6 118
Acrinis True image 2 77
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question