Skip to content

Instantly share code, notes, and snippets.

@k1mny
Created June 29, 2017 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k1mny/c70a5c2c700f992b3cd8a5fb084aa8cd to your computer and use it in GitHub Desktop.
Save k1mny/c70a5c2c700f992b3cd8a5fb084aa8cd to your computer and use it in GitHub Desktop.
C++でSegmentation fault: 11とBus error: 10が出てしまうときの一例
#include <iostream>
using namespace std;
int A[10][10];
int main() {
memset(A,0,sizeof(A));
//Bus error
for(int i=0; i<10; i++) {
for(int j=0; j<10; i++) {
cout << A[i][j] << " ";
}
cout << endl;
}
}
#include <iostream>
using namespace std;
int main() {
int A[10][10];
memset(A,0,sizeof(A));
//Segmentation fault
for(int i=0; i<10; i++) {
for(int j=0; j<10; i++) {
cout << A[i][j] << " ";
}
cout << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment