I only get this problem with this compiler ( MSVC++ 6.0 ).
Here is the code in question
Display is an unsigned char array. I get this errorCode:if ( Display [ x + ( y * max_width ) ] != 0 )
!?Code:error C2108: subscript is not of integral type
This is a discussion on MSVC++ error within the C++ Programming forums, part of the General Programming Boards category; I only get this problem with this compiler ( MSVC++ 6.0 ). Here is the code in question Code: if ...
I only get this problem with this compiler ( MSVC++ 6.0 ).
Here is the code in question
Display is an unsigned char array. I get this errorCode:if ( Display [ x + ( y * max_width ) ] != 0 )
!?Code:error C2108: subscript is not of integral type
What is C++?
MSVC doesn't like the stuff that is inside the [] for some reason..
I think [ x + ( y * max_width ) ] should resolve to an unsigned integer....
Try adding a cout << x + ( y * max_width ) and see what ye' get
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
std::cout << x + ( y * max_width );
that worked fine.
x, y, and max_width are floats. BUT I tried changing them to different types and it gives me the same error.
EDIT:
AH, I tried changing them to int again and it worked.
Lemme see if I can resolve the problem.
Last edited by Vicious; 09-26-2004 at 09:50 PM.
What is C++?
hmmm... a floating point array subscript may be your problem.. a simple cast to integer should fix the problem...
give this a try...
Code:display[(int)x +(int) ( y * max_width )]
Last edited by The Brain; 09-27-2004 at 02:30 AM.
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
I changed all of the variables involved to ints. I figured it would be faster that converting all the time.
Thanks for your help!
What is C++?
righteous.![]()
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel