title: How can I compile C programs that use deprecated functions, such as gets()
body: <p>For a homework assignment, I have to try to use buffer overflows to crash a simple c program. My problem is that my compiler won't compile the <code>gets()</code> function because it is deprecated and unsafe. I understand this, but for the sake of the example, I'd like to override that.  Here is the code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char *argv[]) {
  
      int valid = 0;
  
      // Char arrays w/buffer set to 8 chars
      char str1[8];
      char str2[8];
  
      next_tag(str1);
  
      //This is where I want to use gets and not fgets or other secure functions...
      gets(str2);
  
      if(strncmp(str1, str2, 8) == 0) {
          valid = 1;
      }
  
      // Print
      printf("Buffer 1: str1(%s), str2(%s), valid(%d)\n", str1, str2, valid);
  
  
  }
  </code></pre>
  
  <p>My gcc version is:</p>
  
  <pre>
  rabbitfighter@ECHO:[~/Code/C/BufferOverflowExamples]: gcc -v
  
  Using built-in specs.
  COLLECT_GCC=gcc
  COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/lto-wrapper
  Target: x86_64-unknown-linux-gnu
  Configured with: /build/gcc/src/gcc-4.9-20140903/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl --disable-isl-version-check --disable-cloog-version-check --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib --disable-werror --enable-checking=release
  Thread model: posix
  gcc version 4.9.1 20140903 (prerelease) (GCC) 
  </pre>
  
  <p>If anyone can help me I would greatly appreciate it. I am running Manjaro Linux (Arch).</p>