Initial commit
This commit is contained in:
36
kapitel10/pekare-till-pekare-ex2.c
Normal file
36
kapitel10/pekare-till-pekare-ex2.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#define LANGD 3
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
char *ord[LANGD];
|
||||
char *pc;
|
||||
char **ppc;
|
||||
|
||||
ord[0] = "hund";
|
||||
ord[1] = "katt";
|
||||
ord[2] = "kanin";
|
||||
|
||||
/* Skriv ut de tre strängarna */
|
||||
for (i = 0; i < LANGD; i++)
|
||||
{
|
||||
printf("%s\n", ord[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
/* Skriv ut tecken för tecken */
|
||||
for (i = 0; i < LANGD; i++)
|
||||
{
|
||||
ppc = ord + i;
|
||||
pc = *ppc;
|
||||
while (*pc != '\0')
|
||||
{
|
||||
printf("%c ", *pc);
|
||||
pc = pc + 1;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user