delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/13/01:11:31

From: "Earlblunt" <earlblunt AT usa DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Pointer Usage
Date: Tue, 13 Oct 1998 10:52:01 -0700
Lines: 50
Organization: OEM USER
X-Newsreader: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
NNTP-Posting-Host: mr-84-181.tm.net.my
X-NNTP-Posting-Host: mr-84-181.tm.net.my
Message-ID: <3622bf31.0@news1.tm.net.my>
X-Trace: 13 Oct 1998 10:47:13 +0800, mr-84-181.tm.net.my
X-NNTP-Posting-Host: 202.188.95.15
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello,

I am new in C programming and now learning about pointers.
Could anyone check for me the codes below for the CORRECT usage of pointers?


int main()
{
char crispin[15] , *zunliang[15] ,  *fauzi[15];
int cris ,  *liew , *ogy;

strcpy(crispin, "He's in 2A.");
strcpy(zunliang, crispin);
strcpy(fauzi, zunliang);

printf("%s\n", crispin);
printf("%s\n", zunliang);
printf("%s\n", fauzi);

cris = 14;
liew = cris;
ogy = cris;

printf("Info on Crispin: %s and he is %d years old.\n", crispin, cris);
printf("Info on Liew Zunliang: %s and he is %d years old.\n", zunliang,
liew);
printf("Info on Mohd. Fauzi: %s and he is %d years old.\n", fauzi, ogy);

return 0;
}


/* OUTPUT:

He's in 2A.
He's in 2A.
He's in 2A.
Info on Crispin: He's in 2A. and he is 14 years old.
Info on Liew Zunliang: He's in 2A. and he is 14 years old.
Info on Mohd. Fauzi: He's in 2A. and he is 14 years old.

*/

--
Earlblunt

-----BEGIN PGP PUBLIC KEY BLOCK-----



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019