Mail Archives: djgpp/1999/11/30/19:03:02
From: | steven DOT watson AT dtn DOT ntl DOT com
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | re: pointers
|
Date: | Tue, 30 Nov 1999 22:30:28 +0000
|
Organization: | NTL Internet News Service
|
Lines: | 58
|
Message-ID: | <38445004.1B9658C0@dtn.ntl.com>
|
NNTP-Posting-Host: | p149-harc2-kirklees2.tch.dtn.ntl.com
|
Mime-Version: | 1.0
|
X-Trace: | nclient3-gui.server.dtn.ntl.com 944001479 10158 194.168.246.119 (30 Nov 1999 22:37:59 GMT)
|
X-Complaints-To: | abuse AT net DOT ntl DOT com
|
NNTP-Posting-Date: | 30 Nov 1999 22:37:59 GMT
|
X-Mailer: | Mozilla 4.5 [en]C-CCK-MCD (Win95; I)
|
X-Accept-Language: | en
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
hi
I think I have solved my problem?
but I am still not sure that it is correct
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(void)
{
char text[]="pointer 1\n";
char text1[]="pointer 2\n";
int *pstring;
char *stringp;
int i;
printf("please enter number 2");
scanf("%i",&i);
pstring =(int *) malloc (i);/*wanting pointer to pointers but ?
*/
if (pstring== NULL)
printf("not enough memory\n");
stringp=(char *)malloc(sizeof(text));
if (stringp== NULL)
printf("not enough memory\n");
strcpy(stringp,text);
printf("%s should be pointer1 \n",stringp);
*pstring=(int)stringp;
printf("%s should be pointer 1\n",(int*) *pstring);
stringp=(char *)malloc(sizeof(text1));
if (stringp== NULL)
printf("not enough memory\n");
strcpy(stringp,text1);
*(++pstring)=(int)stringp;
printf("%s should be pointer 2 \n",(int *)*pstring);
*(--pstring);
printf("%s should be pointer 1\n",(int*)*pstring);
return 0;
}
sorry to answer my own mail!
Steven Watson
- Raw text -