Witam mam taki problem że zle alokuje pamięć ale bez kodu nie wytłumacze..
#include <iostream>
#include <stdio.h>
using namespace std;
struct point
{
int x;
int y;
string name;
};
int main()
{
int n;
int a;
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> a;
struct point *tab;
tab = (point *) malloc(sizeof(point) * a + 1);
for(int j = 0 ; j < a; j++)
{
cin >> tab[j].name >>tab[j].x >> tab[j].y;
//cout << tab[j].x << endl;
}
sortb(tab,a);
for(int j = 0 ; j < a; j++)
{
cout << tab[j].name << " " << tab[j].x << " " << tab[j].y << endl;
}
free(tab);
}
return 0;
}
Mniejsza o funkcje sort, gdy miałem zamiast string name tylko char to działało, bez problemu nawet sortowało, gdy daje string name to już mi to nie działa..
Niby piszę w języku C++, ale skorzystałem z malloca..