Solved

invoke a process with a single argument?

Posted on 2000-03-15
4
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

751 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