if i type in the following code i know that p will output the memory address of the first element, *p will output the value of the first element,p[a] will output the value of the element in b with the index number a and &p[a] will output the memory address of the same...
and when i typed this in i was right:
Code:
#include <iostream>
using namespace std;
int main(){
int *p;
int b[10] = {1234,12,351,25,235,123,5,235,1235,000};
p = b;
for(int a = 0; a < 10; a++){
cout << p << "\t" << *p << "\t" << p[a] << &p[a] << endl;
}
}
but when i try the same code with char datatype it doesn't work out well:
Code:
#include <iostream>
using namespace std;
int main(){
char *p;
char b[5] = {'a','a','z','a','d'};
p = b;
for(int a = 0; a < 10; a++){
cout << p << "\t" << *p << "\t" << p[a] << &p[a] << endl;
}
}
please friends out there, help me...