<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>DaniWeb IT Discussion Community - C</title>
		<link>http://www.daniweb.com/forums</link>
		<description><![CDATA[Our C forum is the place for Q&A-style discussions related to the C language as per the ANSI C standard. Otherwise use our C++ forum.]]></description>
		<language>en-US</language>
		<lastBuildDate>Tue, 13 May 2008 22:46:34 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.daniweb.com/forums/myimages/misc/rss.jpg</url>
			<title>DaniWeb IT Discussion Community - C</title>
			<link>http://www.daniweb.com/forums</link>
		</image>
		<item>
			<title>End of file</title>
			<link>http://www.daniweb.com/forums/thread124018.html</link>
			<pubDate>Tue, 13 May 2008 13:07:51 GMT</pubDate>
			<description>Hi,

I want to do the following steps one by one

1. check whether given file is exists in the directory or not
2. if exists open the file
3.read the first line and store the values
4. got to the last line of file and store the values
5. close the file
6. if file does not exists come out of the...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I want to do the following steps one by one<br />
<br />
1. check whether given file is exists in the directory or not<br />
2. if exists open the file<br />
3.read the first line and store the values<br />
4. got to the last line of file and store the values<br />
5. close the file<br />
6. if file does not exists come out of the program.<br />
<br />
Pls Provide the sample coding  to do this..</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>nagaa</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread124018.html</guid>
		</item>
		<item>
			<title>File Integirty Check</title>
			<link>http://www.daniweb.com/forums/thread124012.html</link>
			<pubDate>Tue, 13 May 2008 12:45:56 GMT</pubDate>
			<description>Hi All,

Any sample program in c for file integrity check..

