今天天气好晴朗处处好风光,好天气好开始,图老师又来和大家分享啦。下面给大家推荐Access out of range,希望大家看完后也有个好心情,快快行动吧!
【 tulaoshi.com - 编程语言 】
suppose OneLineText is a string
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/bianchengyuyan/)Don't forget to check the index or it could be out of range! Lenthg checking must performe at first rather than access the char in the string or the string will be also out of range!
The following will be out of range because it may acces the character out of the rang before it check the boundary.
=============================================
while( isalpha( OneLineText.at( i ) ) && ( i LengthOfText ) )
{
i++ ;
}//end while
=============================================
The following code will be all right.
=============================================
while( ( i LengthOfText ) && isalpha( OneLineText.at( i ) ) )
{
i++ ;
}//end while
=============================================
来源:http://www.tulaoshi.com/n/20160219/1604456.html
看过《Access out of range》的人还看了以下文章 更多>>