Problem with pointers
i wanted to create a classroom exchange program using numbers as student and using pointers . i wrote this code wich seems to me correct but when i run it and give values to a and b . i still find them in their first classroom (c1 or c2) i don't know where the problem is , Here's the code : #include <iostream> using namespace std; int main() { int c1[] = {1,2,3,4}; int c2[] = {5,6,7,8}; int *p1; int *p2; int e,f; //exchange way int a,b; cout << "Choose 2 students to exchange between class 1 and class 2" << endl; cin >> a >> b ; p1 = &c1[a] ; p2 = &c2[b] ; cout <<"The students are : " << *p1 << " and " << *p2 << endl; e=*p1 ; f=*p2 ; c1[a] = f ; c2[b] = e ; cout << " Now student : " << c1[a] << " is in clss 2" << endl; cout << "And student : " << c2[b] << " is in class 1" << endl; return.0; }