title: How to get the release version of Linux in C
body: <p>EDIT:: I do not refer my question to utsname.h. Instead, I'm looking to get the distribution version e.g.: Ubuntu 20.04.1. (Just the numbers).</p>
  <p>I'm creating a function in C which return the build version on each OS. I already have it working on MS-Windows and macOS; However, I couldn't find anything to make it work on Linux(Ubuntu). Here is the code of my function with already works fine on MS-W and macOS.</p>
  <pre><code>struct OS_VERSION_LAT {
      double osMayor, osMenor, osBuild;
  };
  
  typedef struct OS_VERSION_LAT Struct;
  
  Struct buscar_os_version() { // Search the build version on each OS
      Struct os_v;
  
      #ifdef WIN32
          OSVERSIONINFO osvi;
  
          ZeroMemory(&amp;osvi, sizeof(OSVERSIONINFO));
          osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  
          GetVersionEx(&amp;osvi);
  
          os_v.osMayor = osvi.dwMajorVersion;
          os_v.osMenor = osvi.dwMinorVersion;
          os_v.osBuild = osvi.dwBuildNumber;
      #elif __APPLE__
          char cmd[64];
          for (int i=0; i&lt;=3; i++){
              sprintf(cmd, &quot;sw_vers -productVersion | awk -F '.' '{print $%d}'&quot;, i);
  
              FILE* stdoutFile = popen(cmd, &quot;r&quot;);
  
              int resp = 0;
              if (stdoutFile) {
                  char buff[16];
                  char *stdout = fgets(buff, sizeof(buff), stdoutFile);
                  pclose(stdoutFile);
                  sscanf(stdout, &quot;%d&quot;, &amp;resp);
              }
              switch(i) {
                  case 1:
                      os_v.osMayor = resp;
                  case 2:
                      os_v.osMenor = resp;
                  case 3:
                      os_v.osBuild = resp;
                      break;
              }
          }
      #else
      #endif
  
      return os_v;
  }
  </code></pre>