Created
June 4, 2015 10:36
-
-
Save darkodemic/cc1dff6f46092b4bd685 to your computer and use it in GitHub Desktop.
array with pointers for printing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Pointeri | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
//preprocessor | |
int main(){ | |
int array[5]; | |
for(int i = 0; i < 5; i++){ | |
printf("Unesite %d. clan niza: ", i+1); | |
scanf("%d",&array[i]); | |
} | |
puts("Unesite element niza koji zelite da ispisete: "); | |
int a=0; | |
scanf("%d",&a); | |
printf("%d. clan niza je: %d\n",a,array[a-1]); | |
int *p = &array[0]; | |
for(int i = 0; i < a-1; p++,i++); | |
printf("%d. clan niza je: %d",a,*p); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment