Language: C

#include <stdio.h>
#define MAXN (400000)

class TrieNode {
public:
    bool exist;
    int  son_count;
    TrieNode* nodes[26]={0};
    TrieNode():son_count(0),exist(false){}
    TrieNode * & getNode(const char & chr)
    {
        return nodes[chr-'a'];
    }
}nodes[MAXN];

int nodes_cnt = 0;

class Trie {
public:
    Trie() {
        root = new TrieNode();
    }

    void insert(const char *  word) {
        TrieNode * now = root;
        while(*word)
        {
            now->son_count++;
            if(!now->getNode(*word))
                now = now->getNode(*word) = &nodes[nodes_cnt++];
            else
                now = now->getNode(*word);
            word++;
        }
        now->son_count ++;
        now->exist = true;
    }

    int get_rank(const char * word, const char * char_rank) {
        int rank = 1;
        TrieNode * now = root, *last = NULL, *tmp;
        while(*word)
        {
            for(int i = 0; char_rank[i] != *word; i++)
            {
                tmp = now->getNode(char_rank[i]);
                if(tmp)
                    rank+= tmp->son_count;
            }
            last = now;
            now = now->getNode(*word);
            word++;
            if(*word && last->exist)
                rank++;
        }
        return rank;
    }
private:
    TrieNode* root;
};
#define MAX_CHAR_LEN (1000000)
#define MAX_STR_CNT  (400000+5)

char char_buffer[MAX_CHAR_LEN];
char * str_table[MAX_STR_CNT];

int main()
{
    int N,Q,k;
    char char_rank[32], * ptr = char_buffer;
    Trie trie;
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        str_table[i] = ptr;
        scanf("%s",ptr);
        trie.insert(ptr);
        ptr += strlen(ptr) + 1;
    }
    scanf("%d",&Q);
    for(int i = 0; i < Q; i++)
    {
        scanf("%d%s", &k, char_rank);
        int rank = trie.get_rank(str_table[k-1], char_rank);
        printf("%d\n", rank);
    }
    //printf("%d")
    return 0;
}

Compiler output:
main.c:4:1: error: unknown type name 'class'
    4 | class TrieNode {
      | ^~~~~
main.c:4:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    4 | class TrieNode {
      |                ^
main.c:14:2: warning: data definition has no type or storage class
   14 | }nodes[MAXN];
      |  ^~~~~
main.c:14:2: error: type defaults to 'int' in declaration of 'nodes' [-Wimplicit-int]
main.c:18:1: error: unknown type name 'class'
   18 | class Trie {
      | ^~~~~
main.c:18:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   18 | class Trie {
      |            ^
main.c: In function 'main':
main.c:71:5: error: unknown type name 'Trie'
   71 |     Trie trie;
      |     ^~~~
main.c:77:13: error: request for member 'insert' in something not a structure or union
   77 |         trie.insert(ptr);
      |             ^
main.c:78:16: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
   78 |         ptr += strlen(ptr) + 1;
      |                ^~~~~~
main.c:2:1: note: include '<string.h>' or provide a declaration of 'strlen'
    1 | #include <stdio.h>
  +++ |+#include <string.h>
    2 | #define MAXN (400000)
main.c:78:16: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch]
   78 |         ptr += strlen(ptr) + 1;
      |                ^~~~~~
main.c:78:16: note: include '<string.h>' or provide a declaration of 'strlen'
main.c:84:24: error: request for member 'get_rank' in something not a structure or union
   84 |         int rank = trie.get_rank(str_table[k-1], char_rank);
      |                        ^