KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How does a pointer points to [-1]th index of the array produce legal output everytime. What is actually happening in the pointer assignment? #include<stdio.h> int main() { int realarray[10]; int *array = &realarray[-1]; printf("%p\n", (void *)array); return 0; } Code output: manav@workstation:~/knr$ gcc -Wall -pedantic ptr.c manav@workstation:~/knr$ ./a.out 0xbf841140 EDIT: If this scenario is valid, then can i use this to define an array whose index start from 1 instead of 0, namely: array[1], array[2],...
Tags (comma-separated)
Save Edits
Cancel