Skip to content

Instantly share code, notes, and snippets.

@darkodemic
Created June 4, 2015 10:36
Show Gist options
  • Save darkodemic/cc1dff6f46092b4bd685 to your computer and use it in GitHub Desktop.
Save darkodemic/cc1dff6f46092b4bd685 to your computer and use it in GitHub Desktop.
array with pointers for printing
//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