Re: Pointers Problem



Manoj tr wrote:
hai all

char **argv; char *line1="Good Morning";
  char *line2="Good Evening";
how to copy line1 to the first index of argv and line2 to the second. ie argv[0], argv[1]; and how to retrive this line1 and line2

IMO, it's better not changing argv, if argv is the usual "main()" argv parameter.

If this isn't the case, argv shall have some memory allocated to it.

You can do, e.g. :

* char *argv[] = {"Good Morning", "Good Evening", NULL};

* char *argv[SOME_DIMENSION];
  char *line1="Good Morning";
  char *line2="Good Evening";
  argv[0] = line1;
  argv[1] = line2;

* char **argv;
  char *line1="Good Morning";
  char *line2="Good Evening";
  argv = (char **) malloc(SOME_DIMENSION * sizeof (*argv));
  argv[0] = line1;
  argv[1] = line2;

  This is a small problem in the case of experts. So i request that dont avoid it. Please send the replay

Manoj


--
 ---------------------------------------------------------------
 Jose Marcio MARTINS DA CRUZ           Tel. :(33) 01.40.51.93.41
 Ecole des Mines de Paris              http://j-chkmail.ensmp.fr
 60, bd Saint Michel                http://www.ensmp.fr/~martins
 75272 - PARIS CEDEX 06      mailto:Jose-Marcio Martins ensmp fr




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]