It works fine but when I change char stuid [20]; to int stuid [20]; I get error on compilation like this.
binary >> no operator found which takes a right-hand operand of type int [20]...
It probably works for char because char* is treated as a c string. If you want to use operator>> on all the elements in the array you can use a loop to do that.
C++ has an overload operator >> for class ifstream when the right operand is of type char * or char[]. However it has no overloaded operator >> for class ifstream when the right operand is an array of any other type. You should enter elements of an array of type int in a cycle. Something as
for ( int i = 0; i < 20; i++ ) std::cin >> stuid[i];