Following code gives "Bus error: 10", though it works perfectly when n is changed to 30. I REALLY do NOT see any single reason for that error. Why do you think this is happening?
#include <algorithm>
#include <cstdio>
#define MAX 100000
using namespace std;
struct suffix
{
int cur;
};
suffix suffixes[MAX];
bool cmp(suffix a, suffix b)
{
return (a.cur <= b.cur);
}
int main()
{
int n = 1000;
sort(suffixes,suffixes + n,cmp);
return 0;
}