Regards,
Nagaa</description>
			<content:encoded><![CDATA[<div>Hi All,<br />
<br />
Any sample program in c for file integrity check..<br />
<br />
Regards,<br />
Nagaa</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>nagaa</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread124012.html</guid>
		</item>
		<item>
			<title>Loading a structure (text lines) from a file, modify the structure, then save</title>
			<link>http://www.daniweb.com/forums/thread123980.html</link>
			<pubDate>Tue, 13 May 2008 09:56:30 GMT</pubDate>
			<description><![CDATA[Hey everyone. Glad to become part of this community and I hope I continue to come here for a long time seeing as this site gives great helps. My problem:

I have a struct that is (for example) the following:

 <div class="codeblock"> <div class="spaced"> <div class="light" style="float:right"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hey everyone. Glad to become part of this community and I hope I continue to come here for a long time seeing as this site gives great helps. My problem:<br />
<br />
I have a struct that is (for example) the following:<br />
<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><br />
#define NUM 999<br />
<br />
struct client<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int id;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char name[15]; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char lastname[15]; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int telephone; <br />
}c[NUM]; </code> </div>
<br />
I want to do the following: First I want to see if the file exists or not. Thats pretty simple using a pointer to the fopen function with the file; If it returns NULL it doesnt exist. Now the hard part is reading and loading and then after saving.<br />
<br />
If it isnt found, all the struct will be set to the number/string 0. If its found, then all of the data from the text file is loaded onto the struct and I work with the struct modifing, deleteing, adding, etc.<br />
At the end of the program when I hit enter, Id like for the program to save all (or the changes) to the text file so when I load the program again it has all the additions I previously made.<br />
<br />
If Im not clear on something, go ahead and ask. Thank you very much for your help.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>riahc3</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123980.html</guid>
		</item>
		<item>
			<title>Random numbers (finding odd and even numbers)</title>
			<link>http://www.daniweb.com/forums/thread123917.html</link>
			<pubDate>Mon, 12 May 2008 22:24:49 GMT</pubDate>
			<description><![CDATA[hello i have got little problem :)
create a c program which starts with 3 processes the first proccess generates 50 random numbers and writes them inti common memory. the second proccess reads them and whrites the even numbers in file A,the odd numbers in file B.
 <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>hello i have got little problem :)<br />
create a c program which starts with 3 processes the first proccess generates 50 random numbers and writes them inti common memory. the second proccess reads them and whrites the even numbers in file A,the odd numbers in file B.<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;stdlib.h&gt;<br />
#include &lt;stdio.h&gt;<br />
<br />
int main(void)<br />
{<br />
&nbsp; &nbsp; int A;<br />
&nbsp; &nbsp; srand(time(0));<br />
&nbsp; &nbsp; for (A = 0; A &lt; 50; ++A) {<br />
&nbsp; &nbsp; &nbsp;  int number;<br />
<br />
&nbsp; &nbsp; &nbsp;  number = rand();<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;%d\n&quot;);<br />
<br />
&nbsp; }<br />
&nbsp; return 0;<br />
}</code> </div>
i create first part of the program i also know how to find odd and even numbers<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left">if ( x % 2 == 0 ) { //even<br />
&nbsp;<br />
} else { /odd<br />
&nbsp;<br />
}</code> </div>
i know that i must insert &quot;fd = open(&quot;blabla&quot;,O_RDWR|O_CREAT,0)&quot; after &quot;if&quot;  but my knowlodge isnt enogh :(<br />
thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>satanix</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123917.html</guid>
		</item>
		<item>
			<title>Stack problem</title>
			<link>http://www.daniweb.com/forums/thread123898.html</link>
			<pubDate>Mon, 12 May 2008 19:37:50 GMT</pubDate>
			<description><![CDATA[Hi, I've have a problem of printing data from stack, if it's simple words,then stack works just fine,but if I try to push changed data using function(Written by a very intelligent moderator :) ), I get just the same word n times:
Intelect
Intelect
Intelect
....
 <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hi, I've have a problem of printing data from stack, if it's simple words,then stack works just fine,but if I try to push changed data using function(Written by a very intelligent moderator :) ), I get just the same word n times:<br />
Intelect<br />
Intelect<br />
Intelect<br />
....<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left">#include&lt;stdio.h&gt;<br />
#include&lt;stdlib.h&gt;<br />
#include &lt;string.h&gt;<br />
//-------------------Function--------------------------------------------<br />
char AD(char *record, char *record_out)<br />
{<br />
&nbsp; &nbsp; char *p1 = record;<br />
&nbsp; &nbsp; char *p2 = record_out;<br />
<br />
&nbsp; &nbsp;  while( *p1 )<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; // use temp pointer to locate<br />
&nbsp; &nbsp; &nbsp; &nbsp; // end of digits<br />
&nbsp; &nbsp; &nbsp; &nbsp; char* p3 = p1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while( isdigit(*p3) )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p3++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; // is there a space following the digits ?<br />
&nbsp; &nbsp; &nbsp; &nbsp; if( *p3 == ' ')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // yes, then skip the space and move on to the next char<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p1 = p3+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // no, then was the last char put into temp buffer<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // a space<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( *(p2-1) == ' ')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // yes, then overwrite that space with a new character<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p2--;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p1 = p3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; // copy all characters up to the next digit<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(*p1 &amp;&amp; !isdigit(*p1) )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *p2++ = *p1++;<br />
&nbsp; &nbsp; }<br />
&nbsp;  <br />
}<br />
//------------------------------------------------------------------------------<br />
struct stack {<br />
&nbsp; &nbsp; &nbsp;  char *d;//data<br />
&nbsp; &nbsp; &nbsp;  struct stack *next;//pointer<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; };&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
typedef struct stack ELEMENT; <br />
typedef ELEMENT *POINTER;<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;<br />
void push(POINTER *Top, char *a)<br />
/* put a into the top of the stack */<br />
{<br />
POINTER temp;<br />
temp = malloc(sizeof(ELEMENT));<br />
temp-&gt;d= a;&nbsp; <br />
temp-&gt;next = *Top;<br />
*Top = temp;<br />
}<br />
<br />
void print_stack(POINTER Top){<br />
POINTER copy= Top;<br />
while(copy!=NULL)<br />
{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
printf(&quot;%s\n&quot;,copy-&gt;d);<br />
copy=copy-&gt;next;<br />
}<br />
}<br />
<br />
int main()<br />
{<br />
&nbsp;  POINTER start = NULL;<br />
&nbsp;  char *DELIMITERS = &quot; &quot;;&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; char *str,record[100],*o;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char line[]=&quot;jjj&nbsp;  yyyy dfsfsd sdfsdf sdfsdfsdf sdfsdfsfd sdfasdfafs Intelect&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; str = strtok(line, DELIMITERS);<br />
&nbsp; &nbsp; char recordd[sizeof(record)] = {0};<br />
<br />
while (str)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; AD(str, recordd);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  //Changing word with function(actually line,but if it works with word,then...good)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // printf(&quot;%s\n&quot;,recordd);&nbsp;  <br />
&nbsp; o = recordd;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; <br />
&nbsp; // str=o;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // But if I just try to push changed word(With function which IS needed) function<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // print_stack(start) prints stack for n times ????<br />
&nbsp; <br />
&nbsp; push(&amp;start,str); //push the word ... and this part works!!!<br />
&nbsp; <br />
&nbsp; <br />
&nbsp; <br />
&nbsp; str = strtok(NULL, DELIMITERS);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
print_stack(start); //print stack..works, print changed words - don't...<br />
&nbsp; <br />
<br />
system(&quot;pause&quot;);<br />
}</code> </div>
So, should I try to change stack or maybe there is another/easier way?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Onixtender</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123898.html</guid>
		</item>
		<item>
			<title>random number</title>
			<link>http://www.daniweb.com/forums/thread123892.html</link>
			<pubDate>Mon, 12 May 2008 18:19:30 GMT</pubDate>
			<description><![CDATA[i'm trying to get random numbers in a loop like this

#include <stdio.h>
#include <time.h>

int getRand ( int a , int b ) 
{	
  return a+rand()%(b-a+1);
}]]></description>
			<content:encoded><![CDATA[<div>i'm trying to get random numbers in a loop like this<br />
<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1">#include &lt;stdio.h&gt;<br /></div></li><li class="li1"><div class="de1">#include &lt;time.h&gt;<br /></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">int getRand ( int a , int b ) <br /></div></li><li class="li2"><div class="de2">{&nbsp; &nbsp; &nbsp; &nbsp; <br /></div></li><li class="li1"><div class="de1">&nbsp; return a+rand()%(b-a+1);<br /></div></li><li class="li1"><div class="de1">}<br /></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">int main()<br /></div></li><li class="li2"><div class="de2">{<br /></div></li><li class="li1"><div class="de1">srand ( time( NULL ) ) ;<br /></div></li><li class="li1"><div class="de1">int i;<br /></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">for(i=0 ; i&lt;6 ; i++)<br /></div></li><li class="li2"><div class="de2">printf(&quot;%d\n&quot;,getRand(0,9));<br /></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">return 0;<br /></div></li><li class="li1"><div class="de1">}</div></li></ol></pre></code> </div>
<br />
the problem is that i keep getting the same number</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>emilio</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123892.html</guid>
		</item>
		<item>
			<title>Validating Algorithms</title>
			<link>http://www.daniweb.com/forums/thread123864.html</link>
			<pubDate>Mon, 12 May 2008 14:31:14 GMT</pubDate>
			<description><![CDATA[I am wondering about this if I had a program that contained this:
if (0 <= X and X < 49)
	output "you fail"
What will be printed if the input is 0? would it say you fail? I was thinking it was worded wrong and it should read:if (0 <= X or X < 49)
	output "you fail"]]></description>
			<content:encoded><![CDATA[<div>I am wondering about this if I had a program that contained this:<br />
if (0 &lt;= X and X &lt; 49)<br />
	output &quot;you fail&quot;<br />
What will be printed if the input is 0? would it say you fail? I was thinking it was worded wrong and it should read:if (0 &lt;= X or X &lt; 49)<br />
	output &quot;you fail&quot;</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>twgood</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123864.html</guid>
		</item>
		<item>
			<title>Timing in C addon</title>
			<link>http://www.daniweb.com/forums/thread123641.html</link>
			<pubDate>Sun, 11 May 2008 09:34:50 GMT</pubDate>
			<description><![CDATA[To whoever is using the following code for timing code execution in C 
Originally Posted by [*B]vijayan121 *[/b]

#include<time.h>
blah blah
 main()   
{      
      clock_t start, end;
      double cpu_time_used;
      start = clock();]]></description>
			<content:encoded><![CDATA[<div>To whoever is using the following code for timing code execution in C <br />
Originally Posted by [<b>B]vijayan121 </b>[/b]<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1"><span class="co2">#include&lt;time.h&gt;</span></div></li><li class="li1"><div class="de1">blah blah</div></li><li class="li1"><div class="de1"> main<span class="br0">&#40;</span><span class="br0">&#41;</span>&nbsp;  </div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span>&nbsp; &nbsp; &nbsp; </div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; clock_t start, end;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw4">double</span> cpu_time_used;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; start = clock<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  <span class="coMULTI">/* whatever */</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp;  end = clock<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp;  cpu_time_used = <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="kw4">double</span><span class="br0">&#41;</span> <span class="br0">&#40;</span>end - start<span class="br0">&#41;</span><span class="br0">&#41;</span> / CLOCKS_PER_SEC;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></pre></code> </div>
    if you are wondering why the time displayed is compiler specific instead of being processor specific the solution is here:<br />
Applications should use sysconf(_SC_CLK_TCK) to determine the number of clock ticks per second as it may vary from system to system.<br />
 <a rel="nofollow" class="t" href="http://www.opengroup.org/onlinepubs/000095399/functions/times.html" target="_blank">http://www.opengroup.org/onlinepubs/...ons/times.html</a><br />
 <a rel="nofollow" class="t" href="http://www.opengroup.org/onlinepubs/000095399/functions/sysconf.html" target="_blank">http://www.opengroup.org/onlinepubs/...s/sysconf.html</a><br />
                         Courtesy great google and opengroup.org</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>knapshots</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123641.html</guid>
		</item>
		<item>
			<title>inserting sleep in VC++</title>
			<link>http://www.daniweb.com/forums/thread123609.html</link>
			<pubDate>Sun, 11 May 2008 05:01:35 GMT</pubDate>
			<description><![CDATA[hi all

i am using VC++ editor. Can anyone tell me how to insert sleep in my program? i have tried sleep(). but it is giving an warning

'sleep' undefined; assuming extern returning int.
Thanks in advance]]></description>
			<content:encoded><![CDATA[<div>hi all<br />
<br />
i am using VC++ editor. Can anyone tell me how to insert sleep in my program? i have tried sleep(). but it is giving an warning<br />
<br />
'sleep' undefined; assuming extern returning int.<br />
Thanks in advance</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>carobee</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123609.html</guid>
		</item>
		<item>
			<title>Unstable Program</title>
			<link>http://www.daniweb.com/forums/thread123572.html</link>
			<pubDate>Sat, 10 May 2008 20:02:18 GMT</pubDate>
			<description><![CDATA[Hai guys,

I have quite a large program here that I don't seem to understand. The program, Bow Vice Jet (an anagram for object view) is meant to display WaveFront .obj files. However, it quits when it loads a specific file while on my computer, while on another it does not. I can't find the bug,...]]></description>
			<content:encoded><![CDATA[<div>Hai guys,<br />
<br />
I have quite a large program here that I don't seem to understand. The program, Bow Vice Jet (an anagram for object view) is meant to display WaveFront .obj files. However, it quits when it loads a specific file while on my computer, while on another it does not. I can't find the bug, and it's very annoying. Maybe it has got something to do with memory allocation, maybe something else. If anyone sees any mistake in the code, please point it out and I will correct it. I know it's a vague question, &quot;Find the bug&quot;, but I've been searching for quite some time now and can't figure it out.<br />
<br />
The code is attached, together with the &quot;quiting&quot; file and a file that almost works. To see how these files should look in 3D space, download GLC Player or use your favorite 3D mesh viewing program.<br />
<br />
Thanks in advance,<br />
Nick</div>  <br /> <div style="padding:5px">     <fieldset class="fieldset"> <legend>Attached Files</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums//forums/myimages/attach/zip.gif" alt="File Type: zip" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=6028&amp;d=1210449731">Bow Vice Jet.zip</a> (237.5 KB)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Clockowl</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123572.html</guid>
			<enclosure url="http://www.daniweb.com/forums/attachment.php/6028/Bow+Vice+Jet.zip" length="243218" type="application/zip" />
		</item>
		<item>
			<title>Ranking Array Failure?</title>
			<link>http://www.daniweb.com/forums/thread123510.html</link>
			<pubDate>Sat, 10 May 2008 08:30:43 GMT</pubDate>
			<description><![CDATA[Well I tried to look for any posts on ranking arrays, but all I ever really got were stuff about Google's ranking system. Anyway, I have two arrays. One is arr[] which is the original array, and rank[] is the indexing array. So if I were to print arr[rank[0]], it would give me the smallest value of...]]></description>
			<content:encoded><![CDATA[<div>Well I tried to look for any posts on ranking arrays, but all I ever really got were stuff about Google's ranking system. Anyway, I have two arrays. One is arr[] which is the original array, and rank[] is the indexing array. So if I were to print arr[rank[0]], it would give me the smallest value of arr[]. Without further ado, here is the code!<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1"><span class="co2">#include &lt;stdio.h&gt;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw4">int</span> main<span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">&nbsp; <span class="co1">// Local Declarations</span></div></li><li class="li1"><div class="de1">&nbsp; <span class="kw4">int</span> arr<span class="br0">&#91;</span><span class="nu0">5</span><span class="br0">&#93;</span>=<span class="br0">&#123;</span><span class="nu0">2</span>,<span class="nu0">9</span>,<span class="nu0">5</span>,<span class="nu0">1</span>,<span class="nu0">3</span><span class="br0">&#125;</span>;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw4">int</span> rank<span class="br0">&#91;</span><span class="nu0">5</span><span class="br0">&#93;</span>=<span class="br0">&#123;</span><span class="nu0">0</span>,<span class="nu0">1</span>,<span class="nu0">2</span>,<span class="nu0">3</span>,<span class="nu0">4</span><span class="br0">&#125;</span>;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw4">int</span> i; <span class="kw4">int</span> j;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw4">int</span> smallest;</div></li><li class="li2"><div class="de2">&nbsp; <span class="kw4">int</span> temp;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; <span class="co1">// Statements</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>i=<span class="nu0">0</span>;i&lt;<span class="nu0">4</span>;i++<span class="br0">&#41;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; smallest = i;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>j=i<span class="nu0">+1</span>;j&lt;=<span class="nu0">4</span>;j++<span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>arr<span class="br0">&#91;</span>rank<span class="br0">&#91;</span>smallest<span class="br0">&#93;</span><span class="br0">&#93;</span> &gt; arr<span class="br0">&#91;</span>rank<span class="br0">&#91;</span>j<span class="br0">&#93;</span><span class="br0">&#93;</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; smallest = j;</div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; temp = rank<span class="br0">&#91;</span>i<span class="br0">&#93;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; rank<span class="br0">&#91;</span>i<span class="br0">&#93;</span> = smallest;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; rank<span class="br0">&#91;</span>smallest<span class="br0">&#93;</span> = temp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw3">printf</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span>;</div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>i=<span class="nu0">0</span>;i&lt;<span class="nu0">5</span>;i++<span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">printf</span><span class="br0">&#40;</span><span class="st0">&quot;%3d&quot;</span>, rank<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw3">printf</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;  <span class="kw1">for</span><span class="br0">&#40;</span>i=<span class="nu0">0</span>;i&lt;<span class="nu0">5</span>;i++<span class="br0">&#41;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; <span class="kw3">printf</span><span class="br0">&#40;</span><span class="st0">&quot;%3d&quot;</span>, arr<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw3">printf</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw1">return</span> <span class="nu0">0</span>;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span> <span class="co1">// main</span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1"><span class="coMULTI">/* Execution Results</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp; 3&nbsp; 1&nbsp; 2&nbsp; 0&nbsp; 4</span></div></li><li class="li1"><div class="de1"><span class="coMULTI">&nbsp; 2&nbsp; 9&nbsp; 5&nbsp; 1&nbsp; 3</span></div></li><li class="li2"><div class="de2"><span class="coMULTI">*/</span></div></li></ol></pre></code> </div>
<br />
For some reason, the for loop for the ranking sort just goes through only once. Otherwise it would print the ranking array 3 more times I believe. Any help would be greatly appreciated. Thanks in advance!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>RaDeuX</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123510.html</guid>
		</item>
		<item>
			<title>How to read complete file names???</title>
			<link>http://www.daniweb.com/forums/thread123504.html</link>
			<pubDate>Sat, 10 May 2008 08:07:53 GMT</pubDate>
			<description><![CDATA[I want to read files and folder names from directories.
I have used the following code.
But the problem is that in the output the file name gets truncated.(See the output below)




#include <dirent.h>
#include <stdio.h>
#include<conio.h>]]></description>
			<content:encoded><![CDATA[<div>I want to read files and folder names from directories.<br />
I have used the following code.<br />
But the problem is that in the output the file name gets truncated.<i>(See the output below)</i><br />
<br />
<br />
<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1"><span class="co2">#include &lt;dirent.h&gt;</span></div></li><li class="li1"><div class="de1"><span class="co2">#include &lt;stdio.h&gt;</span></div></li><li class="li1"><div class="de1"><span class="co2">#include&lt;conio.h&gt;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li2"><div class="de2"><span class="kw4">void</span> main<span class="br0">&#40;</span><span class="kw4">void</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1"><span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; clrscr<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; DIR&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  *d;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw4">struct</span> dirent *dir;</div></li><li class="li2"><div class="de2">&nbsp; d = opendir<span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>d<span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>dir = readdir<span class="br0">&#40;</span>d<span class="br0">&#41;</span><span class="br0">&#41;</span> != <span class="kw2">NULL</span><span class="br0">&#41;</span></div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#123;</span></div></li><li class="li2"><div class="de2">&nbsp; &nbsp; &nbsp; <span class="kw3">printf</span><span class="br0">&#40;</span><span class="st0">&quot;%s<span class="es0">\n</span>&quot;</span>, dir-&gt;d_name<span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; &nbsp; closedir<span class="br0">&#40;</span>d<span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1">&nbsp; <span class="br0">&#125;</span></div></li><li class="li2"><div class="de2">&nbsp;</div></li><li class="li1"><div class="de1">&nbsp; getch<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div></li><li class="li1"><div class="de1"><span class="br0">&#125;</span></div></li></ol></pre></code> </div>
<br />
<br />
<br />
=====<br />
OUTPUT<br />
=====<br />
ABCABC~1.CPP<br />
CURREN~1.EXE<br />
CURREN~1.OBJ<br />
============<br />
<br />
The actual naes of the files are:<br />
abcabcd.cpp<br />
currentfolder.exe<br />
currentfolder.obj<br />
<br />
<br />
I would like to read the files as their original names....but I am unable to do so..<br />
<br />
Please help!!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>harsh2327</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123504.html</guid>
		</item>
		<item>
			<title>Problem in finding the greatest no. from array</title>
			<link>http://www.daniweb.com/forums/thread123421.html</link>
			<pubDate>Fri, 09 May 2008 18:16:06 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div class="light" style="float:right"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div>(<a href="#"...]]></description>
			<content:encoded><![CDATA[<div><div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left">#include&lt;stdio.h&gt;<br />
int main()<br />
{<br />
&nbsp; &nbsp; int i ,j ,a[5];<br />
&nbsp; &nbsp; for(i=0;i&lt;=4;i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n\tEnter the %dst value of the array: &quot;, i+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, &amp;a[i]);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; j = a[0];<br />
&nbsp; &nbsp; printf(&quot;\n\tOriginal array entered by the user: &quot;);<br />
&nbsp; &nbsp; for(i=0;i&lt;=4;i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot; %d &quot;, a[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(a[i]&lt;a[i+1])<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  j = a[i+1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; printf(&quot;\n\n\tGreatest no. from the array: %d&quot;, j);<br />
getch();<br />
return 0;&nbsp;  <br />
}</code> </div>
<br />
according to me there is no problem in this code.......<br />
<br />
but its printing some wierd values again n again.....<br />
<br />
plz...help me out here....<br />
<br />
My Wierd Output:<br />
<br />
        Enter the 1st value of the array: 56<br />
<br />
        Enter the 2st value of the array: 35<br />
<br />
        Enter the 3st value of the array: 26<br />
<br />
        Enter the 4st value of the array: 15<br />
<br />
        Enter the 5st value of the array: 24<br />
<br />
        Original array entered by the user:  56  35  26  15  24<br />
<br />
        Greatest no. from the array: 4007048</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>web_master</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123421.html</guid>
		</item>
		<item>
			<title>ftell() fclose() and FILE* f = NULL</title>
			<link>http://www.daniweb.com/forums/thread123377.html</link>
			<pubDate>Fri, 09 May 2008 12:56:42 GMT</pubDate>
			<description><![CDATA[FILE* f = NULL;
fclose(f);Terminates with: 'No source available for "fclose@@GLIBC_2.1() " '

FILE* f = NULL;
ftell(f);Terminates with: 'No source available for "ftell()"' 

Why those functions does not return error value but terminate whole program? How can I safely tell if file is opened in C and...]]></description>
			<content:encoded><![CDATA[<div><div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1">FILE* f = <span class="kw2">NULL</span>;</div></li><li class="li1"><div class="de1">fclose<span class="br0">&#40;</span>f<span class="br0">&#41;</span>;</div></li></ol></pre></code> </div>
Terminates with: 'No source available for &quot;fclose@@GLIBC_2.1() &quot; '<br />
<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><pre class="code"><ol><li class="li1"><div class="de1">FILE* f = <span class="kw2">NULL</span>;</div></li><li class="li1"><div class="de1">ftell<span class="br0">&#40;</span>f<span class="br0">&#41;</span>;</div></li></ol></pre></code> </div>
Terminates with: 'No source available for &quot;ftell()&quot;' <br />
<br />
Why those functions does not return error value but terminate whole program? How can I safely tell if file is opened in C and close it???<br />
<br />
If variable of type 'FILE*' is passed to my function I need to know the state of the file and be able to close.<br />
Any idea?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>edek</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123377.html</guid>
		</item>
		<item>
			<title>DLL problem</title>
			<link>http://www.daniweb.com/forums/thread123310.html</link>
			<pubDate>Fri, 09 May 2008 05:11:23 GMT</pubDate>
			<description>I have written a code for maximum power point tracking. The purpose was to create DLL file and use it in a circuit base simulation program. I used Microsoft visual c++ 2008 express and created that DLL file but I only get first value from the created array in C. I mean circuit based simulation...</description>
			<content:encoded><![CDATA[<div>I have written a code for maximum power point tracking. The purpose was to create DLL file and use it in a circuit base simulation program. I used Microsoft visual c++ 2008 express and created that DLL file but I only get first value from the created array in C. I mean circuit based simulation program only get first value (although I see all array values after executing in &quot;ChSciTE&quot;). Do I need to store data somewhere? I am kind of rookie about writing C code? The code is below and the algorithm is attached as pdf. If anyone help me I would be so happy... I have been playing with this for 3 weeks...<br />
<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;math.h&gt;<br />
<br />
&nbsp; &nbsp; main() {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; static double y[21];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //controlled variable<br />
&nbsp; &nbsp; static double m_A[21];&nbsp; &nbsp; &nbsp; &nbsp;  //modulation index&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; double dm_A=0.05;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //small change for modulation index<br />
&nbsp; &nbsp; int n;<br />
&nbsp; &nbsp; double i_cell[]={4.65, 4.68, 4.7, 3.7, 2.1, 2.8,4.68, 4.65, 3.9, 3.7, 2.1, 2.8,4.68, 4.65, 3.9, 4.3, 2.1, 3.3, 4, 3.7,4.6}; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for (n=1;n&lt;=19;n++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; m_A[0]=0.75;<br />
&nbsp; &nbsp; &nbsp; &nbsp; m_A[1]=0.65;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; y[n-1]=i_cell[n-1]*m_A[n-1];&nbsp; &nbsp; &nbsp; //estimated initial controlled variable<br />
&nbsp; &nbsp; &nbsp; &nbsp; y[n]=i_cell[n]*m_A[n];&nbsp; <br />
<br />
&nbsp; &nbsp; if (((m_A[n]&gt;=m_A[n-1]) &amp;&amp; (y[n]&gt;=y[n-1])) || //algorithm for maximum power point tracking<br />
&nbsp; &nbsp; &nbsp; &nbsp; (((m_A[n]&lt;m_A[n-1]) &amp;&amp; (y[n]&lt;y[n-1]))))&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; m_A[n+1]=m_A[n]+dm_A;&nbsp; &nbsp; //increase modulation index<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; else&nbsp; &nbsp;  //while one of them is increasing and the other one decreasing<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; m_A[n+1]=m_A[n]-dm_A; //decrease modulation index&nbsp; <br />
&nbsp; <br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%f \n&quot;,m_A[n+1]); //display modulation indices<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</code> </div>
<br />
The code above for seeing results in &quot;ChSciTE&quot; program but the one I pasted below creates that DLL file to use in simulation.<br />
<br />
<div style="margin:10px 20px 20px 20px"> <code style="margin:0px" dir="ltr" style="text-align:left"><br />
#include &lt;math.h&gt;<br />
__declspec(dllexport) void simuser (t, delt, in, out)<br />
double t, delt;<br />
double *in, *out;<br />
{<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; static double y[21];&nbsp; &nbsp; &nbsp; //controlled variable<br />
&nbsp; &nbsp; &nbsp; &nbsp; static double m_A[21]; //modulation index<br />
&nbsp; &nbsp; &nbsp; &nbsp; double i_cell=4.65;&nbsp; &nbsp; &nbsp; &nbsp;  //estimated initial current value<br />
&nbsp; &nbsp; &nbsp; &nbsp; int n;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for (n=1;n&lt;=19;n++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_A[0]=0.75;&nbsp; &nbsp; &nbsp; &nbsp; //estimated initial current value<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_A[1]=0.65;&nbsp; &nbsp; &nbsp; &nbsp; //second estimated initial current value<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y[n-1]=i_cell*m_A[0];&nbsp; &nbsp; &nbsp; &nbsp; //estimated initial controlled variable<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y[n]=in[0]*m_A[n];&nbsp; &nbsp; &nbsp; &nbsp; //in[0] current input value&nbsp; comes from sim.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (((m_A[n]&gt;=m_A[n-1]) &amp;&amp; (y[n]&gt;=y[n-1])) || <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (((m_A[n]&lt;m_A[n-1]) &amp;&amp; (y[n]&lt;y[n-1]))))&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m_A[n+1]=m_A[n]+in[1];&nbsp; &nbsp; &nbsp; &nbsp; //in[1] input from circuit based simulation<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; //while one of them increases and the other one decreases<br />
&nbsp; &nbsp; &nbsp; &nbsp; m_A[n+1]=m_A[n]-in[1];&nbsp; &nbsp; &nbsp; &nbsp;  //decrease modulation index<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; out[0]=m_A[n+1];&nbsp;  // out[0] is output which is transfered to the sim. <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
}<br />
</code> </div>
<br />
in[0]: first input comes from simulation program<br />
in[1]: second input comes from simulation program<br />
out[0]: output from C code or DLL file goes to simulation or taken by simulation program<br />
<br />
Those values taken by simulation should be m_A[n+1]? As far as I understand which is an array. However only the first, I mean m_A[1+1] = m_A[2] has taken by simulation. How could I write the code all values from m_A[2], m_A[3]........m_A[20] can be taken by simulation or DLL sends those values to simulation program one by one for every 20 ms or different interval...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>wam2</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread123310.html</guid>
		</item>
	</channel>
</rss>
