Pointers
May 3, 2010 at 6:13pm UTC
Respected Fellow members, I am not that much expert in C++, however when practicing pointers I encountered following problem.
I am trying to implement the following code obtained form
http://www.functionx.com/cpp/Lesson13.htm
#include <iostream>
using namespace std;
int main()
{
int students;
int *ptrStudents;
ptrStudents = &students;
cout << "Number of students: ";
cin >> *ptrStudents;
cout << "\nNumber of students: " << students
<< "\nThat is: " << *ptrStudents << " students.";
cout << "\n\n";
return 0;
}
However, at the underlined line, i am receiving the msg
error C2100: illegal indirection
pls help
May 3, 2010 at 6:22pm UTC
The code compiles and works correctly for me.
May 3, 2010 at 6:31pm UTC
The code compiles and works correctly for me.
Same here.
May 3, 2010 at 7:37pm UTC
The code compiles and works correctly for me.
Same here.
-Albatross
May 5, 2010 at 12:05pm UTC
This is what your compiler complains about:
http://msdn.microsoft.com/en-us/library/bzf3eha6%28VS.71%29.aspx
That is you try to dereference something that is not a pointer.
But the piece of code here works ok. Maybe when you were pasting/typing it in your compiler editor you missed an asterisk (*) in the declaration of ptrStudents...
Topic archived. No new replies allowed.