Possible Duplicate:
Similarities and differences between arrays and pointers through a practical example
I used to take them as the same referring to an array name. But now I have encountered an error, that is, when I use int *path and try to access the members of the array, the compiler gets a SIGSEGV(Which I never remembered to have happened in the code I have written before), but I it’s okay when I use int path[].
So why am I getting a SIGSEGV when using int *path ?
Just guessing you are trying to write to an array you have declared in the two possible, not equivalent, ways:
but
In the first case, path is a pointer to a “static” “list” put somewhere. You have just the pointer to it, can read the content, but likely if you try to write on it, you have segmentation fault. (Likely since those data could be in a memory you can write to even if often it happens you can’t, but it depends on the system).
In the second case, an area on the stack is reserved, big enough to hold the data, which then are copied into that area. In this case, you can both read and write to it.
edit
as noticed in comments the first example gives warning, you will need a cast (int []) to compile without warning. Then, let us suppose the array is created somewhere where you can’t write to, though it could not be the case.