1

I have an unordered_map containing a struct I created called groups, with int keys and basically want to print the map as if it was a list but for some reason its giving an error.

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <unordered_map>
#define UID "10014"

using namespace std;

typedef struct
{
    int num_users;
    char GNAME[26],GID[3];
    char UIDS[500][6];
}group;

std::unordered_map<int,group> groups;

int main()
{
    for (auto x : groups)
      cout << x.first << x.second endl;

   return(0);
}

The code gives me this error:

no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘group’)
       cout << x.first << " " << x.second << endl;
user4581301
  • 31,330
  • 6
  • 30
  • 51
Martim Correia
  • 471
  • 2
  • 12

0 Answers0