Mam kod:
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
struct osoba
{
string imie;
int numer;
};
int main()
{
int n;
scanf("%d", &n);
struct osoba uczestnicy[n];
for(int i = 0; i < n; i++)
{
scanf("%s", uczestnicy[i].imie);
scanf("%d", &uczestnicy[i].numer);
}
for(int i = 0; i < n; i++)
{
printf("%s ", uczestnicy[i].imie);
printf("%d", uczestnicy[i].numer);
printf("\n");
}
return 0;
}
Dostaję komunikaty:
In function 'int main()':
error: cannot pass objects of non-trivially-copyable type 'std::string {aka class std::basic_string<char>}' through '...'
warning: format '%s' expects argument of type 'char*', but argument 2 has type 'std::string {aka std::basic_string<char>}' [-Wformat]
error: cannot pass objects of non-trivially-copyable type 'std::string {aka class std::basic_string<char>}' through '...'
warning: format '%s' expects argument of type 'char*', but argument 2 has type 'std::string {aka std::basic_string<char>}' [-Wformat]
Kompilacja niepowodzenie: 2 błędów, 2 ostrzeżeń (0 min, 0 sek)
W jaki sposób mogę wczytać napis (ma mieć do 10 znaków) do structa i jak mogę go potem wypisać (nie używając cin i cout), żeby działało jak najszybciej.