array and point

Well basically i copied a program on youtube but the problem is i wont work. We are using different compilers.

here are my codes:
__________________________________________________________________
#include <cstdlib>
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
int intarr[10] = (1,2,3,4,5,6,7,8,9,10));
int i;
int *ptr=intarr;

for(i=0; i<10; i++)
{
printf("element %d value = %d \n", i, *ptr);
ptr++;
}


system("PAUSE");
return EXIT_SUCCESS;
}

______________________________________________________________
can anyone please fix it and tell me what i have done wrong?
Fixed the brackets around the numbers:
1
2
3
4
5
6
7
8
9
int intarr[10] = {1,2,3,4,5,6,7,8,9,10 };
int i;
int *ptr=intarr;

for(i=0; i<10; i++)
{
	printf("element %d value = %d \n", i, *ptr);
	ptr++;
} 
thanks it worked perfectly

now i have a next i need to show the addresses of the variable in each integer array element. I need to store addresses in pointers temporarily prior to displaying it.
i solved the problem by adding this

printf("Address of x: %p \n", *ptr);

am i correct.

another thing i need to do is to make the program sk the user to enter an address. The address should be stored in a temporary int variable, and then copied to the integer pointer.
Topic archived. No new replies allowed.