Language: C++

#include <cstdio>
#include <cstdlib>
#include <string>
#include <list>
#include <map>
using namespace std;

struct C
{
  string s;
  int x1;
  int y1;
  int x2;
  int y2;
  C ( int x1, int y1, int x2, int y2, const char *s )
  {
    this->x1 = x1;
    this->y1 = y1;
    this->x2 = x2;
    this->y2 = y2;
    this->s = s;
  }
};

int
main (
  int   argc,
  char *argv[ ]
  )
{
  list<C>::iterator it;
  int i;

  for ( ; ; )
  {
    map<string,list<C> > lis;
    list<string> buf;
    list<string> cont;
    int w, h;
    int n;

    scanf ( " %d", &n );
    if ( n == 0 ) break ;

    scanf ( " %d %d", &w, &h );
    while ( n-- )
    {
      list<C> r;
      char s[ 32 ];
      int c;

      scanf ( " %s %d", s, &c );
      if ( buf.empty ( ) )
        buf.push_back ( s );
      for ( i = 0; i < c; ++i )
      {
        int x1, y1, x2, y2;
        char t[ 32 ];

        scanf ( " %d %d %d %d %s", &x1, &y1, &x2, &y2, t );
        r.push_back ( C ( x1, y1, x2, y2, t ) );
      }
      lis[ s ] = r;
    }

    scanf ( " %d", &n );
    while ( n-- )
    {
      char cmd[ 32 ];

      scanf ( " %s", cmd );

      if ( strcmp ( "show", cmd ) == 0 )
      {
        puts ( buf.back ( ).c_str ( ) );
        continue ;
      }
      if ( strcmp ( "click", cmd ) == 0 )
      {
        list<C> *p;
        int x, y;

        scanf ( " %d %d", &x, &y );

        p = &lis[ buf.back ( ) ];
        for ( it = p->begin ( ); it != p->end ( ); ++it )
        {
          if ( x >= it->x1 && x <= it->x2
            && y >= it->y1 && y <= it->y2 )
          {
            buf.push_back ( it->s );
            cont.clear ( );
            break ;
          }
        }

        continue ;
      }
      if ( strcmp ( "back", cmd ) == 0 )
      {
        if ( buf.size ( ) >= 2 )
        {
          cont.push_front ( buf.back ( ) );
          buf.pop_back ( );
        }
        continue ;
      }
      if ( strcmp ( "forward", cmd ) == 0 )
      {
        if ( cont.size ( ) >= 1 )
        {
          buf.push_back ( cont.front ( ) );
          cont.pop_front ( );
        }
        continue ;
      }
    }
  }

  return ( EXIT_SUCCESS );
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:73:12: error: 'strcmp' was not declared in this scope
   73 |       if ( strcmp ( "show", cmd ) == 0 )
      |            ^~~~~~
a.cc:6:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <map>
  +++ |+#include <cstring>
    6 | using namespace std;
a.cc:78:12: error: 'strcmp' was not declared in this scope
   78 |       if ( strcmp ( "click", cmd ) == 0 )
      |            ^~~~~~
a.cc:78:12: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:99:12: error: 'strcmp' was not declared in this scope
   99 |       if ( strcmp ( "back", cmd ) == 0 )
      |            ^~~~~~
a.cc:99:12: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:108:12: error: 'strcmp' was not declared in this scope
  108 |       if ( strcmp ( "forward", cmd ) == 0 )
      |            ^~~~~~
a.cc:108:12: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'