|  | 
|  | 
| вернуться в форум | What does it mean? What does it mean? Runtime error (access violation)This is my code on c++
 #include <iostream>
 using namespace std;
 int n,ans;
 string s;
 int main()
 {
 cin>>n;
 ans=n+2;
 for(int i=0; i<n; i++)
 {
 cin>>s;
 for(int j=0; j<s.size()-3; j++)
 {
 if(s[j]=='+' && s[j+1]=='o' && s[j+2]=='n' && s[j+3]=='e')
 {
 ans++;
 break;
 }
 }
 }
 if(ans==13) ans++;
 cout<<100*ans;
 return 0;
 }
 
 Edited by author 31.05.2017 21:40
Re: What does it mean? for(int j=0; j<(int) s.size()-3; j++)
 
 Edited by author 31.05.2017 23:05
 
 Edited by author 31.05.2017 23:05
Re: What does it mean? The problem is "s. size() -3".The type of s. size()  is SIZE_T.  It is UNSIGNED.  So,  if s. length <=2,then SIZE_T overflows.  The result is a HUGE number.  And j goes out of range.
Re: What does it mean? "Access violation" means that you are trying to access some memory you are NOT SUPPOSED to access.
 Edited by author 31.05.2017 23:04
 | 
 | 
|