<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Approximatrix Forums — [new user] Compile/build a pure C code (How to?/Examples?)]]></title>
		<link>https://forums.approximatrix.com/viewtopic.php?id=756</link>
		<atom:link href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=756&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in [new user] Compile/build a pure C code (How to?/Examples?).]]></description>
		<lastBuildDate>Fri, 12 Jun 2020 16:01:35 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: [new user] Compile/build a pure C code (How to?/Examples?)]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3507#p3507</link>
			<description><![CDATA[<p>Thank you, Jeff !</p>]]></description>
			<author><![CDATA[null@example.com (petran)]]></author>
			<pubDate>Fri, 12 Jun 2020 16:01:35 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3507#p3507</guid>
		</item>
		<item>
			<title><![CDATA[Re: [new user] Compile/build a pure C code (How to?/Examples?)]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3506#p3506</link>
			<description><![CDATA[<p>I&#039;m not sure why it wasn&#039;t appearing.&nbsp; My guess is that there is an issue flushing the standard output prior to awaiting input.&nbsp; It is considered a bug with Simply Fortran, and I&#039;ll look at it today.</p><p>You&#039;re still receiving an error because <em>main</em> functions are normally defined as:</p><div class="codebox"><pre><code>int main(int argc, char *argv[])</code></pre></div><p>and normally end with</p><div class="codebox"><pre><code>return 0; /* Or any exit code */</code></pre></div><p>The use of <em>exit(0)</em> in you code is a little surprising, especially if it&#039;s from a book.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Fri, 12 Jun 2020 14:14:41 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3506#p3506</guid>
		</item>
		<item>
			<title><![CDATA[Re: [new user] Compile/build a pure C code (How to?/Examples?)]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3505#p3505</link>
			<description><![CDATA[<p>Hello Jeff,</p><p>Thank you very much for your time and for the quick reply! I copied the example from a book and did not expect to have these bugs. Do you have an idea, why it isn&#039;t appearing in the Simply Fortran Console tab on Windows ? I received a compilation warning:<br />&nbsp; &nbsp; return type defaults to &#039;int&#039; [-Wimplicit-int]</p><p>Thank you in advance,<br />Peter</p>]]></description>
			<author><![CDATA[null@example.com (petran)]]></author>
			<pubDate>Fri, 12 Jun 2020 14:07:51 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3505#p3505</guid>
		</item>
		<item>
			<title><![CDATA[Re: [new user] Compile/build a pure C code (How to?/Examples?)]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3503#p3503</link>
			<description><![CDATA[<p>Peter,</p><p>Your code has a handful of problems that are not allowing it to compile.&nbsp; First, if you&#039;re going to call <em>printf</em> and <em>scanf</em>, you need to also include <strong>stdio.h</strong>.&nbsp; Second, if you&#039;re going to call <em>exit</em>, you need to include <strong>stdlib.h</strong>.&nbsp; Third, there is a syntax error on line 29 that the compiler correctly flags:</p><div class="codebox"><pre><code>.\alone.c:29:25: error: expected &#039;;&#039; before &#039;)&#039; token
   29 |    xl = (-b-sqrt(D))/2*a);
      |                         ^</code></pre></div><p>If you look at line 30, it probably should look more like that.</p><p>With those changes, the code does run, though it isn&#039;t appearing in the Simply Fortran Console tab on Windows.&nbsp; It works fine by running in an external console, though.&nbsp; The modified code is:</p><div class="codebox"><pre><code>/* Program quad_root.c */

#include &lt;math.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

main(){
   float a, b, c;
   float xl, x2;
   float D;

   printf(&quot;Enter coefficient a:&quot;);
   scanf(&quot;%f&quot;,&amp;a);
   /* test for quadratic */
   if (a==0){
     printf(&quot;Illegal quadratic!\n&quot;);
     exit(0) ;
   }
   printf(&quot;Enter coefficient b:&quot;);
   scanf(&quot;%f&quot;,&amp;b);
   printf(&quot;Enter coefficient c: &quot; ) ;
   scanf(&quot;%f&quot;,&amp;c);
   /* Compute argument for square root and
      test for complex roots */
   D = b*b - (4*a*c);
   if(D &lt; 0){
     printf(&quot;complex roots! \n&quot;);
     exit(0);
   }
   /* Compute roots of quadratic*/
   xl = (-b-sqrt(D))/(2*a);
   x2 = (-b+sqrt(D))/(2*a);
   /* Output the results*/
   printf(&quot;xl = %f\n&quot;,xl);
   printf(&quot;x2 = %f\n&quot;,x2);
   exit(0);
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Fri, 12 Jun 2020 11:28:30 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3503#p3503</guid>
		</item>
		<item>
			<title><![CDATA[[new user] Compile/build a pure C code (How to?/Examples?)]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3502#p3502</link>
			<description><![CDATA[<p>Hello,</p><p>I am a new user of SF.</p><p>I could successfully compile Fortran code. I would like now to compile a pure C code. I tried it with a simple code (see below) but it didn&#039;t work. Could you please give me a feedback, why this simple code doesn&#039;t work?</p><p>Thank you in advance,<br />Peter</p><p>/* Program quad_root.c */</p><p>#include &lt;math.h&gt;</p><p>main(){<br />&nbsp; &nbsp;float a, b, c;<br />&nbsp; &nbsp;float xl, x2;<br />&nbsp; &nbsp;float D;</p><p>&nbsp; &nbsp;printf(&quot;Enter coefficient a:&quot;);<br />&nbsp; &nbsp;scanf(&quot;%f&quot;,&amp;a);<br />&nbsp; &nbsp;/* test for quadratic */<br />&nbsp; &nbsp;if (a==0){<br />&nbsp; &nbsp; &nbsp;printf(&quot;Illegal quadratic!\n&quot;);<br />&nbsp; &nbsp; &nbsp;exit(0) ;<br />&nbsp; &nbsp;}<br />&nbsp; &nbsp;printf(&quot;Enter coefficient b:&quot;);<br />&nbsp; &nbsp;scanf(&quot;%f&quot;,&amp;b);<br />&nbsp; &nbsp;printf(&quot;Enter coefficient c: &quot; ) ;<br />&nbsp; &nbsp;scanf(&quot;%f&quot;,&amp;c);<br />&nbsp; &nbsp;/* Compute argument for square root and<br />&nbsp; &nbsp; &nbsp; test for complex roots */<br />&nbsp; &nbsp;D = b*b - (4*a*c);<br />&nbsp; &nbsp;if(D &lt; 0){<br />&nbsp; &nbsp; &nbsp;printf(&quot;complex roots! \n&quot;);<br />&nbsp; &nbsp; &nbsp;exit(0);<br />&nbsp; &nbsp;}<br />&nbsp; &nbsp;/* Compute roots of quadratic*/<br />&nbsp; &nbsp;xl = (-b-sqrt(D))/2*a);<br />&nbsp; &nbsp;x2 = (-b+sqrt(D))/(2*a);<br />&nbsp; &nbsp;/* Output the results*/<br />&nbsp; &nbsp;printf(&quot;xl = %f\n&quot;,xl);<br />&nbsp; &nbsp;printf(&quot;x2 = %f\n&quot;,x2);<br />&nbsp; &nbsp;exit(0);<br />}</p>]]></description>
			<author><![CDATA[null@example.com (petran)]]></author>
			<pubDate>Fri, 12 Jun 2020 09:10:53 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3502#p3502</guid>
		</item>
	</channel>
</rss>
