In my homework, I have to build a program using a struct with some fields. I have to output a list with the name of the "societate" field in an ascending order and the number of these fields.
So I tried to add all these fields into a new array while checking if the field is not already inside that array.
Here's how I tried to do it:
#include "stdafx.h"
#include <iostream>
#include <string.h>
using namespace std;
struct sponsorizari {
char societate[30], localitate[30];
int cod_sponsorizare, data, valoare;
};
int main()
{
int n, k = 0;
char a[100];
sponsorizari x[100];
cin >> n;
for (int i = 0; i < n; i++)
{
cin.get();
cin.get(x[i].societate, 30);
cin.get();
cin.get(x[i].localitate, 30);
cin.get();
cin >> x[i].cod_sponsorizare >> x[i].data >> x[i].valoare;
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < k; j++)
{
if (!strcmp(a[j], x[i].societate))
{
strcpy(a[k], x[i].societate);
k++;
}
}
}
}
It doesn't work - it gives me some errors. How can I make it work?

char[]overstd::string?