title: What is format specifier for `long double`
body: <p>I am working on application which works on various flavors of Unix and Windows 32bit and 64bit OS.</p>
  
  <p>I am using <code>long double</code> data type, When I do <code>sprintf()</code> and used <code>long double</code> with <code>%lf</code>  in it then it works fine with windows does not give any kind of error, however on Solaris platform it gives core dump.</p>
  
  <p>Sample code for the same issue is as following.</p>
  
  <pre><code>void main(){
      string size = "16622";
      string sizeFact = "20";
      long long sizeLongLong = strtoll(size);
      int factInt = atoi(sizeFact);
      long double sizeLongDouble = (long double) sizeLongLong/pow(2, factInt);
      char buf[512];
      sprintf(buf, "%.3lf %s", sizeLongDouble, "str");    
  }
  </code></pre>
  
  <p>As mentioned above code works fine on windows 32bit and 64bit however for sprintf it gives me core on Solaris.</p>
  
  <p>I tried type casting in sprintf it worked fine.</p>
  
  <pre><code>sprintf(buf, "%.3lf %s", (double) sizeLongDouble, "str");
  </code></pre>
  
  <p>What is the format specifier for <code>long double</code>?</p>
  
  <p>What is the mistake I am making here, am I using wrong format specifier because of which it is giving core?</p>
  
  <p>Why do I need to type cast one more time in sprintf()?</p>