I have a question regarding pointers. When I iterate through a char array using pointer to char array in function, original array stays the same, but when I do it in main function, I can't print char array.
I am new to pointers.
void f(char* a)
{
    while (*a!=0) {
    *(a++); // going through array
    }
}
int main()
{
    char* a1 = "test";
    f(a1);
    cout <<a1<<endl; // I can normally print out "test"
    return 0;
}
But,
int main()
{
    char* a1 = "test";
    while (*a1!=0) {
    *(a1++);
    }
    cout <<a1<<endl; // won't print anything
    return 0;
}
So my question is, even though I am passing pointer to function, why is original array not modified?
 
     
     
     
     
     
     
     
     
    