Even and odd indexed characters in a string in C++
<p>Given a string, S, of length N that is indexed from 0 to N-1, print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line. 0 will be considered as even index. Number of input strings can be T from 1 to 10. The program is giving correct results in codeblocks (offline) but not on HackerRank platform.
Its giving the error:</p>

<blockquote>
  <p>solution.cc: In function 'int main()':</p>
  
  <p>solution.cc:22:9: warning: 'char* gets(char*)' is deprecated (declared
  at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
           gets(g[i].s);
                     ^</p>
  
  <p>solution.cc:22:20: warning: 'char* gets(char*)' is deprecated
  (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
           gets(g[i].s);
                      ^</p>
  
  <p>/ccQXNkYE.o: In function <code>main': solution.cc:(.text.startup+0x4e):
  warning: the</code>gets' function is dangerous and should not be used.</p>
</blockquote>

<p>My code is:</p>

<pre><code>#include &lt;cstdio&gt;
#include &lt;iostream&gt;

struct str {
    char s[10000];
};

int main() {
    using namespace std;
    int T; 
    cin &gt;&gt; T;
    fflush(stdin);
    str g[10];
    for(int i = 0; i &lt; T; ++i) {
        gets(g[i].s);
        fflush(stdin);
    }
    for(int t = 0; t &lt; T; ++t) {
        int j = 0;
        while(j &lt; strlen(g[t].s)) {
            if(j % 2 == 0)
                cout &lt;&lt; g[t].s[j];
            ++j;
        }
        cout &lt;&lt; " ";
        int k = 0;
        while(k &lt; strlen(g[t].s)) {
            if(k % 2 == 1)
                cout &lt;&lt; g[t].s[k];
            ++k;
        }
        cout &lt;&lt; endl;
    }
    return 0;
}
</code></pre>