UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » How to change the argv[0] value

#1 2010-11-12 01:32 AM

toni
Guest

How to change the argv[0] value

int main(int argc, char *argv[])
{
     argv[0] = "test" ;
     printf("%s",argv[0]);
     //code 
     //code
}

#2 2010-11-12 03:00 PM

toni
Guest

Re: How to change the argv[0] value

i want to execute the file by using the command

test

and Not

./test

Is this possible ?

#3 2010-11-12 03:15 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: How to change the argv[0] value

Just add the current working directory to your PATH environment variable. E.g. add

PATH="$PATH:./"

to your ~/.bashrc.

Offline

#4 2010-11-12 06:07 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: How to change the argv[0] value

Offline

  • Index
  • » C
  • » How to change the argv[0] value

Board footer

Powered by FluxBB