parent
2e9eb14783
commit
799b2e2588
@ -0,0 +1,39 @@ |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
|
||||
int main() |
||||
{ |
||||
char vowels[] = { 'A', 'E', 'I', 'O', 'U' }; |
||||
char* pvowels = vowels; |
||||
|
||||
printf("Point the addresses\n"); |
||||
for (int i = 0; i < 5; i++) |
||||
{ |
||||
printf("&vowels[%d]: %p, pvowels + %d: %p, vowels + %d: %p\n", i, &vowels[i], i, pvowels + i, i, vowels + i); |
||||
} |
||||
|
||||
printf("\nPoint the values\n"); |
||||
for (int i = 0; i < 5; i++) |
||||
{ |
||||
printf("vowels[%d]: %c, *(pvowels + %d): %c, *(vowels + %d): %c\n", i, vowels[i], i, *(pvowels + i), i, *(vowels + i)); |
||||
} |
||||
|
||||
// Dynamic malloc for array
|
||||
int n = 4; |
||||
char* parr = (char*)malloc(n * sizeof(char)); |
||||
parr[0] = 'L'; |
||||
parr[1] = 'o'; |
||||
parr[2] = 'V'; |
||||
parr[3] = 'e'; |
||||
|
||||
for (int i = 0; i < n; i++) |
||||
{ |
||||
printf("%c", parr[i]); |
||||
} |
||||
|
||||
printf("\n"); |
||||
|
||||
free(parr); |
||||
|
||||
return 0; |
||||
} |
Loading…
Reference in new issue