<?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>Sat, 07 Nov 2009 23:07:07 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.daniweb.com/alphaimages/misc/rss.jpg</url>
			<title>DaniWeb IT Discussion Community - C</title>
			<link>http://www.daniweb.com/forums/</link>
		</image>
		<item>
			<title>Problem with piping commands in C</title>
			<link>http://www.daniweb.com/forums/thread236880.html</link>
			<pubDate>Sat, 07 Nov 2009 22:52:05 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I'm trying to create a simple shell in C for Unix. I've been able to do all the parsing of commands and execution, but I'm having a problem with piping. I think the problem is that I'm not hooking into the correct pipe for the input of the second command. 
 
For example, if I type "ls | wc",...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I'm trying to create a simple shell in C for Unix. I've been able to do all the parsing of commands and execution, but I'm having a problem with piping. I think the problem is that I'm not hooking into the correct pipe for the input of the second command.<br />
<br />
For example, if I type &quot;ls | wc&quot;, it will pause after the &quot;wc&quot; command, which I think is because its waiting for input. I think the problem is when I use dup2(reading[i],0), and its not hooking into the correct pipe.<br />
<br />
I know this is a bit of a broad question, but if there are any pointers I could get, I would appreciate it. Here is the code that creates new processes and tries to pipe them.<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; int fileds[2];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int reading[num_cmds];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int writing[num_cmds];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int p;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(p=0; p &lt; num_cmds; p++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reading[p] = -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writing[p] = -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int j;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(j=0; j &lt; num_cmds-1; j++)&nbsp; &nbsp; //Create pipes for commands<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int fileds[2];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pipe(fileds);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reading[j+1] = fileds[0];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writing[j] = fileds[1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; num_cmds;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd_args = parse_cmd(cmds[i],output_file,input_file,&amp;run_bg); //Get command and args<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pid_t childpid;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int status;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; childpid=fork();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (childpid &gt;= 0) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (childpid == 0) <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;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(writing[i] != -1)<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dup2(writing[i],1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close(writing[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(reading[i] != -1)<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dup2(reading[i],0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close(reading[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int h;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(h = 0; h &lt; num_cmds; h++)<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close(writing[h]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close(reading[h]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(execvp(cmd_args[0],cmd_args) == -1) <br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; perror(&quot;Problem with command&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&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 />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; wait(&amp;status);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int m;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(m = 0; m &lt; num_cmds; m++)<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( writing[m] != -1) close(writing[m]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( reading[m] != -1) close(reading[m]);<br />
&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 />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  perror(&quot;fork&quot;); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; input_file[0] = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output_file[0] = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run_bg = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>symmet</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236880.html</guid>
		</item>
		<item>
			<title>Could Someone Try Compiling This On A Different Compiler</title>
			<link>http://www.daniweb.com/forums/thread236858.html</link>
			<pubDate>Sat, 07 Nov 2009 20:22:18 GMT</pubDate>
			<description>I wrote this very small program that works fine until I remove the comments for the fprintf function. 
 
Basically the program will prompt the user for a numeric value, when the user guesses right(1234) the program exits. When I remove the comments the program never exits...Does anyone have any...</description>
			<content:encoded><![CDATA[<div>I wrote this very small program that works fine until I remove the comments for the fprintf function.<br />
<br />
Basically the program will prompt the user for a numeric value, when the user guesses right(1234) the program exits. When I remove the comments the program never exits...Does anyone have any idea why? I'm completely lost as to why it would behave like this...maybe its my compiler - gcc 4.4.1<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
unsigned long testval = 1234;<br />
<br />
void* foundit(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; fputs(&quot;found it!\n&quot;, stdout);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return (void*)0;<br />
}<br />
<br />
void* tryit(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; unsigned long val;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; fputs(&quot;enter a value/guess-&gt;&quot;, stdout);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fscanf(stdin, &quot;%u&quot;, &amp;val);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (val == testval)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (void*)&amp;foundit;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (void*)&amp;tryit;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
int main(int argc, char**argv)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; void *addr = (void*)&amp;tryit;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //fprintf(stdout, &quot;ans-&gt;%u\n&quot;, 1);&nbsp; &nbsp; &nbsp; &nbsp; //remove comments and program runs <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; //but fails to exit with correct value<br />
&nbsp; &nbsp; &nbsp; &nbsp; while ((addr = ((void*(*)(void))addr)()))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {}<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit(EXIT_SUCCESS);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>gerard4143</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236858.html</guid>
		</item>
		<item>
			<title>Problem with Bitwise Masking</title>
			<link>http://www.daniweb.com/forums/thread236830.html</link>
			<pubDate>Sat, 07 Nov 2009 17:48:34 GMT</pubDate>
			<description><![CDATA[Ok so I make my masks  
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <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>...]]></description>
			<content:encoded><![CDATA[<div>Ok so I make my masks <br />
 <pre style="margin:20px; line-height:13px">short m1, m2, m3, m4;<br />
<br />
m1 = 0xF000;<br />
m2 = 0x0F00;<br />
m2 = 0x00F0;<br />
m3 = 0x000F;</pre><br />
and then I test my masks <br />
 <pre style="margin:20px; line-height:13px">printf(&quot;%hd %hd %hd %hd\n&quot;, m1, m2, m3, m4);</pre><br />
when I test it the values come out as<br />
 <pre style="margin:20px; line-height:13px">-4096 240 15 0</pre><br />
which is equal to <br />
<br />
 <pre style="margin:20px; line-height:13px">0xF000<br />
0x00F0<br />
0x000F<br />
0x0000</pre><br />
which is messing up my checksum program when I try to apply the masks. :-\<br />
<br />
Any advice?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Kombat</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236830.html</guid>
		</item>
		<item>
			<title>Zeroing bits</title>
			<link>http://www.daniweb.com/forums/thread236816.html</link>
			<pubDate>Sat, 07 Nov 2009 16:04:41 GMT</pubDate>
			<description><![CDATA[Is this the proper way to zero the first 12 bits of an address? 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>Is this the proper way to zero the first 12 bits of an address?<br />
<br />
 <pre style="margin:20px; line-height:13px">void *ans = (void*)((unsigned long)addr &amp;&nbsp; ((0UL - 1)&nbsp; ^ 0xfff));</pre><br />
Where addr is any user process memory address..<br />
<br />
Note this method works...I just want to know if there is a better way</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>gerard4143</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236816.html</guid>
		</item>
		<item>
			<title>check 1 number is a prime or not</title>
			<link>http://www.daniweb.com/forums/thread236791.html</link>
			<pubDate>Sat, 07 Nov 2009 14:00:46 GMT</pubDate>
			<description><![CDATA[[CODE =C] 
#include "conio.h" 
#include "stdio.h" 
#include "math.h" 
 
int isPrime(int n) 
{ 
    int i,isTrue=1; 
    for(i=2; i<(int)sqrt(n); i++) 
    if(n%i==0)]]></description>
			<content:encoded><![CDATA[<div>[CODE =C]<br />
#include &quot;conio.h&quot;<br />
#include &quot;stdio.h&quot;<br />
#include &quot;math.h&quot;<br />
<br />
int isPrime(int n)<br />
{<br />
    int i,isTrue=1;<br />
    for(i=2; i&lt;(int)sqrt(n); i++)<br />
    if(n%i==0)<br />
    return 0;<br />
    else return 1;<br />
}<br />
<br />
int main()<br />
{<br />
    int N;<br />
    printf(&quot;Enter n: &quot;);<br />
    scanf(&quot;%d&quot;,&amp;N);<br />
    if(isPrime(N))<br />
    printf(&quot;prime&quot;);  <br />
    else<br />
    printf(&quot;Not prime\n&quot;);<br />
    getch();<br />
    return 0;<br />
}<br />
<br />
[/CODE]<br />
here is my source code, but when i test , sometimes it's true sometimes it's false. I don't know what is my mistake<br />
Please help me solve it<br />
Thanks a lot!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>thebluestar</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236791.html</guid>
		</item>
		<item>
			<title>Message Queue Error</title>
			<link>http://www.daniweb.com/forums/thread236656.html</link>
			<pubDate>Fri, 06 Nov 2009 23:12:47 GMT</pubDate>
			<description>I am new to message queues and IPC in general.  I am trying to have a process establish the queue and send a message.  Then I fork and the child will read the message.  The goal is to measure the execution time for different sized messages. 
 
The msgsnd is returning a -1 and I have no idea as to...</description>
			<content:encoded><![CDATA[<div>I am new to message queues and IPC in general.  I am trying to have a process establish the queue and send a message.  Then I fork and the child will read the message.  The goal is to measure the execution time for different sized messages.<br />
<br />
The msgsnd is returning a -1 and I have no idea as to why its not sending anything.  Any help is appreciated.  Thanks in advance<br />
<br />
 <pre style="margin:20px; line-height:13px">int main() {<br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //establish the character array to be passed around<br />
&nbsp; &nbsp; &nbsp; &nbsp; int msgSize = 1024;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; char charArray[msgSize];<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; clock_t timeStampBegin;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; clock_t timeStampEnd;<br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; key_t key = 1234; /* key to be passed to msgget() */ <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int msqid; /* return value from msgget() */ <br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //establish the message queue and make sure that it properly established<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((msqid = msgget(key, IPC_CREAT)) == 1) {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; perror(&quot;msgget: msgget failed&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //exit(1);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; } else {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (void) fprintf(stderr, &quot;msgget succeeded\n&quot;); <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Take an initial timestamp<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; timeStampBegin = clock();<br />
&nbsp; &nbsp; &nbsp; &nbsp; //printf(&quot;\nTimeStampBegin = %d\n&quot;, timeStampBegin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int amountSent = msgsnd(1234, &amp;charArray, msgSize, 0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d bytes were sent&quot;, amountSent);<br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(fork() == 0) {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //this is the child, this is the one that we want to recieve the info.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char recievedArray[100000];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if((size_t)msgSize == msgrcv(1234, &amp;recievedArray, msgSize, 0, 0))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Mesage was recieved&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timeStampEnd = clock();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //printf(&quot;Time for transit of size %d = %f&quot;, msgSize, (double)(timeStampEnd-timeStampBegin));<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
<br />
<br />
<br />
}</pre><br />
Output<br />
 <pre style="margin:20px; line-height:13px">msgget succeeded<br />
-1 bytes were sent<br />
-1 bytes were sent</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>chunalt787</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236656.html</guid>
		</item>
		<item>
			<title>Reading from the Command line</title>
			<link>http://www.daniweb.com/forums/thread236628.html</link>
			<pubDate>Fri, 06 Nov 2009 19:32:50 GMT</pubDate>
			<description><![CDATA[Hey, 
How do you read from the command line in C? I need to read 10 arguments from the command line. Can I use char* argv[] as a parameter in the main function to do so? 
 
Thanks.]]></description>
			<content:encoded><![CDATA[<div>Hey,<br />
How do you read from the command line in C? I need to read 10 arguments from the command line. Can I use char* argv[] as a parameter in the main function to do so?<br />
<br />
Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>shakunni</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236628.html</guid>
		</item>
		<item>
			<title>need help!!! to fix my program please!!!</title>
			<link>http://www.daniweb.com/forums/thread236621.html</link>
			<pubDate>Fri, 06 Nov 2009 18:53:42 GMT</pubDate>
			<description><![CDATA[I made a program that inputs the radius of a circle, and then should output a circle of asterisks. however, I am just getting the fourth-quadrant part of the circle, and I need the whole circle to be printout. what do I need in my code? 
 
this is my code: 
 
#include <stdio.h> 
#define x 25 
 
int...]]></description>
			<content:encoded><![CDATA[<div>I made a program that inputs the radius of a circle, and then should output a circle of asterisks. however, I am just getting the fourth-quadrant part of the circle, and I need the whole circle to be printout. what do I need in my code?<br />
<br />
this is my code:<br />
<br />
#include &lt;stdio.h&gt;<br />
#define x 25<br />
<br />
int main()<br />
{<br />
char A[x][x];<br />
int r, i, j;<br />
<br />
printf(&quot;Radius: &quot;);<br />
scanf(&quot;%d&quot;, &amp;r);<br />
<br />
for(i=0; i&lt;=r; i++)<br />
{<br />
for(j=0; j&lt;=r; j++)<br />
{<br />
  if(i*i + j*j &lt;= r*r)<br />
  A[i][j]= '*'<br />
<br />
else<br />
  A[i][j]= ' ';<br />
}<br />
}<br />
<br />
for(i=o; i&lt;=r; i++)<br />
{  <br />
   for(j=o; j&lt;=r; j++)<br />
   printf(&quot;%c&quot;, A[i][j]);<br />
<br />
   printf(&quot;\n&quot;);<br />
}<br />
<br />
return 0;<br />
}</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>needhelpe</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236621.html</guid>
		</item>
		<item>
			<title>Merge sort or an alternative..</title>
			<link>http://www.daniweb.com/forums/thread236586.html</link>
			<pubDate>Fri, 06 Nov 2009 15:17:56 GMT</pubDate>
			<description>Hi there guys, 
 
 So I have two arrays, and each arrays got 5 elements (integers). My goal is to to arrange the elements of each of those arrays in a descending order and save them in a new array.  
 
I started off with bubble sorting each of those arrays and rearranging the elements in a...</description>
			<content:encoded><![CDATA[<div>Hi there guys,<br />
<br />
 So I have two arrays, and each arrays got 5 elements (integers). My goal is to to arrange the elements of each of those arrays in a descending order and save them in a new array. <br />
<br />
I started off with bubble sorting each of those arrays and rearranging the elements in a descending sequence. It just seemed reasonable to start with that. <br />
<br />
However now, I have to merge those two arrays. I thought it'd be wise to create a new empty array with a size big enough to contain all the elements, but I can't figure out for the life me how to arrange them in a descending order while merging them.<br />
<br />
I know I could just transfer all the elements to the new array and then bubble sort it but that seems tedious. Any ideas?<br />
<br />
Thanks in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>s.p.i.</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236586.html</guid>
		</item>
		<item>
			<title>classes</title>
			<link>http://www.daniweb.com/forums/thread236561.html</link>
			<pubDate>Fri, 06 Nov 2009 12:54:16 GMT</pubDate>
			<description><![CDATA[Hi! 
 
I have had to change from Python to C because of university instructions. My problem is that, when I want to make a menu for my program or whatever, I always want to define classes:P 
 
My question is simple --> are structures the best way to "replace" classes? 
 
TY]]></description>
			<content:encoded><![CDATA[<div>Hi!<br />
<br />
I have had to change from Python to C because of university instructions. My problem is that, when I want to make a menu for my program or whatever, I always want to define classes:P<br />
<br />
My question is simple --&gt; are structures the best way to &quot;replace&quot; classes?<br />
<br />
TY</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Yee</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236561.html</guid>
		</item>
		<item>
			<title>non preemptive scheduler</title>
			<link>http://www.daniweb.com/forums/thread236558.html</link>
			<pubDate>Fri, 06 Nov 2009 12:37:06 GMT</pubDate>
			<description>hii i want c code for non preemptive scheduler where burst time and arrival time is given and u have to return waiting time from the function u will develop. 
please give code soon 
pleaseeeee..</description>
			<content:encoded><![CDATA[<div>hii i want c code for non preemptive scheduler where burst time and arrival time is given and u have to return waiting time from the function u will develop.<br />
please give code soon<br />
pleaseeeee..</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>vivek01anand</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236558.html</guid>
		</item>
		<item>
			<title>alphabet sorting for strings</title>
			<link>http://www.daniweb.com/forums/thread236528.html</link>
			<pubDate>Fri, 06 Nov 2009 09:45:01 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <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> <strong>C Syntax</strong> (<a...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
#include&lt;conio.h&gt;<br />
#include&lt;string.h&gt;<br />
<br />
int n;<br />
char (*p)[40],*temp;<br />
void Input();<br />
void ABCsorting();<br />
<br />
void Input()<br />
{<br />
&nbsp; &nbsp;  printf(&quot;How many persons u want to input: &quot;);<br />
&nbsp; &nbsp;  scanf(&quot;%d&quot;,&amp;n); <br />
&nbsp; &nbsp;  p=(char*)malloc(n*40*sizeof(char));<br />
&nbsp; &nbsp;  temp=(char*)malloc(n*sizeof(char));<br />
&nbsp; &nbsp;  int i; <br />
&nbsp; &nbsp;  for(i=0; i&lt;n ; i++)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;String %d: &quot;,i+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fflush(stdin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; gets(p[i]);<br />
&nbsp; &nbsp;  }<br />
&nbsp; &nbsp;  printf(&quot;All strings before sorting: \n&quot;);<br />
&nbsp; &nbsp;  /*for(i=0; i&lt;n ; i++)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot; %s\n&quot;,*(p+i) );&nbsp; <br />
&nbsp; &nbsp;  } */<br />
&nbsp; &nbsp;  for(i=0; i&lt;n ; i++)<br />
&nbsp; &nbsp;  printf(&quot; %s |&quot;,p[i]);<br />
}<br />
<br />
void ABCsorting()<br />
{<br />
&nbsp; &nbsp;  int i,j;<br />
&nbsp; &nbsp;  for(i=0; i&lt;n-1 ;i++)<br />
&nbsp; &nbsp;  for(j=i+1; j&lt;n; j++)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; if( strcmp((p+i),(p+j)) &gt; 0 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = (p+i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (p+i) = (p+j);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (p+j) = temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; /*&nbsp; if( strcmp(p[i], p[j]) &gt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp=p[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p[i]= p[j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p[j]=temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }*/<br />
&nbsp; &nbsp;  }<br />
&nbsp; &nbsp;  printf(&quot;\nAfter Sorting: \n&quot;);<br />
&nbsp; &nbsp;  for(i=0; i&lt;n ;i++)<br />
&nbsp; &nbsp;  printf(&quot; %s |&quot;,p[i]);<br />
}<br />
&nbsp;<br />
&nbsp;<br />
int main()<br />
{&nbsp;  <br />
&nbsp; &nbsp; Input();<br />
&nbsp; &nbsp; ABCsorting();<br />
&nbsp; &nbsp; getch();<br />
&nbsp; &nbsp; return 0;<br />
}</pre>Please help me find the mistake in my above source code<br />
Thanks a lot!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>thebluestar</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236528.html</guid>
		</item>
		<item>
			<title><![CDATA[Difference between *p[5] and (*p)[5]?]]></title>
			<link>http://www.daniweb.com/forums/thread236527.html</link>
			<pubDate>Fri, 06 Nov 2009 09:41:35 GMT</pubDate>
			<description><![CDATA[I'm not sure about the difference between  *p[5] and (*p)[5]? 
Please help me clarify them?  
Thanks a lot!]]></description>
			<content:encoded><![CDATA[<div>I'm not sure about the difference between  *p[5] and (*p)[5]?<br />
Please help me clarify them? <br />
Thanks a lot!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>thebluestar</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236527.html</guid>
		</item>
		<item>
			<title>Array counter</title>
			<link>http://www.daniweb.com/forums/thread236509.html</link>
			<pubDate>Fri, 06 Nov 2009 07:55:32 GMT</pubDate>
			<description>Hi there,  
 
 I was trying to code a simple program that bubble sorts an array into a list of numbers arranged in a descending order: 
 
Here is the code I used: 
 
 
#define size1 5  
#define size2 5</description>
			<content:encoded><![CDATA[<div>Hi there, <br />
<br />
 I was trying to code a simple program that bubble sorts an array into a list of numbers arranged in a descending order:<br />
<br />
Here is the code I used:<br />
<br />
 <pre style="margin:20px; line-height:13px">#define size1 5 <br />
#define size2 5<br />
<br />
#include &lt;stdio.h&gt;<br />
int main()<br />
{<br />
int a&#91;size1&#93;={8,4,5,2,3};//array 1<br />
int i=0;<br />
int n=0;<br />
int temp=0;<br />
<br />
//sort array A into a descending sequence<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i=0;i&lt;size1;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(n=i+1;n&lt;size1;n++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (a&#91;i&#93;&lt;a&#91;n&#93;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {temp = a&#91;i&#93;;a&#91;i&#93;=a&#91;n&#93;;a&#91;n&#93;=temp;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i=0;i&lt;size1;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d\n&quot;,a&#91;i&#93;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
return(0);<br />
}</pre><br />
Now the block of code written above works just fine, however if I replace<br />
<br />
 <pre style="margin:20px; line-height:13px">for(n=i+1;n&lt;size1;n++)</pre><br />
with<br />
<br />
 <pre style="margin:20px; line-height:13px">for(n=1;n&lt;size1;n++)</pre><br />
..the program randomly generates a sequence of numbers along with a garbage value. What's going on here? As far as I can see both codes are equivalent.<br />
<br />
Any input will be appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>s.p.i.</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236509.html</guid>
		</item>
		<item>
			<title>fork syscall and related issues</title>
			<link>http://www.daniweb.com/forums/thread236492.html</link>
			<pubDate>Fri, 06 Nov 2009 06:27:38 GMT</pubDate>
			<description>Dont know these types of questions are asked here or not but if any one has idea please help me. 
 
i just started started learning system programming and want to pursue a career in the sys prog area. 
 
below is the program that use a fork() call. 
 i read in one of the tutorials that parent...</description>
			<content:encoded><![CDATA[<div>Dont know these types of questions are asked here or not but if any one has idea please help me.<br />
<br />
i just started started learning system programming and want to pursue a career in the sys prog area.<br />
<br />
below is the program that use a fork() call.<br />
 i read in one of the tutorials that parent process and child process uses different address spaces and runs concurrently.<br />
<br />
that meas each process gets some slice of cpu time, then the statements in that process are executed.<br />
<br />
my Questions:<br />
<br />
1.is there any way to know how much timeslice each process is getting.<br />
<br />
2.what kind of scheduling its using<br />
<br />
3. can i print the out put one page at a time ( should wait for keypress to print next page)<br />
<br />
4. any links that provides good system programming info(message queues, pipes,shared memory etc.. )<br />
<br />
5. appications that uses sockets <br />
below is some example prog:<br />
 <br />
 <pre style="margin:20px; line-height:13px">#include&nbsp; &lt;stdio.h&gt;<br />
#include&nbsp; &lt;sys/types.h&gt;<br />
<br />
#define&nbsp;  MAX_COUNT&nbsp; 200<br />
<br />
void&nbsp; ChildProcess(pid_t);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* child process prototype&nbsp; */<br />
void&nbsp; ParentProcess(pid_t);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  /* parent process prototype */<br />
<br />
void&nbsp; main(void)<br />
{<br />
&nbsp; &nbsp;  pid_t&nbsp; pid;<br />
<br />
&nbsp; &nbsp;  pid = fork();<br />
&nbsp; &nbsp;  if (pid == 0) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ChildProcess(pid);<br />
&nbsp; &nbsp;  else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ParentProcess(pid);<br />
}<br />
<br />
void&nbsp; ChildProcess(pid_t pid)<br />
{<br />
&nbsp; &nbsp;  int&nbsp;  i;<br />
&nbsp; &nbsp;  char buf[40];<br />
&nbsp; &nbsp;  for(i=1; i &lt;= MAX_COUNT; i++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sprintf(buf, &quot;This line is from pid %d, value = %d\n&quot;, pid, i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write(1, buf, strlen(buf));<br />
&nbsp; &nbsp;  }<br />
}<br />
<br />
void&nbsp; ParentProcess(pid_t pid)<br />
{<br />
&nbsp; &nbsp;  int&nbsp;  i;&nbsp; &nbsp; <br />
&nbsp; &nbsp;  char buf[40];<br />
&nbsp; &nbsp;  for(i=1; i &lt;= MAX_COUNT; i++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sprintf(buf, &quot;This line is from pid %d, value = %d\n&quot;, pid, i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write(1, buf, strlen(buf));<br />
&nbsp; &nbsp;  }<br />
}</pre>thanks in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Iam3R</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236492.html</guid>
		</item>
		<item>
			<title>Bowling program (wrong scores)</title>
			<link>http://www.daniweb.com/forums/thread236484.html</link>
			<pubDate>Fri, 06 Nov 2009 05:22:23 GMT</pubDate>
			<description><![CDATA[Hey guys, 
 
I've got an issue with the bowling program I've created.  It's outputting the wrong scores, but I believe it's because of wrong bowling code.  Is there anything wrong that you can see? 
 
One of the issues I'm having is frame 2, where the scores were 9 and 1, and it's being counted as...]]></description>
			<content:encoded><![CDATA[<div>Hey guys,<br />
<br />
I've got an issue with the bowling program I've created.  It's outputting the wrong scores, but I believe it's because of wrong bowling code.  Is there anything wrong that you can see?<br />
<br />
One of the issues I'm having is frame 2, where the scores were 9 and 1, and it's being counted as a STRIKE, inflating the score quite a bit.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;string&gt;<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; //declare variables<br />
&nbsp; &nbsp; int frame[10] = {0};<br />
&nbsp; &nbsp; int balls[21] = {0};<br />
&nbsp; &nbsp; int input_counter = 0;<br />
&nbsp; &nbsp; int sum = 0;<br />
&nbsp; &nbsp; int strike = 10;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; //input stream<br />
&nbsp; &nbsp; ifstream score;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; //open file and have a statement if file is not opened<br />
&nbsp; &nbsp; score.open(&quot;MGlane9.txt&quot;);<br />
&nbsp; &nbsp; if(score.fail())<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;File inaccessible.&quot;;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; //while END OF FILE is not reached<br />
&nbsp; &nbsp; while(!score.eof())<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; score &gt;&gt; balls[input_counter];<br />
&nbsp; &nbsp; &nbsp; &nbsp; input_counter++;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; //close Input file<br />
&nbsp; &nbsp; score.close();<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; for(int i=0;i&lt;input_counter;i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  //for anything other than strike<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(balls[i] &lt; 10)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;First bowl is &quot; <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;  &lt;&lt; balls[i]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;Second bowl is &quot; <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;  &lt;&lt; balls[i+1] <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;  <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;  &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += balls[i]+ balls[i+1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(balls[i] + balls[i+1] == 10)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;SPARE!!!&quot;;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Sum is &quot; &lt;&lt; sum &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //for strike<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(balls[i] = 10)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(balls[i] = 10)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Strike!&quot; &lt;&lt; balls[i] &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += balls[i] + balls[i+1];}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Sum is &quot; &lt;&lt; sum &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; //preview cout&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; getchar();&nbsp;  <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; //end program&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>godsgift2dagame</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236484.html</guid>
		</item>
		<item>
			<title>Forks and Shared Memory in C (Linux OS)</title>
			<link>http://www.daniweb.com/forums/thread236454.html</link>
			<pubDate>Fri, 06 Nov 2009 02:59:09 GMT</pubDate>
			<description>So, I have a server process that forks for every client that connects. I keep a list of connected clients that I want each fork process to have. Of course, when the process forks the child only has what it had when the fork occurred. For the solution to this, I decided to use shared memory. For...</description>
			<content:encoded><![CDATA[<div>So, I have a server process that forks for every client that connects. I keep a list of connected clients that I want each fork process to have. Of course, when the process forks the child only has what it had when the fork occurred. For the solution to this, I decided to use shared memory. For simplicities sake (and because this is my main issue I'm dealing with right now) I'll illustrate how I've attempted to pass an integer from the parent to child processes.<br />
<br />
Parent process:<br />
<br />
 <pre style="margin:20px; line-height:13px">key_t key_numentries;<br />
int shmid_numentries;<br />
char *shm_numentries, *shm1;<br />
<br />
char buf&#91;&#93;;<br />
<br />
//Key for numentries is 2345<br />
<br />
key_numentries = 2345;<br />
<br />
//Create the shared memory segment<br />
<br />
if((shmid_numentries = shmget(key_numentries, 8, IPC_CREAT | 0666)) &lt; 0) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; perror(&quot;shmget&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br />
}<br />
<br />
//Attach shared memory to dataspace<br />
<br />
if((shm1 = shmat(shmid_numentries, NULL, 0)) == (char *) -1) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; perror(&quot;shmat&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br />
}<br />
<br />
//did this because I wasn't sure how to send an int over the shm<br />
//numentries does contain the right value, I've tested it.<br />
<br />
sprintf (buf,&quot;%d&quot;,numentries);<br />
<br />
//not sure if this would work, but a printf(%s) with &amp;shm1&#91;0&#93; printed <br />
//the correct value<br />
shm1 = buf;<br />
<br />
//pretty sure the code below fork is irrelevant<br />
<br />
if(!fork()){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close(socket_in);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recievecmds(new_fd);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close(new_fd);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);}</pre><br />
Child process:<br />
<br />
 <pre style="margin:20px; line-height:13px">int shmid_numentries;<br />
key_t key_numentries;<br />
char *shm_numentries, *shm1;<br />
<br />
//set key to 2345<br />
<br />
key_numentries = 2345;<br />
<br />
//locate the segment<br />
<br />
if ((shmid_numentries = shmget(key_numentries, 8, 0666)) &lt; 0) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; perror(&quot;shmget&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br />
}<br />
<br />
//attach the segment to our data space<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
if ((shm1 = shmat(shmid_numentries, NULL, 0)) == (char *) -1) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; perror(&quot;shmat&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br />
}<br />
<br />
// I have no idea what to do here... here are some of the things I've tried<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //send # of entries to client<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //char c = (char)&amp;shm1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //printf(&quot;got this from the parent too %s\n&quot;,c);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //printf(&quot;in SHM buf: %s\n&quot;,&amp;shm1&#91;0&#93;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numentries = (int)&amp;shm1&#91;0&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //numentries = strtol(&amp;shm1&#91;0&#93;,NULL,0);<br />
&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; for (; shm1 != NULL; shm1++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putchar(*shm1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; putchar('\n');</pre><br />
heres where I'm not sure what to do... how do I get the data from the pointer? Everything I've tried is either nothing or it's a bunch of random gibberish that obviously I didn't store in the pointer... so I'm afraid the memory space isn't actually being shared. Can anyone point me in the right direction here? I am BRAND NEW to shared memory to be honest. Haven't dealt with forks that much either.<br />
<br />
Thanks in advance! Please let me know if I need to clarify anything.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>cwarren13</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236454.html</guid>
		</item>
		<item>
			<title>Get keyboard key name?</title>
			<link>http://www.daniweb.com/forums/thread236412.html</link>
			<pubDate>Thu, 05 Nov 2009 23:15:15 GMT</pubDate>
			<description><![CDATA[I need a function that returns the name of a key directly from the keyboard, eg, the input of '32' would return 'Space'.  
 
I know there is a function that does this, but I can't figure out which one.]]></description>
			<content:encoded><![CDATA[<div>I need a function that returns the name of a key directly from the keyboard, eg, the input of '32' would return 'Space'. <br />
<br />
I know there is a function that does this, but I can't figure out which one.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>MajesticMoose</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236412.html</guid>
		</item>
		<item>
			<title>getting a runtime error,please help!</title>
			<link>http://www.daniweb.com/forums/thread236393.html</link>
			<pubDate>Thu, 05 Nov 2009 21:54:40 GMT</pubDate>
			<description><![CDATA[the header file: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <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> <strong>C...]]></description>
			<content:encoded><![CDATA[<div>the header file:<br />
 <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
struct IntArray<br />
{<br />
&nbsp;int schedule[30000];<br />
&nbsp;int nSize;<br />
};<br />
struct IntArray getSchedule(int browsingTime[], int noOfPersons, int timeSlot);</pre>the implementation file:<br />
 <pre style="margin:20px; line-height:13px"><br />
#include&quot;leastremainingtime.h&quot;<br />
void sort(int *a,int n)<br />
{<br />
&nbsp; int i=0,j=0,temp=0;<br />
&nbsp; for(i=0; i&lt;n;i++)<br />
&nbsp; {<br />
&nbsp; &nbsp; for(j=0;j&lt;n-1;j++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(a[j] &gt; a[j+1])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp=a[j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  a[j]=a[j+1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  a[j+1]=temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; }<br />
}<br />
struct IntArray getSchedule(int browsingTime[], int noOfPersons, int timeSlot)<br />
{<br />
&nbsp;struct IntArray soln;<br />
&nbsp;soln.nSize=0;<br />
&nbsp;int i=0,j=0,k=0,toBeSorted[500],sameArr[500],newarr[500],l=0,remUsers=0;<br />
&nbsp;for(i=0; i&lt;noOfPersons; i++)<br />
&nbsp;{<br />
&nbsp; &nbsp; toBeSorted[i]=sameArr[i]=browsingTime[i];<br />
&nbsp;}<br />
&nbsp;sort(toBeSorted,noOfPersons);<br />
&nbsp;for(i=0; i&lt;noOfPersons; i++)<br />
&nbsp;{<br />
&nbsp; for(j=0; j&lt;noOfPersons ; j++)<br />
&nbsp; {<br />
&nbsp; &nbsp; &nbsp; if(toBeSorted[i]==sameArr[j])<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; newarr[k]=j+1; k++; <br />
&nbsp; &nbsp; &nbsp; &nbsp; sameArr[j]=-1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp;  }<br />
&nbsp; }<br />
&nbsp; /*for(l=0; l&lt;k; l++)<br />
&nbsp; printf(&quot;\nnew:%d&quot;,newarr[l]);<br />
&nbsp; /*for(i=0;i&lt;noOfPersons;i++)<br />
&nbsp; printf(&quot;\nsort:%d\tactual:%d&quot;,toBeSorted[i],browsingTime[i]);*/<br />
&nbsp; //to implement th algo on the sorted array<br />
&nbsp; i=0,k=0;<br />
&nbsp; while(1)<br />
&nbsp; {<br />
&nbsp; &nbsp;  if(remUsers == noOfPersons)&nbsp; break;<br />
&nbsp; &nbsp;  else if(toBeSorted[i] == -1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; i=(i+1)%noOfPersons;<br />
&nbsp; &nbsp;  else if(toBeSorted[i] &lt;= timeSlot)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; soln.schedule[k]=newarr[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; k++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; soln.nSize++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; toBeSorted[i]=-1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; remUsers++;&nbsp;  // printf(&quot;\trem:%d&quot;,remUsers);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i=(i+1)%noOfPersons; <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  else if(toBeSorted[i] &gt; timeSlot)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; soln.schedule[k]=newarr[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; toBeSorted[i]=toBeSorted[i]-timeSlot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //printf(&quot;\tin &gt;::%d&quot;,toBeSorted[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; k++;&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  soln.nSize++; i=(i+1)%noOfPersons; <br />
&nbsp; &nbsp;  }<br />
&nbsp;  <br />
&nbsp; }&nbsp; &nbsp; <br />
&nbsp;return soln; <br />
}<br />
<br />
// Following main function contains 3 representative test cases<br />
<br />
int main()&nbsp; &nbsp; &nbsp; &nbsp; <br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Testcase 1:<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i,browsingtime[] = {10,7,3,4,11};<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int size = 5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int time_slot = 5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; struct IntArray res = getSchedule(browsingtime, size, time_slot);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(res.schedule != NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i=0;i&lt;res.nSize;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf (&quot;%d, &quot;,res.schedule[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Testcase 2:<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i,browsingtime[] = {3,7,14,4,11};<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int size = 5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int time_slot = 7;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; struct IntArray res = getSchedule(browsingtime, size, time_slot);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(res.schedule != NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i=0;i&lt;res.nSize;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf (&quot;%d, &quot;,res.schedule[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Testcase 3:<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i,browsingtime[] = {4,2,5};<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int size = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int time_slot = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; struct IntArray res = getSchedule(browsingtime, size, time_slot);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(res.schedule != NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i=0;i&lt;res.nSize;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf (&quot;%d, &quot;,res.schedule[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre>Can anyone please tell me where the mistake is?I am getting a rumtime error.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>want_to_code</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236393.html</guid>
		</item>
		<item>
			<title>dynamic Array in C from strings</title>
			<link>http://www.daniweb.com/forums/thread236373.html</link>
			<pubDate>Thu, 05 Nov 2009 20:43:34 GMT</pubDate>
			<description>Hi to all, 
Could someone show me by giving a code  about how to create dynamic an Array in C, (nxm) from strings and read values in this array ? 
Thanks in advance...</description>
			<content:encoded><![CDATA[<div>Hi to all,<br />
Could someone show me by giving a code  about how to create dynamic an Array in C, (nxm) from strings and read values in this array ?<br />
Thanks in advance...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>PBIRBAS</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236373.html</guid>
		</item>
		<item>
			<title>Question in Arrays - Give an advice</title>
			<link>http://www.daniweb.com/forums/thread236372.html</link>
			<pubDate>Thu, 05 Nov 2009 20:40:43 GMT</pubDate>
			<description><![CDATA[The following problem has to do with Arrays. I would appreciate if someone could give an explanation in this assumption below: 
 
If we assume that SIZE is a catholic constant with value 100 and A is Array of size SIZE with n stored elements from left to right. If it is assumed that Array's...]]></description>
			<content:encoded><![CDATA[<div>The following problem has to do with Arrays. I would appreciate if someone could give an explanation in this assumption below:<br />
<br />
If we assume that SIZE is a catholic constant with value 100 and A is Array of size SIZE with n stored elements from left to right. If it is assumed that Array's elements are not initialised and at n first position there are numbers from 1 to n in ascending numerical order, what will be the printout of the following command and why ?<br />
for (i=0; i&lt;SIZE; i++)<br />
printf(&quot;%d, &quot; A[i]);<br />
Thanks in advance...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>PBIRBAS</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236372.html</guid>
		</item>
		<item>
			<title>Hwk: how do I make a 2d array of pointers point to another array</title>
			<link>http://www.daniweb.com/forums/thread236338.html</link>
			<pubDate>Thu, 05 Nov 2009 18:16:11 GMT</pubDate>
			<description><![CDATA[Hi, I'm new here and I just need a little help with pointers and 2D arrays. I'm kind of new to programming so this might be redundant. I'm trying to make a 2D array of pointers (already have done) that points to another 2D array of double values... I have the code: 
 
  <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hi, I'm new here and I just need a little help with pointers and 2D arrays. I'm kind of new to programming so this might be redundant. I'm trying to make a 2D array of pointers (already have done) that points to another 2D array of double values... I have the code:<br />
<br />
 <pre style="margin:20px; line-height:13px">for (i = 0; i &lt; n; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (j = 0; j &lt; n; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptrA[i][j] = a[j][i];</pre>**its transposed for a reason**<br />
<br />
However when I do calculations on array ptrA, it doesnt change the values in array a...<br />
<br />
ptrA and a are declared by  <pre style="margin:20px; line-height:13px">double a[n][n];<br />
double temp;<br />
for (i = 0; i &lt; n; i++){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //intializing [A] to inputs<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (j = 0; j &lt; n; j++){ <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%lf&quot;, &amp;temp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a[i][j] = temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
double **ptrA = malloc(n*sizeof(*ptrA));<br />
if (ptrA != NULL){<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; n; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptrA[i] = malloc(n*sizeof(*ptrA[i]));<br />
} else return 1;</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Tamaki</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236338.html</guid>
		</item>
		<item>
			<title>Detect Multicore processors</title>
			<link>http://www.daniweb.com/forums/thread236332.html</link>
			<pubDate>Thu, 05 Nov 2009 17:34:50 GMT</pubDate>
			<description><![CDATA[Hey everyone, 
 
For my project, I need to write an assembly/C code to detect multiprocessors. I really have no idea how as I have barely done assembly coding and I have no good reference or even idea how to start. Again, what I am going to do is, I'm trying to find how many processors on dual core...]]></description>
			<content:encoded><![CDATA[<div>Hey everyone,<br />
<br />
For my project, I need to write an assembly/C code to detect multiprocessors. I really have no idea how as I have barely done assembly coding and I have no good reference or even idea how to start. Again, what I am going to do is, I'm trying to find how many processors on dual core or quad core chips there are and detect them and later on use them. Please help me out here.<br />
<br />
Thanks a lot.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>group256</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236332.html</guid>
		</item>
		<item>
			<title>Prime numbers from 1 to 100</title>
			<link>http://www.daniweb.com/forums/thread236262.html</link>
			<pubDate>Thu, 05 Nov 2009 12:47:07 GMT</pubDate>
			<description>Please, I need help in this little problem of printing all the prime numbers from  to 100. Please, if you have more than one method to the question, I would really appreciate it. I also need it as soon as possible. Thanks.</description>
			<content:encoded><![CDATA[<div>Please, I need help in this little problem of printing all the prime numbers from  to 100. Please, if you have more than one method to the question, I would really appreciate it. I also need it as soon as possible. Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>imolorhe</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236262.html</guid>
		</item>
		<item>
			<title>How to produce an assembly file (.asm) on Windows by program in C</title>
			<link>http://www.daniweb.com/forums/thread236078.html</link>
			<pubDate>Wed, 04 Nov 2009 23:09:38 GMT</pubDate>
			<description><![CDATA[How to produce an assembly file (.asm) on Windows by having a program in C? 
I use NetBeans 6.7.1 on Windows and it would help me a lot if i could do that, 
additionaly do you know a way that the syntax produced will be compatible with MASM? 
I have Ubuntu too and i used the command 
  <div...]]></description>
			<content:encoded><![CDATA[<div>How to produce an assembly file (.asm) on Windows by having a program in C?<br />
I use NetBeans 6.7.1 on Windows and it would help me a lot if i could do that,<br />
additionaly do you know a way that the syntax produced will be compatible with MASM?<br />
I have Ubuntu too and i used the command<br />
 <pre style="margin:20px; line-height:13px">gcc -S file.c</pre> and produced a (.s) file that i cannot run either.<br />
Do you know a way of doing the first thing or both?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>panagos</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236078.html</guid>
		</item>
		<item>
			<title>Help with self made atoi Function.</title>
			<link>http://www.daniweb.com/forums/thread236009.html</link>
			<pubDate>Wed, 04 Nov 2009 17:10:33 GMT</pubDate>
			<description><![CDATA[I am trying to implement my own atoi function, and I am supposed to pass my variables in after ./a.out. 
 
Here is my code: 
 
#include <stdio.h> 
#include <stdlib.h> 
 
int myatoi(char array[]) 
{ 
        int sum = 0;]]></description>
			<content:encoded><![CDATA[<div>I am trying to implement my own atoi function, and I am supposed to pass my variables in after ./a.out.<br />
<br />
Here is my code:<br />
<br />
#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
int myatoi(char array[])<br />
{<br />
        int sum = 0;<br />
        int i = 0;<br />
<br />
        while(array[i] != '\0') {<br />
                int number = array[i] - '0';<br />
                sum = 10 * sum + number;<br />
                i++;<br />
                }<br />
<br />
        return sum;<br />
}<br />
<br />
int main(int argc, char *Name[]) {<br />
/*      char *Name = &quot;Josh&quot;;   */<br />
        printf(&quot;%d&quot;,myatoi(Name));<br />
        return 0;<br />
}<br />
<br />
<br />
<br />
<br />
I am getting  an error message:<br />
myatoi.c: In function âmainâ:<br />
myatoi.c:20: warning: passing argument 1 of âmyatoiâ from incompatible pointer type<br />
<br />
This is in the printf statement. What am I doing wrong?<br />
<br />
Also, the program works if I take out the arguments into main and uncomment the first line of main.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Soileau</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236009.html</guid>
		</item>
		<item>
			<title>left operand must be l-value</title>
			<link>http://www.daniweb.com/forums/thread236007.html</link>
			<pubDate>Wed, 04 Nov 2009 17:06:50 GMT</pubDate>
			<description><![CDATA[what's wrong here? 
 
 
typedef struct person 
{ 
	int age; 
	char name[50]; 
}; 
 
int main()]]></description>
			<content:encoded><![CDATA[<div>what's wrong here?<br />
<br />
 <pre style="margin:20px; line-height:13px">typedef struct person<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int age;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char name&#91;50&#93;;<br />
};<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; struct person test;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; test.age = 20;<br />
&nbsp; &nbsp; &nbsp; &nbsp; test.name = &quot;Test&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>fatihpiristine</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236007.html</guid>
		</item>
		<item>
			<title>raw sockets using mac addresses</title>
			<link>http://www.daniweb.com/forums/thread235995.html</link>
			<pubDate>Wed, 04 Nov 2009 16:00:49 GMT</pubDate>
			<description><![CDATA[Hi everyone. 
 
I'm diving head first into the fascinating world of  Linux network programming. 
I've read about using sockets to do the networking, however, all the books I've seen so far have talked about IP addresses. 
 
My goal is to connect my PC to a development board and make them talk...]]></description>
			<content:encoded><![CDATA[<div>Hi everyone.<br />
<br />
I'm diving head first into the fascinating world of  Linux network programming.<br />
I've read about using sockets to do the networking, however, all the books I've seen so far have talked about IP addresses.<br />
<br />
My goal is to connect my PC to a development board and make them talk through Ethernet. I think that MAC addresses are the way to go here (instead of IP) but I can't find a reference of this anywhere. <br />
<br />
It would help me a lot if someone here could explain how to approach this. Also, if my notion is incorrect I would be glad to hear sooner than later.<br />
<br />
Thank you,<br />
Gadi</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>GadiK</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235995.html</guid>
		</item>
		<item>
			<title>AIrline Booking System</title>
			<link>http://www.daniweb.com/forums/thread235985.html</link>
			<pubDate>Wed, 04 Nov 2009 15:01:02 GMT</pubDate>
			<description>Hello guys....I just have some doubt about C programming...well I have done a lot of functions for airline booking system but im not able to implement the multi dimensional array... I dont get how should I implement it in this problem as the variables are global and they are used in different...</description>
			<content:encoded><![CDATA[<div>Hello guys....I just have some doubt about C programming...well I have done a lot of functions for airline booking system but im not able to implement the multi dimensional array... I dont get how should I implement it in this problem as the variables are global and they are used in different functions. So below is just a part of where i am blur on how to use the multidimensional array...here im trying to use 4 dimensional array and I get a lot of errors in it....Hope you guys can help me out....Thanks<br />
<br />
 <pre style="margin:20px; line-height:13px">void menu_PurchaseTicket()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; menu_chooseTicket();//a variable is used to store the input here<br />
&nbsp; &nbsp; &nbsp; &nbsp; menu_ChooseDestination();//a variable is used to store the input here<br />
&nbsp; &nbsp; &nbsp; &nbsp; menu_ChooseTime();//a variable is used to store the input here<br />
&nbsp; &nbsp; &nbsp; &nbsp; menu_ViewSeating();//function showing the seats arrangement in rows and columns(5x5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; menu_ChooseSeat();//a variable is used to store the input here<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int seat[cust_TicketClass][cust_Destination][cust_Time][cust_Seat];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int a,b,c,d;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(a=0;a&lt;2;a++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(cust_TicketClass == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Business Class&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Economy Class&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(b=0;b&lt;2;b++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(cust_Destination == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Destination: Kuala Lumpur --&gt; Langkawi\n\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Destination: Langkawi --&gt; Kuala Lumpur\n\n&quot;);<br />
&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; for(c=0;c&lt;5;c++)<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; switch(cust_Time)<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '1':<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; printf(&quot;Departure Time: 9.00 a.m\n&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '2':<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; printf(&quot;Departure Time: 11.00 a.m\n&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '3':<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; printf(&quot;Departure Time: 1.00 p.m\n&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '4':<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; printf(&quot;Departure Time: 3.00 p.m\n&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '5':<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; printf(&quot;Departure Time: 5.00 p.m\n&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:<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; printf(&quot;Please enter the correct selection\n\n&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(d=0;d&lt;25;d++)<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(cust_Seat&gt;25 || cust_Seat&lt;0)<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; printf(&quot;Invalid Seat Number&quot;);<br />
<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; if(cust_Seat&gt;0 || cust_Seat&lt;25)<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; seat[cust_TicketClass][cust_Destination][cust_Time][cust_Seat]=1;<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Bheeman89</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235985.html</guid>
		</item>
		<item>
			<title>passing structuce to function as an argument</title>
			<link>http://www.daniweb.com/forums/thread235959.html</link>
			<pubDate>Wed, 04 Nov 2009 12:45:32 GMT</pubDate>
			<description>This is the problem: 
 
In this exercise you have to write a program to manage items in a super market.  
Suppose that the data about each item includes:  
•  Item’s ID: ID of the item, it is an integer which ranges from 1 to 9999  
•  Item’s type: Its value is:  
•  1 if the item is food  
•  2 if...</description>
			<content:encoded><![CDATA[<div>This is the problem:<br />
<br />
In this exercise you have to write a program to manage items in a super market. <br />
Suppose that the data about each item includes: <br />
•  Item’s ID: ID of the item, it is an integer which ranges from 1 to 9999 <br />
•  Item’s type: Its value is: <br />
•  1 if the item is food <br />
•  2 if the item is electrical good <br />
•  3 if the item is household good <br />
•  Item’s price <br />
 <br />
1.  Create a structure template that contains data of one item. Then use this template to declare an array <br />
of structures that stores data of maximum 50 items. <br />
2.  Ask user to input the list of N items from the keyboard. Then print out the list of items on the screen. <br />
3.  Print out the title of the item which has maximum price. <br />
 Here is my source code<br />
 <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
#include&lt;conio.h&gt;<br />
#define MAX 50<br />
<br />
struct good <br />
{<br />
&nbsp;  int id;<br />
&nbsp;  int type;<br />
&nbsp;  float price;<br />
};<br />
struct good item[MAX];<br />
int n;<br />
int pos;<br />
<br />
void input()<br />
{ char temp[40];<br />
&nbsp; int i;<br />
&nbsp; printf(&quot;how many items u want to store: &quot;); scanf(&quot;%d&quot;,&amp;n);<br />
&nbsp; for(i=0; i&lt;n; i++)<br />
&nbsp; {<br />
&nbsp; &nbsp; printf(&quot;\nItem %d: &quot;,i+1);<br />
&nbsp; &nbsp; do<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;\n id:&quot;);<br />
&nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;,&amp;item[i].id);<br />
&nbsp; &nbsp; } while( (item[i].id&lt;0) || (item[i].id&gt;9999) );<br />
&nbsp; &nbsp; printf(&quot;\n Type: &quot;);<br />
&nbsp; &nbsp; fflush(stdin);<br />
&nbsp; &nbsp; gets(temp);<br />
&nbsp; &nbsp; if(strcmp(temp,&quot;food&quot;)==0)<br />
&nbsp; &nbsp; &nbsp;  item[i].type=1;<br />
&nbsp; &nbsp; &nbsp;  else if(strcmp(temp,&quot;electrical&quot;)==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  item[i].type=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if(strcmp(temp,&quot;household&quot;)==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  item[i].type=3;<br />
&nbsp; &nbsp; printf(&quot;\n Price: &quot;);<br />
&nbsp; &nbsp; scanf(&quot;%f&quot;,&amp;item[i].price);<br />
&nbsp; }<br />
}<br />
<br />
void display()<br />
{ <br />
&nbsp; int i;<br />
&nbsp; for(i=0; i&lt;n; i++)<br />
&nbsp; {<br />
&nbsp; &nbsp; printf(&quot;Item %d: &quot;,i+1);<br />
&nbsp; &nbsp; printf(&quot;\n id %d, type %d, price %f\n&quot;,item[i].id,item[i].type, item[i].price);<br />
&nbsp; }<br />
}<br />
<br />
<br />
<br />
struct good price(struct good arr[])<br />
{<br />
&nbsp; int i,pos;<br />
&nbsp; struct good temp;<br />
&nbsp; <br />
&nbsp; temp&nbsp; = item[0];<br />
&nbsp; for(i=0; i&lt;n; i++)<br />
&nbsp; {<br />
&nbsp; &nbsp; if(temp.price &lt; item[i].price)<br />
&nbsp; &nbsp; temp = item[i];<br />
&nbsp; }<br />
&nbsp; return temp ;<br />
}<br />
&nbsp; <br />
void display_item(struct good *p)<br />
{&nbsp; <br />
&nbsp; printf(&quot;\n id %d, type %d, price %f\n&quot;,p -&gt; id, p -&gt; type, p -&gt; price);&nbsp; <br />
}<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; input();<br />
&nbsp; &nbsp; display();<br />
&nbsp; &nbsp; struct good item_max;<br />
&nbsp; &nbsp; item_max =struct good price(item[MAX]);<br />
&nbsp; &nbsp; display_item(&amp;item_max);<br />
&nbsp; &nbsp; getch();<br />
&nbsp; &nbsp; return 0;<br />
}</pre>to solve problem number 3, I use a function to find the item having max price , then print its details ,but I cannot passing the structure &quot;item&quot; found in function struct good price(struct good arr[]) to display_item function.<br />
Please help me find the mistake!<br />
Thanks a  lot!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>thebluestar</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235959.html</guid>
		</item>
		<item>
			<title>c langauge 2nd edition</title>
			<link>http://www.daniweb.com/forums/thread235926.html</link>
			<pubDate>Wed, 04 Nov 2009 10:03:37 GMT</pubDate>
			<description><![CDATA[please provide the  free pdf link of k & R c prog lang. 
 
i spent lot of time in googling but couldnot get it. 
 
thanks in adv.]]></description>
			<content:encoded><![CDATA[<div>please provide the  free pdf link of k &amp; R c prog lang.<br />
<br />
i spent lot of time in googling but couldnot get it.<br />
<br />
thanks in adv.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Iam3R</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235926.html</guid>
		</item>
		<item>
			<title>Question About Random?</title>
			<link>http://www.daniweb.com/forums/thread235781.html</link>
			<pubDate>Tue, 03 Nov 2009 21:58:29 GMT</pubDate>
			<description><![CDATA[How do I generate random numbers in C?  The user doesn't enter anything, I'm just looking for a way to generate random numbers every time I run the program. 
 
Thanks guys!]]></description>
			<content:encoded><![CDATA[<div>How do I generate random numbers in C?  The user doesn't enter anything, I'm just looking for a way to generate random numbers every time I run the program.<br />
<br />
Thanks guys!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>spatel14</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235781.html</guid>
		</item>
		<item>
			<title>find string in file</title>
			<link>http://www.daniweb.com/forums/thread235776.html</link>
			<pubDate>Tue, 03 Nov 2009 21:51:21 GMT</pubDate>
			<description>Hello friends, I am having a problem writing a function to search for a string in an input file. I have successfully output the file with line numbers, which was the first step in the program, but now I am stuck on searching for a given string. After searching for the string I want to print the...</description>
			<content:encoded><![CDATA[<div>Hello friends, I am having a problem writing a function to search for a string in an input file. I have successfully output the file with line numbers, which was the first step in the program, but now I am stuck on searching for a given string. After searching for the string I want to print the number of times it appears in the input file. As of right now all the function does is return a junk number. I have tried many different things and haven't gotten anything to work correctly.<br />
Here is my code<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
#define MAX 1000<br />
void find_string(char text[], char pattern[]);<br />
int main()<br />
{<br />
&nbsp; &nbsp; char pattern[] = &quot;of&quot;; //string to search for<br />
&nbsp; &nbsp; int counter = 0;<br />
&nbsp; &nbsp; static const char filename[] = &quot;in.txt&quot;;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; FILE *file = fopen(filename, &quot;r&quot;);&nbsp; &nbsp; <br />
&nbsp; &nbsp; if ( file != NULL )<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp;  char line [ MAX ]; <br />
<br />
&nbsp; &nbsp; &nbsp; while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ++counter;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf( &quot;%d&nbsp; &quot;, counter);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fputs ( line, stdout ); /* write the line */<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; printf( &quot;\n\n&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; find_string(filename, pattern);<br />
&nbsp; &nbsp; &nbsp; fclose ( file );<br />
&nbsp;  }<br />
&nbsp;  else<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; perror ( filename ); <br />
&nbsp;  }<br />
&nbsp;  <br />
&nbsp;  char wait;<br />
&nbsp;  scanf( &quot;%c&quot;, &amp;wait );<br />
&nbsp;  return(0);<br />
}<br />
<br />
void find_string(char text[], char pattern[])<br />
{<br />
&nbsp; &nbsp;  int matches;<br />
&nbsp; &nbsp;  static const char filename[] = &quot;in.txt&quot;;&nbsp; &nbsp; <br />
&nbsp; &nbsp;  FILE *file = fopen(filename, &quot;r&quot;);&nbsp; &nbsp; <br />
&nbsp; &nbsp;  if ( file != NULL )<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; char line [ MAX ]; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while ( fgets ( line, sizeof line, file ) != NULL ) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if( line == pattern)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matches++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  printf(&quot;%d&quot;, matches);<br />
&nbsp; &nbsp;  }<br />
}</pre>Thanks to anyone who takes the time to point me in the right direction.  <br />
 <br />
I attached the input file as an attachment.<br />
Thanks again for any help.</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/images/attach/txt.gif" alt="File Type: txt" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12445&amp;d=1257285034">in.txt</a> (526 Bytes)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Grn Xtrm</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235776.html</guid>
		</item>
		<item>
			<title>switch case problem with characters</title>
			<link>http://www.daniweb.com/forums/thread235729.html</link>
			<pubDate>Tue, 03 Nov 2009 18:45:09 GMT</pubDate>
			<description><![CDATA[Hello guys, 
 
How can I make a switch case using an array of chars. 
Ex: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>Hello guys,<br />
<br />
How can I make a switch case using an array of chars.<br />
Ex:<br />
 <pre style="margin:20px; line-height:13px">char input[50];<br />
// my code here<br />
switch ( input ) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; case &quot;abc&quot;:&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // do something<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case &quot;xyz&quot;:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // do otherthings<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
}</pre><br />
Is that possible in C?<br />
<br />
Thank you!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>miskeen</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235729.html</guid>
		</item>
		<item>
			<title>32 bits/64 bits case</title>
			<link>http://www.daniweb.com/forums/thread235717.html</link>
			<pubDate>Tue, 03 Nov 2009 18:12:59 GMT</pubDate>
			<description><![CDATA[Hi All, 
I have the application which will be support 32 bits and 64 bits 
and below are the statement to handle 32bits/64bits data  
and new_node->data  
 is void * new_node->data  
for ( index = 0 ; index < items ;index++ ) { 
   if (data_size == SIZE_32 ) { 
      * (...]]></description>
			<content:encoded><![CDATA[<div>Hi All,<br />
I have the application which will be support 32 bits and 64 bits<br />
and below are the statement to handle 32bits/64bits data <br />
and new_node-&gt;data <br />
 is void * new_node-&gt;data <br />
for ( index = 0 ; index &lt; items ;index++ ) {<br />
   if (data_size == SIZE_32 ) {<br />
      * ( ((int32_t*)(new_node-&gt;data)) + index) = (int32_t) index*2 ;<br />
      * ( ((int32_t*)(new_node-&gt; data)) + index) = (int32_t) index*3<br />
    }<br />
   else {<br />
       * ( ((int64_t*)(new_node-&gt; data)) + index) = (int64_t) index*4;<br />
      * ( ((int64_t*)(new_node-&gt; data)) + index) = (int64_t) index*5;<br />
		}<br />
	}<br />
Is there any better to handle this without the if/else statement (if ((data_size == SIZE_32 ) {<br />
Thanks<br />
J</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>jodie121997</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235717.html</guid>
		</item>
		<item>
			<title>Pthread support in Vxworks</title>
			<link>http://www.daniweb.com/forums/thread235692.html</link>
			<pubDate>Tue, 03 Nov 2009 16:09:34 GMT</pubDate>
			<description>How to support Pthread calls like(pthread_create) in Vxworks 5.5 
 
We have include the macro INCLUDE_POSIX_PTHREAD but we are getting linker error while loading. 
 
We tried to build the bsp(In tornado 2.2) with the pthread after changing the config file but we were not able to build the bsp</description>
			<content:encoded><![CDATA[<div>How to support Pthread calls like(pthread_create) in Vxworks 5.5<br />
<br />
We have include the macro INCLUDE_POSIX_PTHREAD but we are getting linker error while loading.<br />
<br />
We tried to build the bsp(In tornado 2.2) with the pthread after changing the config file but we were not able to build the bsp</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>ankur_</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235692.html</guid>
		</item>
		<item>
			<title>Print table of  a number entered by user</title>
			<link>http://www.daniweb.com/forums/thread235631.html</link>
			<pubDate>Tue, 03 Nov 2009 11:21:54 GMT</pubDate>
			<description>Hi, 
 
I would like to print the table of a number entered by the user like 
 
2 *1=2 
2*2=4 
2*3=6 
 
The code is</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I would like to print the table of a number entered by the user like<br />
<br />
2 *1=2<br />
2*2=4<br />
2*3=6<br />
<br />
The code is<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
#include&lt;conio.h&gt;<br />
<br />
main()<br />
<br />
{<br />
<br />
int i,num;<br />
<br />
printf(&quot;Enter any number&quot;);<br />
scanf(&quot;%d&quot;,&amp;num);<br />
<br />
for(i=1;i&lt;=num;i++)<br />
<br />
printf(&quot;%d*%d=%d&quot;,num,i,num*i);<br />
<br />
getch();<br />
<br />
}</pre><br />
But this code is generating errors.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>seo2005</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235631.html</guid>
		</item>
		<item>
			<title>Display in C for multiple threads</title>
			<link>http://www.daniweb.com/forums/thread235563.html</link>
			<pubDate>Tue, 03 Nov 2009 05:22:21 GMT</pubDate>
			<description><![CDATA[Hello, 
 
I need a pointer on how exactly I can use part of the terminal for inpit and another part for output. 
 
Example 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680"...]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I need a pointer on how exactly I can use part of the terminal for inpit and another part for output.<br />
<br />
Example<br />
<br />
 <pre style="margin:20px; line-height:13px">Enter the next command&gt; [my command]&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;  &lt;other thread display some stuff&gt;</pre><br />
Because I have a thread to display and a thread to read and I don't want to mix both outputs together.<br />
<br />
Is there a way to do it in ANSI C/ posix ?<br />
<br />
I just need a pointer to standard routines or library that I can use.<br />
<br />
Thanks,</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>chornox</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235563.html</guid>
		</item>
		<item>
			<title>nth last element with o(n) complexity</title>
			<link>http://www.daniweb.com/forums/thread235559.html</link>
			<pubDate>Tue, 03 Nov 2009 04:58:22 GMT</pubDate>
			<description><![CDATA[written a code for finding nth last element but no idea how to caluculate complexity. 
 
how can i make this, of 0(n) complexity. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>written a code for finding nth last element but no idea how to caluculate complexity.<br />
<br />
how can i make this, of 0(n) complexity.<br />
<br />
 <pre style="margin:20px; line-height:13px">// p is position of element to find<br />
<br />
int nthlast(struct node *n, int p) {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; struct node *f, *s;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(n) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int cnt=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f = n;// start address store in first pointer<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(n != NULL &amp;&amp; cnt&lt;p-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n=n-&gt;next, cnt++; // move the the pointer p-1 times<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!n) /* if the entered poistion is greater than the no of elements */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  return -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(p &lt;= 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  return -2; /* if entered poisition is lessthan or equal to zero */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s = n;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(n)&nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int cnt = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(n != NULL &amp;&amp; cnt &lt; p-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n=n-&gt;next, cnt++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(n) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  f = s;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  s = n;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int i=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  while(i&lt;cnt-1)&nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  f=f-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  return f-&gt;data;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(p==1) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  n=n-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  s = n;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return f-&gt;data;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
//Driver code:<br />
<br />
<br />
&nbsp;int main()<br />
&nbsp;{<br />
<br />
&nbsp; struct node*p=NULL;<br />
&nbsp; int n,d,i=0,ele,a[10]={1,2,3,4,5,6,7,8,9,10};<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(i&lt;10)<br />
&nbsp; &nbsp;  {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; insert(&amp;p,a[i++]);<br />
&nbsp; &nbsp;  }<br />
display(p);<br />
printf(&quot;nter the pos\n&quot;);<br />
scanf(&quot;%d&quot;,&amp;n);<br />
if((ele = nthlast(p,n)) &gt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n%d&quot;,ele);<br />
else if(!ele)<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;list empty\n&quot;);<br />
else if(ele == -1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;no of elements less than the pos\n&quot;);<br />
else<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;positio shuold be &gt; 0\n&quot;);<br />
<br />
&nbsp; return 0;<br />
&nbsp;}<br />
<br />
<br />
inserting elements function:<br />
<br />
void insert(struct node**p,int num)<br />
&nbsp;{<br />
&nbsp;  if(*p==NULL)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; (*p)=malloc(sizeof(struct node));<br />
&nbsp; &nbsp; &nbsp; (*p)-&gt;next=NULL;<br />
&nbsp; &nbsp; &nbsp; (*p)-&gt;data=num;<br />
&nbsp; &nbsp;  }<br />
&nbsp;  else<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp;  insert(&amp;((*p)-&gt;next),num);<br />
&nbsp; &nbsp; }<br />
&nbsp;}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Iam3R</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235559.html</guid>
		</item>
		<item>
			<title><![CDATA[What in the world does "type double unexpected" mean?]]></title>
			<link>http://www.daniweb.com/forums/thread235544.html</link>
			<pubDate>Tue, 03 Nov 2009 03:43:19 GMT</pubDate>
			<description><![CDATA[So I finally get to the end of this evil program, and then it won't compile because it says "type double not expected". 
 
Here is my error message in its entirety: 
program 3 item.cpp(111) : error C2062: type 'double' unexpected 
program 3 item.cpp(121) : error C2062: type 'double' unexpected...]]></description>
			<content:encoded><![CDATA[<div>So I finally get to the end of this evil program, and then it won't compile because it says &quot;type double not expected&quot;.<br />
<br />
Here is my error message in its entirety:<br />
program 3 item.cpp(111) : error C2062: type 'double' unexpected<br />
program 3 item.cpp(121) : error C2062: type 'double' unexpected<br />
program 3 item.cpp(131) : error C2062: type 'double' unexpected<br />
<br />
And here is a link to my codes (with the line numbers, so hopefully it won't be that hard to see what I'm doing wrong)<br />
<a rel="nofollow" class="t" href="http://pastebin.com/mff1e676" target="_blank">http://pastebin.com/mff1e676</a><br />
<br />
Thanks for the help :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>A Tripolation</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235544.html</guid>
		</item>
		<item>
			<title>Code Snippet help with c program</title>
			<link>http://www.daniweb.com/code/snippet235508.html</link>
			<pubDate>Tue, 03 Nov 2009 00:07:10 GMT</pubDate>
			<description>HI  
 the prgram below request a user to enter 3 character id number and interger age.  a function must be used 
that tells the user how many years to retirement.  i must pass the age and print 
a message in the function. retirement age is 65 for persons over 45 and 70 for all 
other persons. the...</description>
			<content:encoded><![CDATA[<div>HI <br />
 the prgram below request a user to enter 3 character id number and interger age.  a function must be used<br />
that tells the user how many years to retirement.  i must pass the age and print<br />
a message in the function. retirement age is 65 for persons over 45 and 70 for all<br />
other persons. the id number is a 3 element character array.  the program<br />
should continue to accept user input until the id number entered is 000 or age is<br />
-1. <br />
<br />
please help.  i am fairly new to c and i am unsure of how to do the function part.<br />
<br />
my program is compiling and running but a long number is printing and not the age.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>maubybark</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235508.html</guid>
		</item>
		<item>
			<title>Fraction to float</title>
			<link>http://www.daniweb.com/forums/thread235480.html</link>
			<pubDate>Mon, 02 Nov 2009 21:30:17 GMT</pubDate>
			<description><![CDATA[I'm currently working with a group of my classmates on a recipe measurement converter, and I'm currently on the most difficult code of the three that is my part of the project.  The code is basically for getting the amount from the user, a fraction.  I have based my algorithm as reading the...]]></description>
			<content:encoded><![CDATA[<div>I'm currently working with a group of my classmates on a recipe measurement converter, and I'm currently on the most difficult code of the three that is my part of the project.  The code is basically for getting the amount from the user, a fraction.  I have based my algorithm as reading the fraction as a string and converting it into an int.  I haven't got a decent piece of code together yet, I'm still jotting out my algorithm and just keep getting turned around...please if someone can help with any ideas please do so I might can make a start at this!!! Thanks so much!  Kat</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>kat_stephens</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235480.html</guid>
		</item>
		<item>
			<title>Assigning an array values from another array</title>
			<link>http://www.daniweb.com/forums/thread235475.html</link>
			<pubDate>Mon, 02 Nov 2009 21:11:55 GMT</pubDate>
			<description><![CDATA[I am attempting to write a simple chess program (starting with just pawns), and am currently at the stage of initialising the board. 
 
The initial board is declared using an array of numbers, with '0' indicating a white piece, '1' indicating a black piece and '2' indicating an empty square. 
 
I'm...]]></description>
			<content:encoded><![CDATA[<div>I am attempting to write a simple chess program (starting with just pawns), and am currently at the stage of initialising the board.<br />
<br />
The initial board is declared using an array of numbers, with '0' indicating a white piece, '1' indicating a black piece and '2' indicating an empty square.<br />
<br />
I'm then trying to get the initial state of the board printed back to me, but currently all squares are indicated as white (0), so it appears the values are not being assigned in the array correctly.  <br />
<br />
The code I currently have is:<br />
<br />
Main.c<br />
 <pre style="margin:20px; line-height:13px">/*<br />
&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; main.c<br />
&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; P Chess<br />
&nbsp;*<br />
&nbsp;*/<br />
<br />
#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;signal.h&gt;<br />
#include &quot;defs.h&quot;<br />
#include &quot;boardrep.h&quot;<br />
<br />
void init_board()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; 64; ++i) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; colour&#91;i&#93; = init_colour&#91;i&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
void print_board()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n8 &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; 64; ++i) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (colour&#91;i&#93;) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case EMPTY:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot; -&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case BLACK:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot; b&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case WHITE:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot; w&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((i + 1) % 8 == 0 &amp;&amp; i != 63)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n%d &quot;, 7 - ROW(i));<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n\n&nbsp;  a b c d e f g h\n\n&quot;);<br />
}<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char s&#91;256&#93;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Pawn Chess - Board representation\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;version 0.01, 26/10/09\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\&quot;d\&quot; displays the current board state\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre><br />
Boardrep.c<br />
 <pre style="margin:20px; line-height:13px">/*<br />
&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; boardrep.c<br />
&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; P Chess<br />
&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;*/<br />
<br />
#include &quot;defs.h&quot;<br />
<br />
/* the board representation */<br />
int colour&#91;64&#93;;&nbsp; /* WHITE, BLACK, or EMPTY */<br />
<br />
int mailbox&#91;120&#93; = {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1,&nbsp; 0,&nbsp; 1,&nbsp; 2,&nbsp; 3,&nbsp; 4,&nbsp; 5,&nbsp; 6,&nbsp; 7, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1,&nbsp; 8,&nbsp; 9, 10, 11, 12, 13, 14, 15, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1, 16, 17, 18, 19, 20, 21, 22, 23, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1, 24, 25, 26, 27, 28, 29, 30, 31, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1, 32, 33, 34, 35, 36, 37, 38, 39, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1, 40, 41, 42, 43, 44, 45, 46, 47, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1, 48, 49, 50, 51, 52, 53, 54, 55, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1, 56, 57, 58, 59, 60, 61, 62, 63, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,<br />
&nbsp; &nbsp; &nbsp; &nbsp;  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1<br />
};<br />
<br />
int mailbox64&#91;64&#93; = {<br />
&nbsp; &nbsp; &nbsp; &nbsp; 21, 22, 23, 24, 25, 26, 27, 28,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 31, 32, 33, 34, 35, 36, 37, 38,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 41, 42, 43, 44, 45, 46, 47, 48,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 51, 52, 53, 54, 55, 56, 57, 58,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 61, 62, 63, 64, 65, 66, 67, 68,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 71, 72, 73, 74, 75, 76, 77, 78,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 81, 82, 83, 84, 85, 86, 87, 88,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 91, 92, 93, 94, 95, 96, 97, 98<br />
};<br />
<br />
int init_colour&#91;64&#93; = {<br />
&nbsp; &nbsp; &nbsp; &nbsp; 1, 1, 1, 1, 1, 1, 1, 1,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 2, 2, 2, 2, 2, 2, 2, 2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 2, 2, 2, 2, 2, 2, 2, 2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 2, 2, 2, 2, 2, 2, 2, 2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 2, 2, 2, 2, 2, 2, 2, 2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 2, 2, 2, 2, 2, 2, 2, 2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 2, 2, 2, 2, 2, 2, 2, 2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; 0, 0, 0, 0, 0, 0, 0, 0<br />
};</pre><br />
boardrep.h<br />
 <pre style="margin:20px; line-height:13px">/*<br />
&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; boardrep.h<br />
&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; p chess<br />
&nbsp;*/<br />
<br />
extern int colour&#91;64&#93;;<br />
extern int piece&#91;64&#93;;<br />
extern int mailbox&#91;120&#93;;<br />
extern int mailbox64&#91;64&#93;;<br />
extern int init_colour&#91;64&#93;;</pre><br />
defs.h<br />
 <pre style="margin:20px; line-height:13px">/*<br />
&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; DEFS.H<br />
&nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; P Chess<br />
&nbsp;*/<br />
<br />
#define WHITE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0<br />
#define BLACK&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1<br />
#define EMPTY&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2<br />
<br />
#define ROW(x)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (x &gt;&gt; 3)</pre><br />
It currently just outputs a grid of W's.<br />
<br />
Any help much appreciated.  Ta.  :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>mr_steve</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235475.html</guid>
		</item>
		<item>
			<title>Convert Decimal to equivalent ASCII</title>
			<link>http://www.daniweb.com/forums/thread235440.html</link>
			<pubDate>Mon, 02 Nov 2009 19:05:44 GMT</pubDate>
			<description><![CDATA[I really need help to convert decimal number to equivalent ASCII. 
 
I store decimal value in x. 
 
for example int x = 255; 
 
and I want to display it also as '255' in HyperTerminal. 
 
Hope someone can help me :)]]></description>
			<content:encoded><![CDATA[<div>I really need help to convert decimal number to equivalent ASCII.<br />
<br />
I store decimal value in x.<br />
<br />
for example int x = 255;<br />
<br />
and I want to display it also as '255' in HyperTerminal.<br />
<br />
Hope someone can help me :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>aronemz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235440.html</guid>
		</item>
		<item>
			<title>Please help - how to quit a program</title>
			<link>http://www.daniweb.com/forums/thread235420.html</link>
			<pubDate>Mon, 02 Nov 2009 17:50:58 GMT</pubDate>
			<description><![CDATA[hello, i'm making program which repeatedly (through while) gets input from the user ... program should stop whenever user enters "\n" (or enter button)!  
 
thanks in advance!]]></description>
			<content:encoded><![CDATA[<div>hello, i'm making program which repeatedly (through while) gets input from the user ... program should stop whenever user enters &quot;\n&quot; (or enter button)! <br />
<br />
thanks in advance!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>timaquerra</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235420.html</guid>
		</item>
		<item>
			<title><![CDATA[How to do "narrow the range" in a guessing game?]]></title>
			<link>http://www.daniweb.com/forums/thread235388.html</link>
			<pubDate>Mon, 02 Nov 2009 15:22:44 GMT</pubDate>
			<description>I am writing a number guessing game, but it request to give hints to player when he guess wrong. And I need to narrow the range to be the hints, what should  I write to do this function?</description>
			<content:encoded><![CDATA[<div>I am writing a number guessing game, but it request to give hints to player when he guess wrong. And I need to narrow the range to be the hints, what should  I write to do this function?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Wtyy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235388.html</guid>
		</item>
		<item>
			<title>C Modulus</title>
			<link>http://www.daniweb.com/forums/thread235357.html</link>
			<pubDate>Mon, 02 Nov 2009 13:53:00 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <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> <strong>C Syntax</strong> (<a...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">float decimal = 2.345324<br />
<br />
<br />
float dec_points = decimal%1;</pre><br />
hey guys,<br />
I have a small but trivial problem... i have been trying to do the above but i keep getting a error...<br />
&quot;error C2296: '%' : illegal, left operand has type 'float'&quot;<br />
Anyone got a clue?<br />
Thanks guys!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>mitsuevo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235357.html</guid>
		</item>
		<item>
			<title>Reverse of number</title>
			<link>http://www.daniweb.com/forums/thread235260.html</link>
			<pubDate>Mon, 02 Nov 2009 06:22:09 GMT</pubDate>
			<description><![CDATA[Hi, 
 
This has been discussed ealier, but i would like to know how the loop executes 
 
1.   #include<stdio.h> 
2.  #include<conio.h> 
3.    void main() 
4.    { 
5.     int x,y,z; 
6.     scanf("%d",&x);]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
This has been discussed ealier, but i would like to know how the loop executes<br />
<br />
1.   #include&lt;stdio.h&gt;<br />
2.  #include&lt;conio.h&gt;<br />
3.    void main()<br />
4.    {<br />
5.     int x,y,z;<br />
6.     scanf(&quot;%d&quot;,&amp;x);<br />
7.     if(x&gt;0)<br />
8.     {<br />
9.       y=x/10;<br />
10       z=x%10;<br />
11.       x=y;<br />
12.      printf(&quot;%d&quot;,z);<br />
13.      }<br />
14.         printf(&quot;%d&quot;,x);<br />
15.        }<br />
<br />
Suppose I enter 321<br />
y will become 32<br />
z will become 1<br />
x will be 32<br />
<br />
It will print first  z which is 1<br />
then  it will print x which is 32<br />
<br />
But it should have been 123 ( Reverse of 321)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>seo2005</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235260.html</guid>
		</item>
		<item>
			<title><![CDATA[[Help] How to Get Linux Kernel Behavior]]></title>
			<link>http://www.daniweb.com/forums/thread235251.html</link>
			<pubDate>Mon, 02 Nov 2009 05:22:37 GMT</pubDate>
			<description>I need to print out the following values on std-out: 
-CPU Type and Model 
-Kernel Version 
-Amount of time since the system was last booted, in the form dd:hh:mm:ss 
 
This is all on Ubuntu 8.04 
 
I have looked through my Linux Kernel book but it is very vague about how I am supposed to discover...</description>
			<content:encoded><![CDATA[<div>I need to print out the following values on std-out:<br />
-CPU Type and Model<br />
-Kernel Version<br />
-Amount of time since the system was last booted, in the form dd:hh:mm:ss<br />
<br />
This is all on Ubuntu 8.04<br />
<br />
I have looked through my Linux Kernel book but it is very vague about how I am supposed to discover these values...It mentions using the Header File include/linux/sched.h and then &quot;in the source code file <span style="font-weight:bold">kernel/sched.c</span> contains a declaration of the form:<br />
<span style="font-weight:bold">struct task_struct * task[NR_TASKS] = { &amp;init_task, };</span>&quot;<br />
<br />
But there is no kernel/sched.c file that I can find to use in my program, and I am just quite lost on how to go about coding this program.<br />
<br />
If anyone could help me out, point me in the right direction or anything, it would be very appreciated.<br />
<br />
Thank you</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>jeeter19</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235251.html</guid>
		</item>
		<item>
			<title>Can embedded server be accessed by external applications?</title>
			<link>http://www.daniweb.com/forums/thread235245.html</link>
			<pubDate>Mon, 02 Nov 2009 04:35:02 GMT</pubDate>
			<description><![CDATA[I know this forum isn't for databases but I couldn't find a proper one so i post here. (my original post is at forums.mysql.com, but not much seems to be happening there) 
 
can MySQL server be started as a globally accessible server by using libmysqld? 
 
For example, can a application start the...]]></description>
			<content:encoded><![CDATA[<div>I know this forum isn't for databases but I couldn't find a proper one so i post here. (my original post is at forums.mysql.com, but not much seems to be happening there)<br />
<br />
can MySQL server be started as a globally accessible server by using libmysqld?<br />
<br />
For example, can a application start the server using 'localhost' or '127.0.0.1' and if so, can the databases be accessed using another program - say PHP? <br />
<br />
thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>nika201</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235245.html</guid>
		</item>
		<item>
			<title>Print star pattern</title>
			<link>http://www.daniweb.com/forums/thread235242.html</link>
			<pubDate>Mon, 02 Nov 2009 04:13:26 GMT</pubDate>
			<description>Hi, 
 
I would like to print star pattern in the following way - 
 
**** 
*** 
** 
* 
 
main()</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I would like to print star pattern in the following way -<br />
<br />
****<br />
***<br />
**<br />
*<br />
<br />
main()<br />
<br />
int i;<br />
<br />
clrscr();<br />
<br />
for(i=4;i&lt;=4;i++)<br />
<br />
{<br />
<br />
printf(&quot;*&quot;);<br />
<br />
getch();<br />
<br />
}<br />
<br />
It prints starts like ****<br />
<br />
I don't know how to complete the program. Can anyone please do the complete program for this so that stars are printed in the manner as given above.<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>seo2005</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235242.html</guid>
		</item>
		<item>
			<title>Storing Received message in a queue dynamically</title>
			<link>http://www.daniweb.com/forums/thread235185.html</link>
			<pubDate>Sun, 01 Nov 2009 23:25:23 GMT</pubDate>
			<description>Hey All, 
 
I am a newbie in C programming. I have written a program which has a separate function to send messages to 2 neighbours in the same network. This function is called from the main program. Also I have a thread which is created by the main function. The purpose of the thread is to listen...</description>
			<content:encoded><![CDATA[<div>Hey All,<br />
<br />
I am a newbie in C programming. I have written a program which has a separate function to send messages to 2 neighbours in the same network. This function is called from the main program. Also I have a thread which is created by the main function. The purpose of the thread is to listen for incoming messages. So irrespective of what happens in the main function, the function which is executed via the thread should keep receiving messages(whenever one is received) and should store it in a queue. Once in every machine cycle, I want to check the queue and process the received messages. <br />
<br />
Earlier I had both the receive and the send module in the main function, which eventually ended up in a deadlock situation. So to get rid of the interdependencies between the send and receive module, I thought of using the thread concept. Now I think the thread would execute the receive function independently and once in every machine cycle I can read the messages and process it through another function.<br />
<br />
My question is this. Is there a inbuilt option in C programming to store the incoming messages in a queue and later the main function can process it? I know there is something called as message queue in C programming. But my understanding with &quot;message queues&quot; is something like sharing the messages within two processes using a message header. That would have its pre-defined format to store the message I guess. I have my own format for the incoming messages (I will be receiving a structure that will have  3 arrays and a char variable). Is there a way that I can store this structure along with the ip address of the sender in a common buffer or a queue for later retrieval?? I can store it in a buffer I know. But that involves so much of coding. If there is something inbuilt and simple in C programming, that would greatly help me.. Please help.<br />
<br />
Thanks in Advance,<br />
Ani</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>anitha joe</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235185.html</guid>
		</item>
		<item>
			<title>How to split string into a structure?</title>
			<link>http://www.daniweb.com/forums/thread235182.html</link>
			<pubDate>Sun, 01 Nov 2009 23:19:44 GMT</pubDate>
			<description><![CDATA[hi, i have been unable to solve a problem related to C (i'am a newbie girl). I've googled around and maybe I have a flat learning curve :-( 
the fact is that i need to write a program that reads from a .txt file and print the output to another .html file (table) 
the input file has 6...]]></description>
			<content:encoded><![CDATA[<div>hi, i have been unable to solve a problem related to C (i'am a newbie girl). I've googled around and maybe I have a flat learning curve :-(<br />
the fact is that i need to write a program that reads from a .txt file and print the output to another .html file (table)<br />
the input file has 6 space-separated fields per line (activity_code, activity, begining_date, ending_date, days and hour of the day -Morning/Afternoo/Night) and downwards is alike.<br />
i.e. this 2 lines:<br />
ZZZ Tancat 01/01/2009 31/12/2009 SMT MN<br />
<br />
PER PerlMeeting 01/05/2009 31/05/2009 TWF N<br />
<br />
How do I split this strings and assign them to a structure in order to can handle data? Here is the code I wrote, it's very simple and hope you can help me with some advice. Thanks in advance.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;ctype.h&gt; /* to handle isspace()&nbsp; &nbsp; &nbsp; &nbsp;  <br />
#define MAXFILES 200<br />
#define MAXLEN 50<br />
<br />
typedef struct {<br />
&nbsp; &nbsp; &nbsp;  char *CODE[MAXLEN];<br />
&nbsp; &nbsp; &nbsp;  char *NAME[MAXLEN];<br />
&nbsp; &nbsp; &nbsp;  char *DATE_IN[MAXLEN];<br />
&nbsp; &nbsp; &nbsp;  char *DATE_OUT[MAXLEN];<br />
&nbsp; &nbsp; &nbsp;  char *DoW[MAXLEN];<br />
&nbsp; &nbsp; &nbsp;  char *HOUR[MAXLEN];<br />
} rec_s;<br />
int main() <br />
{<br />
&nbsp; rec_s LOG[MAXLEN];<br />
&nbsp; char c[120];&nbsp; /* declare a char array */<br />
&nbsp; char actividad[MAXLEN];<br />
&nbsp; char d;<br />
&nbsp; char words[MAXLEN];<br />
&nbsp; char delims[] = &quot; &quot;;<br />
&nbsp; <br />
&nbsp; int count=0;<br />
&nbsp; char *buffer;<br />
&nbsp; int i;<br />
&nbsp; int j;<br />
&nbsp; <br />
&nbsp; FILE *file;&nbsp; /* declare a FILE pointer&nbsp; */<br />
&nbsp; <br />
&nbsp; file = fopen(&quot;requests.txt&quot;, &quot;r&quot;); <br />
&nbsp; <br />
&nbsp;<br />
&nbsp; /* open a text file for reading */<br />
<br />
&nbsp; if(file==NULL) {<br />
&nbsp; &nbsp; printf(&quot;Error: can't open file.\n&quot;);<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; return 1;<br />
&nbsp; }<br />
&nbsp; else {<br />
&nbsp; &nbsp; printf(&quot;File opened!:\n\n&quot;);<br />
&nbsp; &nbsp; <br />
&nbsp;  <br />
&nbsp;  <br />
&nbsp; &nbsp; while(!feof(file)) {<br />
&nbsp; &nbsp; d = fgetc(file);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( ! isspace (d) ) /* how do i use this function to assign every line string (6) to its appropriate field? */<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; fgets(c, 120, file); <br />
&nbsp; &nbsp; &nbsp; &nbsp; puts(c);&nbsp; &nbsp; &nbsp; &nbsp; /* this shows in screen the input file */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* I don't know how to add every string to the structure */<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp;  printf(&quot;\n\nNow closing file...\n&quot;);<br />
&nbsp; &nbsp; fclose(file);<br />
&nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp;  <br />
&nbsp; }&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>auracabarcas</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235182.html</guid>
		</item>
		<item>
			<title>Rot 13 Help</title>
			<link>http://www.daniweb.com/forums/thread235181.html</link>
			<pubDate>Sun, 01 Nov 2009 23:14:30 GMT</pubDate>
			<description><![CDATA[I made a program that finds the ROT 13, but theres a little thing thats messing it up for me. Its supposed to find the ROT 13 of each character but when i run it, it gives me some funky character in return 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px">...]]></description>
			<content:encoded><![CDATA[<div>I made a program that finds the ROT 13, but theres a little thing thats messing it up for me. Its supposed to find the ROT 13 of each character but when i run it, it gives me some funky character in return<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
int rot13(int c)<br />
{<br />
&nbsp; if (c &gt;= 'A' &amp;&amp; c &lt; 'N')<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; return c + 13;<br />
&nbsp; &nbsp; }<br />
&nbsp; if (c &gt;= 'N' &amp;&amp; c &lt;= 'Z')<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; return c - 13;<br />
&nbsp; &nbsp; }<br />
&nbsp; if (c &gt;= 'a' &amp;&amp; c &lt; 'n')<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; return c + 13;<br />
&nbsp; &nbsp; }<br />
&nbsp; if (c &gt;= 'n' &amp;&amp; c &lt;= 'z')<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; return c - 13;<br />
&nbsp; &nbsp; }<br />
&nbsp;<br />
}<br />
int main(void)<br />
{<br />
&nbsp; int c; <br />
&nbsp; printf(&quot;Enter a character: &quot;);<br />
&nbsp;<br />
&nbsp; while((c == getchar())!= EOF)<br />
&nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; char a = rot13(c);<br />
&nbsp; &nbsp; &nbsp; printf(&quot;%c&quot;, a);&nbsp;  <br />
&nbsp; &nbsp; &nbsp; c++;<br />
&nbsp; &nbsp; }<br />
&nbsp; return 0;<br />
}</pre>Can some one help me out please</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>yasaswyg</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235181.html</guid>
		</item>
		<item>
			<title>debugger help</title>
			<link>http://www.daniweb.com/forums/thread235177.html</link>
			<pubDate>Sun, 01 Nov 2009 22:27:38 GMT</pubDate>
			<description><![CDATA[hi everyone, i have a program code here, its working, but as soon as im trying to add results debugger breaks after adding score, can anyone help me to fix this problem. Program is working ok. heres the code: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>hi everyone, i have a program code here, its working, but as soon as im trying to add results debugger breaks after adding score, can anyone help me to fix this problem. Program is working ok. heres the code:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
void addTeam(char[50], int);<br />
void calculateResult(int, int, int, int);<br />
<br />
char newTeam[50];<br />
int menuChoice = 0;<br />
int numOfTeams = 0;<br />
int team1, team2, team1Score, team2Score;<br />
<br />
typedef struct<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char name[50];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int points, goalsFor, goalsAgainst, played, won, lost, drawn;<br />
} team;<br />
<br />
team teams[12];<br />
<br />
void sortTable(team[]);<br />
&nbsp; <br />
int main(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; while (menuChoice != 4)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Football League\n\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;1. Add team\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;2. Display league table\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;3. Add result\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;4. Quit\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, &amp;menuChoice);&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (menuChoice == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (numOfTeams == 11)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Error: Maximum amount of teams has been entered&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Add new team\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fgets(newTeam, sizeof(newTeam), stdin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newTeam[strlen(newTeam)-1] = '\0';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fgets(newTeam, sizeof(newTeam), stdin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newTeam[strlen(newTeam)-1] = '\0';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addTeam(newTeam, numOfTeams);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numOfTeams++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nNew team added\n&quot;);<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (menuChoice == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\t\tP\tW\tD\tL\tF\tA\tT\n\n\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for ( i = 0; i &lt; 12; i++)<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%s\t\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n&quot;, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[i].name, teams[i].played, teams[i].won,teams[i].drawn, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[i].lost, teams[i].goalsFor, teams[i].goalsAgainst, <br />
teams[i].points);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (menuChoice == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Enter first team playing:\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, &amp;team1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Enter second team playing:\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, &amp;team2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Enter first teams score:\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, &amp;team1Score);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Enter second teams score:\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, &amp;team2Score);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; calculateResult(team1, team2, team1Score, team2Score);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
return 0;<br />
}<br />
&nbsp;<br />
void addTeam(char *teamName, int i)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcpy(teams[i].name, teamName);<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[i].points = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[i].goalsFor = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[i].goalsAgainst = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[i].played = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[i].won = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[i].lost = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[i].drawn = 0;<br />
}<br />
<br />
void calculateResult(int t1, int t2, int t1R, int t2R)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (t1R &gt; t2R)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[(t1-1)].points+=3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[(t1-1)].won++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[(t2-1)].lost++;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (t2R &gt; t1R)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[(t2-1)].points+=3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[(t2-1)].won++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[(t1-1)].lost++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[(t2-1)].points++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[(t1-1)].points++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[(t1-1)].drawn++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams[(t2-1)].drawn++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[(t1-1)].goalsFor+=t1R;<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[(t2-1)].goalsFor+=t2R;<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[(t1-1)].goalsAgainst+=t2R;<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[(t2-1)].goalsAgainst+=t1R;<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[(t1-1)].played++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; teams[(t2-1)].played++;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; sortTable(teams);<br />
}<br />
<br />
void sortTable(team teams1[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; team temp[1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i, j;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for ( i = 0; i &lt; 12; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for ( j = 11; j &gt;=0; j--)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (teams1[j].points &gt; teams1[(j-1)].points)<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; temp[1] = teams1[(j-1)];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams1[(j-1)] = teams1[j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; teams1[j] = temp[1];<br />
&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; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre>thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>dinamit875</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235177.html</guid>
		</item>
		<item>
			<title>c language programe HELP ME PLEASE</title>
			<link>http://www.daniweb.com/forums/thread235157.html</link>
			<pubDate>Sun, 01 Nov 2009 20:03:49 GMT</pubDate>
			<description>HI can anyone help me to write this programe in c  
Q ; WRITE A PROGRAM TO DETERMINE AND PRINT THE SUM OF THE FOLLOWING HARMONIC SERIES FOR A GIVEN VALUE OF N; 
1+1/2+1/3+14+....................1/N 
THE VALUE SHOULD BE GIVEN INTERACTIVELY THROUGH THE TERMINAL</description>
			<content:encoded><![CDATA[<div>HI can anyone help me to write this programe in c <br />
Q ; WRITE A PROGRAM TO DETERMINE AND PRINT THE SUM OF THE FOLLOWING HARMONIC SERIES FOR A GIVEN VALUE OF N;<br />
1+1/2+1/3+14+....................1/N<br />
THE VALUE SHOULD BE GIVEN INTERACTIVELY THROUGH THE TERMINAL</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>ch.ankit87</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235157.html</guid>
		</item>
		<item>
			<title>Code Snippet need help with a simple C program</title>
			<link>http://www.daniweb.com/code/snippet235133.html</link>
			<pubDate>Sun, 01 Nov 2009 17:28:23 GMT</pubDate>
			<description><![CDATA[The programming assignment is to read a text file, extract the words from it, and save them in a 2D array that contains the word and the number of occurrences of that word. For example, if a text file contains the words "first" "second" "third" "second", the array should contain - first 1   second...]]></description>
			<content:encoded><![CDATA[<div>The programming assignment is to read a text file, extract the words from it, and save them in a 2D array that contains the word and the number of occurrences of that word. For example, if a text file contains the words &quot;first&quot; &quot;second&quot; &quot;third&quot; &quot;second&quot;, the array should contain - first 1   second 2   third 1.  The code I have posted creates a 2D array that contains  first 1   second 1   third 1 second 1,  so the count for second does not increment and word is printed again.   I am saving each new word in the hist array and the number in the 31st element of the array.  Then, if the word does exist I want to increment that number.  doesWordExist  is function that returns FALSE if the word does not exist and TRUE if the word exists. The function has been tested and works correctly.  I am also initializing the arrays.  Pointers aren't allowed.<br />
Please help me with this! I have been working on this for a long time and would appreciate your help very much.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>hangman1060</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235133.html</guid>
		</item>
		<item>
			<title>List at least two possible ways for linking against the math library.</title>
			<link>http://www.daniweb.com/forums/thread235115.html</link>
			<pubDate>Sun, 01 Nov 2009 15:44:25 GMT</pubDate>
			<description>List at least two possible ways for linking against the math library.</description>
			<content:encoded><![CDATA[<div>List at least two possible ways for linking against the math library.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>rudz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235115.html</guid>
		</item>
		<item>
			<title>Code Snippet Linked list coding for CPU scheduling algorithms help with pointers</title>
			<link>http://www.daniweb.com/code/snippet235109.html</link>
			<pubDate>Sun, 01 Nov 2009 14:56:14 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <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> <strong>C Syntax</strong> (<a...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">struct PCB* handleProcessArrival_PP(struct PCB *processhead,struct PCB *processtail,struct PCB *currProcess,struct PCB *newProcess,int currTime){<br />
&nbsp; &nbsp; if(currProcess==NULL){<br />
&nbsp; &nbsp; &nbsp;  newProcess-&gt;executionStartTime = currTime;<br />
&nbsp; &nbsp; &nbsp;  newProcess-&gt;executionEndTime = currTime+newProcess-&gt;totalBurstTime;<br />
&nbsp; &nbsp; &nbsp;  newProcess-&gt;remainingBurstTime = newProcess-&gt;totalBurstTime;<br />
&nbsp; &nbsp; &nbsp;  if(newProcess-&gt;processID==processhead-&gt;processID){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; processhead= newProcess-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;processhead in case 1 %d \n&quot;,processhead-&gt;processID);<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  currProcess=newProcess; <br />
&nbsp; &nbsp; &nbsp;  printf(&quot;***current process = new process%d \n&quot;,currProcess-&gt;processID);<br />
&nbsp; &nbsp; &nbsp;  contents(processhead);<br />
&nbsp; &nbsp; &nbsp;  return currProcess;<br />
&nbsp; &nbsp; &nbsp;  //return processhead;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; if (currProcess-&gt;processID !=0){<br />
&nbsp; &nbsp; &nbsp;  contents(processhead);<br />
&nbsp; &nbsp; &nbsp;  if(currProcess-&gt;processPriority&gt;newProcess-&gt;processPriority){//new process higher priority<br />
&nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;***new process in handle %d \n&quot;,newProcess-&gt;processID);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  currProcess-&gt;executionStartTime = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  currProcess-&gt;executionEndTime = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  currProcess-&gt;remainingBurstTime = currProcess-&gt;totalBurstTime-(currProcess-&gt;executionStartTime-currTime);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  processtail-&gt;next=currProcess;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  processtail=currProcess;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  newProcess-&gt;executionStartTime=currTime;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  newProcess-&gt;executionEndTime = currTime+newProcess-&gt;totalBurstTime;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  newProcess-&gt;remainingBurstTime = newProcess-&gt;totalBurstTime;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  currProcess=newProcess;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;current process replaced with%d \n&quot;,newProcess-&gt;processID);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;processhead in case 2 %d \n&quot;,processhead-&gt;processID);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  return currProcess;<br />
&nbsp; &nbsp; &nbsp;  } <br />
&nbsp; &nbsp; &nbsp;  if(currProcess-&gt;processPriority&lt;newProcess-&gt;processPriority){//new process lower priority<br />
&nbsp; &nbsp; &nbsp; &nbsp;  contents(processhead);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  newProcess-&gt;executionStartTime = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  newProcess-&gt;executionEndTime = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  newProcess-&gt;remainingBurstTime = newProcess-&gt;totalBurstTime;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  processtail-&gt;next=newProcess;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  processtail=newProcess;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;new process in handle %d \n&quot;,newProcess-&gt;processID);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;current process continues%d \n&quot;,currProcess-&gt;processID);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;processhead in case 3 %d \n&quot;,processhead-&gt;processID);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  return currProcess;<br />
&nbsp; &nbsp; &nbsp;  }<br />
<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; /*&nbsp;  printf(&quot;process id = %d \n&quot;,currProcess.processID);<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;arrival time = %ld \n&quot;,currProcess.arrivalTimeStamp);<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;total burst time = %ld \n&quot;,currProcess.totalBurstTime);<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;start time = %ld \n&quot;,currProcess.executionStartTime);<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;end time = %ld \n&quot;,currProcess.executionEndTime);<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;remaining burst time = %ld \n&quot;,currProcess.remainingBurstTime);<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;priority = %d \n&quot;,currProcess.processPriority);<br />
*/<br />
}<br />
struct PCB* handleProcessCompletion_PP(struct PCB *processhead,int currTime){<br />
&nbsp; &nbsp; &nbsp;  if (processhead==NULL){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return NULL;<br />
&nbsp; &nbsp; &nbsp;  }else{<br />
&nbsp; &nbsp; &nbsp;  contents(processhead);<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;in else processhead is %d \n&quot;,processhead-&gt;processID);<br />
&nbsp; &nbsp; &nbsp;  struct PCB *processtemp;<br />
&nbsp; &nbsp; &nbsp;  processtemp=processhead;<br />
&nbsp; &nbsp; &nbsp;  int len=length(processhead);<br />
&nbsp; &nbsp; &nbsp;  struct PCB *procArray[len];<br />
&nbsp; &nbsp; &nbsp;  int i=0;<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;test&quot;);<br />
&nbsp; &nbsp; &nbsp;  while(i&lt;len){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  procArray[i] = processtemp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;process put in array %d&quot;,procArray[i]-&gt;processID);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  processtemp=processtemp-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  i++;<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  int min =0;<br />
&nbsp; &nbsp; &nbsp;  for(i=0;i&lt;len;i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(procArray[min]-&gt;processPriority &gt; procArray[i]-&gt;processPriority){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  min = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;high priority process %d&quot;,procArray[min]-&gt;processID);<br />
&nbsp; &nbsp; &nbsp;  procArray[min]-&gt;executionStartTime = currTime;<br />
&nbsp; &nbsp; &nbsp;  procArray[min]-&gt;executionEndTime = currTime+procArray[min]-&gt;remainingBurstTime;<br />
&nbsp; &nbsp; &nbsp;  procArray[min-1]-&gt;next=procArray[min+1];<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;process to run next is %d&quot;,procArray[min]-&gt;processID);<br />
&nbsp; &nbsp; &nbsp;  return procArray[min];<br />
&nbsp; &nbsp; &nbsp;  //return processhead;<br />
&nbsp; &nbsp; &nbsp;  }<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>ayeswarya</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235109.html</guid>
		</item>
		<item>
			<title>C program for binary</title>
			<link>http://www.daniweb.com/forums/thread234991.html</link>
			<pubDate>Sun, 01 Nov 2009 00:35:51 GMT</pubDate>
			<description><![CDATA[Hi i have a binary function search program where the user enters a index of numbers, then enters the number he wants to find. However my program wont compile and says the subscripted value is neither an array or pointer. Help me out please. Here is what ive got: 
  <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hi i have a binary function search program where the user enters a index of numbers, then enters the number he wants to find. However my program wont compile and says the subscripted value is neither an array or pointer. Help me out please. Here is what ive got:<br />
 <pre style="margin:20px; line-height:13px"># include &lt;stdio.h&gt;<br />
# include &quot;genlib.h&quot;<br />
# include &quot;simpio.h&quot;<br />
# include &quot;stdlib.h&quot;<br />
# include &quot;strlib.h&quot;<br />
# define c 33000<br />
<br />
<br />
int bisearch(int nArray,int arraynum, int maxarray)<br />
{<br />
&nbsp; &nbsp;  int ran,track,sort,sort2,num1,save,count,result;<br />
&nbsp; &nbsp;  count=0;<br />
&nbsp; &nbsp;  sort=arraynum;<br />
&nbsp; &nbsp;  sort2=sort;<br />
&nbsp; &nbsp;  while(num1!=0)<br />
&nbsp; &nbsp;  printf(&quot;whats the next integer&quot;);<br />
&nbsp; &nbsp;  num1=GetInteger();<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp;  nArray[arraynum]=GetInteger();<br />
&nbsp; &nbsp;  while(sort!=0)<br />
&nbsp; &nbsp;  if(nArray[arraynum]&lt;nArray[arraynum-1])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp;  num1=nArray[arraynum-1];<br />
&nbsp; &nbsp;  nArray[arraynum-1]=nArray[arraynum];<br />
&nbsp; &nbsp;  nArray[arraynum]=num1;<br />
&nbsp; &nbsp;  sort=sort-1;<br />
&nbsp; &nbsp;  arraynum=arraynum-1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
else<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp;  sort=sort-1;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  arraynum=sort2;<br />
&nbsp; &nbsp;  sort2=sort2+1;<br />
&nbsp; &nbsp;  sort=sort2;<br />
&nbsp; &nbsp;  printf(&quot;%d&quot;,nArray[arraynum]);<br />
&nbsp; &nbsp;  arraynum=arraynum+1;<br />
&nbsp; &nbsp;  count=count+1;<br />
&nbsp; &nbsp;  }<br />
&nbsp; &nbsp;  printf(&quot;what is your number&quot;);<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp;  while(count!=0)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp;  if(result==nArray[arraynum])<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp;  printf(&quot;the number is in index %d&quot;,arraynum);<br />
&nbsp; &nbsp;  break;<br />
&nbsp; &nbsp;  }<br />
else<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp;  arraynum=arraynum-1;<br />
&nbsp; &nbsp;  count=count-1;<br />
&nbsp; &nbsp;  }<br />
}<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp;  <br />
main()<br />
{<br />
&nbsp; &nbsp; &nbsp; int maxarray,arraynum,bin;<br />
&nbsp; &nbsp; &nbsp; printf(&quot;whats is are the numbers you want for your index. Hit 0 to end.&quot;);<br />
&nbsp; &nbsp; &nbsp; int nArray[c];<br />
&nbsp; &nbsp; &nbsp; nArray[arraynum]=0;<br />
&nbsp; &nbsp; &nbsp; arraynum=0;<br />
&nbsp; &nbsp; &nbsp; bin=bisearch(arraynum,maxarray,nArray[arraynum]);<br />
&nbsp; &nbsp; &nbsp; getchar();<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>wangatang126</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234991.html</guid>
		</item>
		<item>
			<title>how can I save process histroy</title>
			<link>http://www.daniweb.com/forums/thread234963.html</link>
			<pubDate>Sat, 31 Oct 2009 19:58:22 GMT</pubDate>
			<description><![CDATA[I am working in Linux 2.14 kernel, and I have an assignment. 
I want to save for every process , the files it opens and closes , and the time he did that. 
for example : 
for process aaa : 
opening "file1" 
opening "file2" 
closing "file1" 
opening "file3" 
closing "file3" 
closing "file2"]]></description>
			<content:encoded><![CDATA[<div>I am working in Linux 2.14 kernel, and I have an assignment.<br />
I want to save for every process , the files it opens and closes , and the time he did that.<br />
for example :<br />
for process aaa :<br />
opening &quot;file1&quot;<br />
opening &quot;file2&quot;<br />
closing &quot;file1&quot;<br />
opening &quot;file3&quot;<br />
closing &quot;file3&quot;<br />
closing &quot;file2&quot;<br />
I could save a linked-list , the question is where to save that , and how to update it.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>ham130489</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234963.html</guid>
		</item>
		<item>
			<title>count number of comparisons</title>
			<link>http://www.daniweb.com/forums/thread234946.html</link>
			<pubDate>Sat, 31 Oct 2009 17:23:52 GMT</pubDate>
			<description><![CDATA[Hello guys! 
 
I'm new to C language and I need help to write a program which searches specific word in text file using Binary Search and count the number of comparisons!!! 
 
My text file consist of following data: 
apple 
book 
clock 
dog 
elephant]]></description>
			<content:encoded><![CDATA[<div>Hello guys!<br />
<br />
I'm new to C language and I need help to write a program which searches specific word in text file using Binary Search and count the number of comparisons!!!<br />
<br />
My text file consist of following data:<br />
apple<br />
book<br />
clock<br />
dog<br />
elephant<br />
fat<br />
hello<br />
key<br />
lucky<br />
moon<br />
olive<br />
paper<br />
<br />
So far, i made program which searches word and gives the location (index) of this word in file. However, that's not what I need, I need to count the number of comparisons!<br />
<br />
I'm currently here:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
#define MAXSIZE 20<br />
#define MAXLEN&nbsp; 20<br />
<br />
<br />
int seq_Search(char array[][MAXSIZE], int count, char *key);&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
int main(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char target[MAXLEN];<br />
&nbsp; &nbsp; &nbsp; &nbsp; char words[MAXLEN][MAXSIZE];<br />
&nbsp; &nbsp; &nbsp; &nbsp; FILE *file;&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 />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if((file = fopen(&quot;a3.txt&quot;, &quot;r&quot;)) == NULL){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Cannot open file\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; } <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(!feof(file)){&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fscanf(file, &quot;%s&quot;, words[i]);<br />
&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; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n\nInput: &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s&quot;, target); <br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int location = seq_Search(words, 15, target);<br />
&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; if((strcasecmp(words[location], target)) == 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nWord %s found&quot;, target);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Location: %d\n&quot;, location);<br />
&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; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nWord %s cannot be found&nbsp;  &quot;, target);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Location: %d\n&quot;, location);<br />
&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; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
int seq_Search(char array[][MAXSIZE], int end, char *key)<br />
<br />
{&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int mid;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int first = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int last = end;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; while(first &lt;= last){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mid = (first + last) / 2;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(strcasecmp(array[mid], key) &lt; 0)<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; first = mid + 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(strcasecmp(array[mid], key) &gt; 0)<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; last = mid - 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return mid; <br />
}</pre><br />
Thank you in advance! <br />
<br />
PS: sorry for my poor english!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>timaquerra</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234946.html</guid>
		</item>
		<item>
			<title>kernel modules</title>
			<link>http://www.daniweb.com/forums/thread234942.html</link>
			<pubDate>Sat, 31 Oct 2009 16:53:11 GMT</pubDate>
			<description>plz plz urgent im a beginner in unix. 
can someone reply asap . 
what are kernel modules?what role do they plan in building and runnig a kernel?what happens if the linux kernel did not support modules?</description>
			<content:encoded><![CDATA[<div>plz plz urgent im a beginner in unix.<br />
can someone reply asap .<br />
what are kernel modules?what role do they plan in building and runnig a kernel?what happens if the linux kernel did not support modules?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>rudz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234942.html</guid>
		</item>
		<item>
			<title><![CDATA[How to get the "Program Counter"]]></title>
			<link>http://www.daniweb.com/forums/thread234884.html</link>
			<pubDate>Sat, 31 Oct 2009 11:10:56 GMT</pubDate>
			<description><![CDATA[Hey *.*, 
 
is it possible to get the current "Program Counter" of another running program? If it is, how can it be done? 
 
Thanks for any hint! 
svkers]]></description>
			<content:encoded><![CDATA[<div>Hey *.*,<br />
<br />
is it possible to get the current &quot;Program Counter&quot; of another running program? If it is, how can it be done?<br />
<br />
Thanks for any hint!<br />
svkers</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>svkers</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234884.html</guid>
		</item>
		<item>
			<title>UART problem!</title>
			<link>http://www.daniweb.com/forums/thread234881.html</link>
			<pubDate>Sat, 31 Oct 2009 10:55:26 GMT</pubDate>
			<description><![CDATA[Hello I'm doing a program about UART in Borland C. And I have a few questions. This is the code: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help...]]></description>
			<content:encoded><![CDATA[<div>Hello I'm doing a program about UART in Borland C. And I have a few questions. This is the code:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream.h&gt;<br />
#include &lt;dos.h&gt;<br />
#include &lt;conio.h&gt;<br />
#include &lt;stdio.h&gt;<br />
<br />
#define COM1 0x3F8<br />
<br />
int main(void)<br />
{<br />
&nbsp; clrscr();<br />
<br />
//&nbsp; outportb( COM1 + 1, 0 );<br />
&nbsp; outportb( COM1 + 3, 0x83);<br />
&nbsp; outportb( COM1, 0x0C);<br />
&nbsp; outportb( COM1 + 1, 0x00);<br />
&nbsp; outportb( COM1 + 3, 0x03);<br />
<br />
&nbsp; char ans;<br />
&nbsp; char readValue;<br />
<br />
&nbsp; do<br />
&nbsp; {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; readValue = inportb( COM1 + 5 );<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( readValue &amp; 0x80 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;ERROR!&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( readValue &amp; 1 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  readValue = inportb( COM1 );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;%c&quot;, readValue);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( kbhit() )<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ans = getch();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  outportb( COM1, ans );<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; } while ( ans != 27 );<br />
<br />
<br />
&nbsp; return 0;<br />
<br />
}</pre>The program reads char data from the COM1 port, and finds if there's any errors. <br />
My question is how to simplify this program, or write it in different way. I need to present two different codes and I don't have idea for the second one.<br />
Thanks!!!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>didi00</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234881.html</guid>
		</item>
		<item>
			<title><![CDATA[HELP! The "if" function doesn't work!!!]]></title>
			<link>http://www.daniweb.com/forums/thread234832.html</link>
			<pubDate>Sat, 31 Oct 2009 06:04:38 GMT</pubDate>
			<description><![CDATA[I am writing a guessing game, player could only enter number ten times, after that, a "End" message should print. 
 
the random name =ran1 
your enter number = a 
count the enter times = b 
 
I wrote : 
 
if ( ran1 != a) 
{]]></description>
			<content:encoded><![CDATA[<div>I am writing a guessing game, player could only enter number ten times, after that, a &quot;End&quot; message should print.<br />
<br />
the random name =ran1<br />
your enter number = a<br />
count the enter times = b<br />
<br />
I wrote :<br />
<br />
if ( ran1 != a)<br />
{<br />
   b++;<br />
}<br />
<br />
printf(&quot;the count number: %d&quot;, b);<br />
printf(&quot;\nthat's the end.&quot;);<br />
<br />
but it doesn't work, the count number is still zero!!!!<br />
<br />
<br />
however, I wrote :<br />
<br />
if ( ran1 == a)<br />
{<br />
   b++;<br />
}<br />
printf(&quot;the count number: %d&quot;, b);<br />
printf(&quot;\nthat's the end.&quot;);<br />
<br />
it works, the count number is can change!!!!!<br />
<br />
<br />
what's the problem?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Wtyy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234832.html</guid>
		</item>
		<item>
			<title>Calulator</title>
			<link>http://www.daniweb.com/forums/thread234793.html</link>
			<pubDate>Sat, 31 Oct 2009 00:46:49 GMT</pubDate>
			<description>I am trying to code a math tutor program that will have random numbers generated.  Any suggestions would be greatful. 
 
Output suppose to be: 
I am having problems with this code. I keep switching it around and can not seem to get it right. This is what output suppose to be: 
 
Menu of Operations...</description>
			<content:encoded><![CDATA[<div>I am trying to code a math tutor program that will have random numbers generated.  Any suggestions would be greatful.<br />
<br />
Output suppose to be:<br />
I am having problems with this code. I keep switching it around and can not seem to get it right. This is what output suppose to be:<br />
<br />
Menu of Operations<br />
1. Addition<br />
2. Subtraction<br />
3. Multiplication<br />
4. Quit.<br />
<br />
Enter the number of the operation to try (1-4)? 2<br />
<br />
What is 6 - 8 ? 2<br />
No, the correct answer is: -2<br />
<br />
<br />
Menu of Operations<br />
1. Addition<br />
2. Subtraction<br />
3. Multiplication<br />
4. Quit.<br />
<br />
Enter the number of the operation to try (1-4)? 3<br />
What is 3 x 4 ? 12<br />
Yes, that is correct. Good job!<br />
Menu of Operations<br />
1. Addition<br />
2. Subtraction<br />
3. Multiplication<br />
4. Quit.<br />
<br />
Enter the number of the operation to try (1-4)? 6<br />
(BEEP) Input value is out of range.<br />
Enter the number of the operation to try (1-4)? 4<br />
Program Complete<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
<br />
#define SENT 4 //&quot;Quit&quot; menu choice<br />
<br />
<br />
/*&nbsp; Function Prototypes */<br />
<br />
<br />
&nbsp; &nbsp; void DisplayMenu (void);<br />
&nbsp; &nbsp; void GetMenuChoice (void);<br />
&nbsp; &nbsp; void Gen2Rand (int*r1, int*r2);<br />
&nbsp; &nbsp; void DrillOneProb (int*c, int*r1, int*r2);<br />
<br />
<br />
<br />
<br />
<br />
/*============Mainline Procedures===============*/<br />
<br />
int main (void);<br />
<br />
&nbsp; &nbsp; int&nbsp; &nbsp; &nbsp;  c;&nbsp;  //Menu Choice (1-4)<br />
&nbsp; &nbsp; int&nbsp;  r1,&nbsp; //First Random Integer:&nbsp; 2-12 inclusive<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r2;&nbsp; //Second Randon Integer:&nbsp; 2-12 inclusive<br />
<br />
<br />
<br />
<br />
/*===========CHILD FUNCTIONS===============*/<br />
<br />
/*&nbsp; Display Title and Menu */<br />
<br />
void DisplayMenu (void)<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;MENU OF OPERATIONS\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;1. Addition.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;2. Subtraction.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;3. Multiplication.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;4. Quit.\n\n&quot;);<br />
<br />
<br />
}<br />
<br />
/* Get Menu Choice */<br />
<br />
void GetMenuChoice (void)<br />
<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; int c;<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf (&quot;Enter the number of the operation to try (1-4):\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf (&quot;%d&quot;, &amp;c);<br />
&nbsp; &nbsp; &nbsp; &nbsp; while<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (c&lt;1 || c&gt;SENT)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\aInput value is out of range.\n&quot;);<br />
<br />
<br />
&nbsp; &nbsp; }<br />
<br />
/* Generate and return 2 integers between 2-12 inclusive */<br />
<br />
void Gen2Rand (int *r1p, int *r2p)<br />
<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; int c;<br />
&nbsp; &nbsp; &nbsp; &nbsp; c=0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (c&gt;=1 &amp;&amp; c&lt;SENT)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int r1; //First random number<br />
&nbsp; &nbsp; &nbsp; &nbsp; int r2; //Second random number<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; r1 = 2 + rand() %11;<br />
&nbsp; &nbsp; &nbsp; &nbsp; r2 = 2 + rand() %11;<br />
<br />
&nbsp; &nbsp; &nbsp;  *r1p = r1;<br />
&nbsp; &nbsp; &nbsp;  *r2p = r2;<br />
<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;Program complete\n&quot;);<br />
<br />
&nbsp; &nbsp; }<br />
<br />
/* Display two random numbers and ask user what the answer would be after the chosen operation*/<br />
<br />
void DrillOneProb (int*c, int*r1, int*r2)<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int CorAns, //Correct Answer<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Reply;&nbsp; // Users Reply<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nWhat is %d&quot;,*r1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, r1);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *r1=2 + rand () % 11;<br />
<br />
<br />
<br />
&nbsp; &nbsp; switch (c)<br />
<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; case '1':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;+&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  CorAns = *r1 + *r2;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; case '2':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;-&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CorAns = r1 - r2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; case '3':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;x&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CorAns = r1 * r2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
<br />
}<br />
<br />
&nbsp; &nbsp; printf(&quot;%d ?&nbsp; %d\n&quot;, r2, Reply);<br />
<br />
&nbsp;  if<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Reply == CorAns<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;Yes, that is correct. Good Job!&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; printf(&quot;No, the correct answer is: %d&quot;, CorAns);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
return (0);<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>katbury</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234793.html</guid>
		</item>
		<item>
			<title>C program to remove duplicates</title>
			<link>http://www.daniweb.com/forums/thread234755.html</link>
			<pubDate>Fri, 30 Oct 2009 19:22:09 GMT</pubDate>
			<description><![CDATA[Hi, this  C program is to remove duplicates. HOwever it doesnt always print out a result and when it does it screws it up sometimes. 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hi, this  C program is to remove duplicates. HOwever it doesnt always print out a result and when it does it screws it up sometimes.<br />
 <pre style="margin:20px; line-height:13px"># include &lt;stdio.h&gt;<br />
# include &quot;simpio.h&quot;<br />
# include &quot;genlib.h&quot;<br />
<br />
main()<br />
{<br />
&nbsp; &nbsp; &nbsp; int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,word;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; word=getchar();<br />
&nbsp; &nbsp; &nbsp; a='a';<br />
&nbsp; &nbsp; &nbsp; b='b';<br />
&nbsp; &nbsp; &nbsp; c='c';<br />
&nbsp; &nbsp; &nbsp; d='d';<br />
&nbsp; &nbsp; &nbsp; e='e';<br />
&nbsp; &nbsp; &nbsp; f='f';<br />
&nbsp; &nbsp; &nbsp; g='g';<br />
&nbsp; &nbsp; &nbsp; h='h';<br />
&nbsp; &nbsp; &nbsp; i='i';<br />
&nbsp; &nbsp; &nbsp; j='j';<br />
&nbsp; &nbsp; &nbsp; k='k';<br />
&nbsp; &nbsp; &nbsp; l='l';<br />
&nbsp; &nbsp; &nbsp; m='m';<br />
&nbsp; &nbsp; &nbsp; n='n';<br />
&nbsp; &nbsp; &nbsp; o='o';<br />
&nbsp; &nbsp; &nbsp; p='p';<br />
&nbsp; &nbsp; &nbsp; q='q';<br />
&nbsp; &nbsp; &nbsp; r='r';<br />
&nbsp; &nbsp; &nbsp; s='s';<br />
&nbsp; &nbsp; &nbsp; t='t';<br />
&nbsp; &nbsp; &nbsp; u='u';<br />
&nbsp; &nbsp; &nbsp; v='v';<br />
&nbsp; &nbsp; &nbsp; w='w';<br />
&nbsp; &nbsp; &nbsp; x='x';<br />
&nbsp; &nbsp; &nbsp; y='y';<br />
&nbsp; &nbsp; &nbsp; z='z';<br />
&nbsp; &nbsp; &nbsp; while((word=getchar())!=EOF)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; if(word==a)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;a&quot;);<br />
&nbsp; &nbsp; &nbsp; a=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==b)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;b&quot;);<br />
&nbsp; &nbsp; &nbsp; b=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==c)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;c&quot;);<br />
&nbsp; &nbsp; &nbsp; c=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==d)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;d&quot;);<br />
&nbsp; &nbsp; &nbsp; d=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==e)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;e&quot;);<br />
&nbsp; &nbsp; &nbsp; e=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==f)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;f&quot;);<br />
&nbsp; &nbsp; &nbsp; f=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==g)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;g&quot;);<br />
&nbsp; &nbsp; &nbsp; g=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==h)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;h&quot;);<br />
&nbsp; &nbsp; &nbsp; h=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==i)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;i&quot;);<br />
&nbsp; &nbsp; &nbsp; i=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==j)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;j&quot;);<br />
&nbsp; &nbsp; &nbsp; j=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==k)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;k&quot;);<br />
&nbsp; &nbsp; &nbsp; k=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==l)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;l&quot;);<br />
&nbsp; &nbsp; &nbsp; l=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==m)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;m&quot;);<br />
&nbsp; &nbsp; &nbsp; m=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==n)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;n&quot;);<br />
&nbsp; &nbsp; &nbsp; n=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==o)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;o&quot;);<br />
&nbsp; &nbsp; &nbsp; o=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==p)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;p&quot;);<br />
&nbsp; &nbsp; &nbsp; p=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==q)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;q&quot;);<br />
&nbsp; &nbsp; &nbsp; q=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==r)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;r&quot;);<br />
&nbsp; &nbsp; &nbsp; r=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==s)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;s&quot;);<br />
&nbsp; &nbsp; &nbsp; s=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==t)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;t&quot;);<br />
&nbsp; &nbsp; &nbsp; t=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==u)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;u&quot;);<br />
&nbsp; &nbsp; &nbsp; u=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==v)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;v&quot;);<br />
&nbsp; &nbsp; &nbsp; v=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==w)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;w&quot;);<br />
&nbsp; &nbsp; &nbsp; w=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==x)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;x&quot;);<br />
&nbsp; &nbsp; &nbsp; x=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==y)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;y&quot;);<br />
&nbsp; &nbsp; &nbsp; y=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
else<br />
&nbsp; &nbsp; &nbsp; if(word==z)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;z&quot;);<br />
&nbsp; &nbsp; &nbsp; z=1234;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; getchar();<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>gandolf III</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234755.html</guid>
		</item>
		<item>
			<title>File modification time as an int</title>
			<link>http://www.daniweb.com/forums/thread234746.html</link>
			<pubDate>Fri, 30 Oct 2009 18:20:57 GMT</pubDate>
			<description><![CDATA[How can I return the file modification time as an int (UNIX epoch)? 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>How can I return the file modification time as an int (UNIX epoch)?<br />
 <pre style="margin:20px; line-height:13px">#include &lt;time.h&gt;<br />
#include &lt;sys/stat.h&gt;<br />
<br />
int *FILEMOD(char *FILENAME)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; struct stat ATTRIBUTES;<br />
&nbsp; &nbsp; &nbsp; &nbsp; time_t MTIME;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; stat(FILENAME, &amp;ATTRIBUTES);<br />
&nbsp; &nbsp; &nbsp; &nbsp; MTIME = ATTRIBUTES.st_mtime;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return MTIME;<br />
}<br />
<br />
int main(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%i&quot;,FILEMOD(&quot;file.txt&quot;));<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre>gcc errors:<br />
 <pre style="margin:20px; line-height:13px">filemod.c: In function ‘FILEMOD’:<br />
mod.c:14: warning: return makes pointer from integer without a cast<br />
mod.c: In function ‘main’:<br />
mod.c:19: warning: incompatible implicit declaration of built-in function ‘printf’</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>raigs</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234746.html</guid>
		</item>
		<item>
			<title>POSIX message queue error in mq_receive()</title>
			<link>http://www.daniweb.com/forums/thread234744.html</link>
			<pubDate>Fri, 30 Oct 2009 18:02:05 GMT</pubDate>
			<description><![CDATA[Hello, 
 
Could anyone please explain a reason why data could not be received from a POSIX message queue using mq_receive(), called from a different file.  Following is my code for a test that i'm running to try and transfer data from one file to another. 
 
main.c 
 
 
#include "recfun.h"]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
Could anyone please explain a reason why data could not be received from a POSIX message queue using mq_receive(), called from a different file.  Following is my code for a test that i'm running to try and transfer data from one file to another.<br />
<br />
main.c<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &quot;recfun.h&quot;<br />
<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; datastruct *data;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char *qname=&quot;/queue&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qdes=mq_open(qname, O_RDWR|O_CREAT|O_NONBLOCK, 0777, NULL);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(qdes==-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Cannot open queue\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data=(datastruct*)malloc(sizeof(datastruct));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data-&gt;i=3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data-&gt;c=&quot;3 is the data&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;data-&gt;i=%d\n&quot;, data-&gt;i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;data-&gt;c=%s\n&quot;, data-&gt;c);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(mq_send(qdes, (char *)data, 128, 0)==-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Cannot send data onto the queue\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recv_fun(qdes);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; free(data);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mq_close(qdes);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mq_unlink(qname);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (0);<br />
}</pre><br />
recfun.h<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;mqueue.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
typedef struct<br />
{<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; char *c;<br />
}datastruct;<br />
static mqd_t qdes;<br />
void recv_fun(mqd_t qdes);</pre><br />
recfun.c<br />
 <pre style="margin:20px; line-height:13px">#include &quot;recfun.h&quot;<br />
<br />
void recv_fun(mqd_t qdes)<br />
{<br />
&nbsp; &nbsp; datastruct *data1;<br />
&nbsp; &nbsp; data1=(datastruct *)malloc(sizeof(datastruct));<br />
&nbsp; &nbsp; if(mq_receive(qdes, (char *)&amp;data1, 128, 0)==-1)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Cannot receive data from queue\n&quot;);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; printf(&quot;data1-&gt;i=%d\n&quot;, data1-&gt;i);<br />
&nbsp; &nbsp; printf(&quot;data1-&gt;c=%s\n&quot;, data1-&gt;c);<br />
&nbsp; &nbsp; free(data1);<br />
}</pre><br />
Please do let me know if there could be any reason why I receive &quot;Message too long&quot; error from mq_receive, even when I have allocated sufficient memory.<br />
<br />
Thank you.<br />
<br />
Regards,<br />
<br />
Tapan.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>katwalatapan</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234744.html</guid>
		</item>
		<item>
			<title>need help in c</title>
			<link>http://www.daniweb.com/forums/thread234694.html</link>
			<pubDate>Fri, 30 Oct 2009 13:55:38 GMT</pubDate>
			<description><![CDATA[hi guys.. 
i need help in creating a 'c' program. i ve written the quest below.. 
pls take time to see the quest n answer it..thanks in advance 
 
you must provide a sentence as the 
arguments. The first word of this sentence is to be treated as a key word, your program must search 
the rest of the...]]></description>
			<content:encoded><![CDATA[<div>hi guys..<br />
i need help in creating a 'c' program. i ve written the quest below..<br />
pls take time to see the quest n answer it..thanks in advance<br />
<br />
you must provide a sentence as the<br />
arguments. The first word of this sentence is to be treated as a key word, your program must search<br />
the rest of the sentence for this key word. Your program must then print out the original sentence<br />
with the key word written in capital letters. e.g.<br />
mine What's yours is mine and what's mine is mine.<br />
Result: What's yours is MINE and what's MINE is MINE.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>crashovercool</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234694.html</guid>
		</item>
		<item>
			<title>Cursor Base implementation of list problem</title>
			<link>http://www.daniweb.com/forums/thread234680.html</link>
			<pubDate>Fri, 30 Oct 2009 12:50:38 GMT</pubDate>
			<description><![CDATA[Hello. I've been trying to solve this problem but I can't and my head hurts already. Please help me.  
 
#include<stdio.h> 
#include<conio.h> 
#include<stdlib.h> 
#include<string.h> 
 
#define max 12 
#define num 30 
#define nam 24]]></description>
			<content:encoded><![CDATA[<div>Hello. I've been trying to solve this problem but I can't and my head hurts already. Please help me. <br />
 <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
#include&lt;conio.h&gt;<br />
#include&lt;stdlib.h&gt;<br />
#include&lt;string.h&gt;<br />
<br />
#define max 12<br />
#define num 30<br />
#define nam 24<br />
<br />
typedef struct<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  char name&#91;nam&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int score;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int rank;<br />
}CONTESTANT;<br />
<br />
typedef struct<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  CONTESTANT CA;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int next;<br />
}HeapSpace;<br />
<br />
typedef struct<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  HeapSpace *H;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int first;<br />
}VirtualHeap, *VHeap;<br />
<br />
typedef struct<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int storage&#91;max&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int ladder&#91;max&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int nextrung;<br />
}DualDataStruc, *DDS;<br />
<br />
void initialize(DDS *D, VHeap *VH);<br />
int myMalloc(VHeap *VH);<br />
void myFree(VHeap *VH, int x);<br />
int hash(char n&#91;&#93;);<br />
void insert(DDS *D, VHeap *VH, int NOP);<br />
void display(DDS D, VHeap VH);<br />
<br />
void initialize(DDS *D, VHeap *VH)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int ctr;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  *D = (DDS) malloc(sizeof(DualDataStruc));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  *VH = (VHeap) malloc(sizeof(VirtualHeap));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  (*VH)-&gt;H = (HeapSpace *) malloc(sizeof(HeapSpace) * num);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  (*VH)-&gt;first = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(ctr = 0; ctr &lt; num - 1; ctr++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*VH)-&gt;H&#91;ctr&#93;.next = ctr + 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  (*VH)-&gt;H&#91;ctr&#93;.next = -1;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(ctr = 0; ctr &lt; max; ctr++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*D)-&gt;storage&#91;ctr&#93; = -1;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  (*D)-&gt;nextrung = 0;<br />
}<br />
<br />
int myMalloc(VHeap *VH)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int temp;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  temp = (*VH)-&gt;first;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;%d\n&quot;, temp);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(temp != -1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*VH)-&gt;first = (*VH)-&gt;H&#91;temp&#93;.next;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d &quot;, (*VH)-&gt;first);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  return temp;<br />
}<br />
<br />
void myFree(VHeap *VH, int x)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int temp;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(x != -1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*VH)-&gt;H&#91;x&#93;.next = (*VH)-&gt;first;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*VH)-&gt;first = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
}<br />
<br />
int hash(char n&#91;&#93;)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int ctr, sum = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(ctr = 0; ctr &lt; strlen(n); ctr++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += (int)n;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  return sum % max;<br />
}<br />
<br />
void insert(DDS *D, VHeap *VH, int NOP)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int ctr;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int x, h;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  char n&#91;nam&#93;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;Enter the name of the contestant:\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(ctr = 0; ctr &lt; NOP; ctr++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flushall();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gets(n);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = myMalloc(&amp;(*VH));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; h = hash(n);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy((*VH)-&gt;H&#91;x&#93;.CA.name, n);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*VH)-&gt;H&#91;x&#93;.next = (*D)-&gt;storage&#91;h&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*D)-&gt;storage&#91;h&#93; = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*D)-&gt;ladder&#91;++((*D)-&gt;nextrung)&#93; = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
}<br />
<br />
void display(DDS D, VHeap VH)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int ctr;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(ctr = 1; ctr &lt;= D-&gt;nextrung; ctr++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; puts(VH-&gt;H&#91;D-&gt;ladder&#91;ctr&#93;&#93;.CA.name);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  getch();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  clrscr();<br />
}<br />
<br />
void main(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp;  DDS D;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  VHeap VH;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int NOP;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  initialize(&amp;D, &amp;VH);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  do<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;How many players are there? &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, &amp;NOP);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(NOP &lt; 1 || NOP &gt; 12)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;You can only input 1 to 12 players&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getch();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clrscr();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }while(NOP &lt; 1 || NOP &gt; 12);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  insert(&amp;D, &amp;VH, NOP);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  display(D, VH);<br />
}</pre><br />
I think the problem is in the myMalloc function. Notice that there are two printf in there. One is for the temp value and one is for the VH-&gt; first value. When I ran the program and input different names, sometimes it goes the way I wanted it to. Sometimes, the value of first suddenly becomes -16384 or any number that is not what I expected. This messes up the arrays causing some undesirable effect. The unexpected numbers comes out randomly depending on the names I inputted or the order of names (e.g.: I inputted the names &quot;Kris&quot; and &quot;Allison&quot; in this order and it goes smoothly. I input &quot;Allison and &quot;Kris&quot; in this order, the value of first after &quot;Kris&quot; becomes -1. It shouldn't be -1 because the program only got 2 virtualheaps).<br />
I don't get this. Please help.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Whilliam</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234680.html</guid>
		</item>
		<item>
			<title>Problem with Structs</title>
			<link>http://www.daniweb.com/forums/thread234582.html</link>
			<pubDate>Fri, 30 Oct 2009 04:26:13 GMT</pubDate>
			<description><![CDATA[After compiling the code found here (http://beej.us/guide/bgnet/output/html/multipage/clientserver.html#simpleclient), I immediately got a number of errors. (Unfortunately, Beej is the starting point my instructor suggested to implement our FTP client's "minimal" commands, but that's another...]]></description>
			<content:encoded><![CDATA[<div>After compiling the code found <a rel="nofollow" class="t" href="http://beej.us/guide/bgnet/output/html/multipage/clientserver.html#simpleclient" target="_blank">here</a>, I immediately got a number of errors. (Unfortunately, Beej is the starting point my instructor suggested to implement our FTP client's &quot;minimal&quot; commands, but that's another story). Anyway, I got rid of a few of them, then ran into this:<br />
<br />
 <pre style="margin:20px; line-height:13px">client.c:32 - error: storage size of 'hints' isn't known</pre>(It isn't actually on line 32 in Beej's guide, but it is one of the first lines of the main function - it's the one declaring the struct.)<br />
<br />
So I looked up structs, and I saw that what Beej used is valid syntax for declaring a struct; however, the struct itself is not declared anywhere in the code. So I can only assume it is declared in a .h file or something, and I do not know how to get rid of that error. Any suggestions?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>BestJewSinceJC</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234582.html</guid>
		</item>
		<item>
			<title>How to put a full sentence into an array?</title>
			<link>http://www.daniweb.com/forums/thread234563.html</link>
			<pubDate>Fri, 30 Oct 2009 02:24:15 GMT</pubDate>
			<description><![CDATA[I am trying to write a program that will input a bunch of names into an array of structures under the .name heading. Currently I have what is below to get it to work. But it's not very flexible. You have to input _both_ a first and a last name before it will go on. Is there any command similar to...]]></description>
			<content:encoded><![CDATA[<div>I am trying to write a program that will input a bunch of names into an array of structures under the .name heading. Currently I have what is below to get it to work. But it's not very flexible. You have to input <span style="text-decoration:underline">both</span> a first and a last name before it will go on. Is there any command similar to cin.getline for C++ that will work in this instance? Or a way to leave <span style="font-weight:bold">last</span> as null if a second (&quot;last&quot;) name isnt input that time around?<br />
<br />
 <pre style="margin:20px; line-height:13px">for (count_s=0; count_s &lt; num_stu; count_s++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nEnter name of student #%i: &quot;,count_s+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s %s&quot;, &amp;first, &amp;last);<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcpy(student&#91;count_s&#93;.name, first)<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcat(student&#91;count_s&#93;.name, &quot; &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcat(student&#91;count_s&#93;.name, last);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>RobertMW</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234563.html</guid>
		</item>
		<item>
			<title>C program for 2^i array</title>
			<link>http://www.daniweb.com/forums/thread234555.html</link>
			<pubDate>Fri, 30 Oct 2009 01:47:40 GMT</pubDate>
			<description><![CDATA[Yeah i made a totally new program. However it still doesnt work. The error message says that it is an invaled conversion from int to int*. Here is the code. Please fix it and help repost it. 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Yeah i made a totally new program. However it still doesnt work. The error message says that it is an invaled conversion from int to int*. Here is the code. Please fix it and help repost it.<br />
 <pre style="margin:20px; line-height:13px"># include &lt;stdio.h&gt;<br />
# include &quot;simpio.h&quot;<br />
# include &quot;genlib.h&quot;<br />
# define SIZE 500<br />
void displayArray(int nArray[])<br />
{<br />
int arraynum;<br />
printf(&quot;%d&nbsp; &nbsp; &nbsp; &nbsp; &quot;,nArray[arraynum]);<br />
}<br />
<br />
<br />
main()<br />
{&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; int amount,count,num1,num2,result,arraynum;<br />
&nbsp; &nbsp; &nbsp; int nArray[arraynum];<br />
&nbsp; &nbsp; &nbsp; amount=GetInteger();<br />
&nbsp; &nbsp; &nbsp; count=amount;<br />
&nbsp; &nbsp; &nbsp; num1=count;<br />
&nbsp; &nbsp; &nbsp; num2=num1;<br />
&nbsp; &nbsp; &nbsp; result=1;<br />
&nbsp; &nbsp; &nbsp; arraynum=0;<br />
&nbsp; &nbsp; &nbsp; while(num2!=0)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; while(num1!=0)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; result=result*2;<br />
&nbsp; &nbsp; &nbsp; num1=num1-1;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; displayArray(nArray[arraynum]);<br />
&nbsp; &nbsp; &nbsp; arraynum=arraynum+1;<br />
&nbsp; &nbsp; &nbsp; num2=num2-1;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; getchar();<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>wangatang126</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234555.html</guid>
		</item>
		<item>
			<title>getline error</title>
			<link>http://www.daniweb.com/forums/thread234519.html</link>
			<pubDate>Thu, 29 Oct 2009 20:26:13 GMT</pubDate>
			<description>Hello friends. I am experiencing problems using the getline function in C. I want to use the function to print line numbers next to the text of each line of an input file. I have successfully read in the file and printed its contents line by line. But when I add the part to print the line numbers...</description>
			<content:encoded><![CDATA[<div>Hello friends. I am experiencing problems using the getline function in C. I want to use the function to print line numbers next to the text of each line of an input file. I have successfully read in the file and printed its contents line by line. But when I add the part to print the line numbers using getline, the compiler reports an error and the code doesnt run.<br />
Here is the error I am getting<br />
 <pre style="margin:20px; line-height:13px">&nbsp; [Linker error] undefined reference to `getline' <br />
&nbsp; ld returned 1 exit status</pre>Here is the code I am using:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
# define NEWLINE '\n'<br />
int main()<br />
{<br />
&nbsp; &nbsp; static const char filename&#91;&#93; = &quot;Bond.in.txt&quot;;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; FILE *file = fopen(filename, &quot;r&quot;);&nbsp; &nbsp; <br />
&nbsp; &nbsp; if ( file != NULL )<br />
&nbsp;  {<br />
&nbsp; &nbsp;  char line &#91; 200 &#93;; <br />
<br />
&nbsp; &nbsp; &nbsp; while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  fputs ( line, stdout ); /* write the line */<br />
&nbsp; &nbsp; &nbsp; }<br />
/*********** code that gives problem ***********/<br />
<br />
int counter = 0;<br />
while ( getline(&amp;filename, &amp;line, stdin) ) <br />
{<br />
&nbsp; &nbsp; ++counter;<br />
&nbsp; &nbsp; printf( &quot;%d , %d&quot;, counter, line);&nbsp; &nbsp; &nbsp; &nbsp; <br />
}<br />
<br />
/************* end of code that gives problem****/<br />
<br />
&nbsp; &nbsp; &nbsp; fclose ( file );<br />
&nbsp;  }<br />
&nbsp;  else<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; perror ( filename ); <br />
&nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  char wait;<br />
&nbsp; &nbsp; scanf( &quot;%c&quot;, &amp;wait );<br />
&nbsp;  return(0);<br />
}</pre>I dont understand where this error is coming from. I tried several varaitions using different parameters for getline but all resulted in the aformentioned error. It is my understanding that getline is a built in function included in the stdio library. I havent been able to test my code to see if it is correct because of this error.<br />
Thanks for any help.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Grn Xtrm</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234519.html</guid>
		</item>
		<item>
			<title>Code Snippet Palindrome Check, Dynamic Memory</title>
			<link>http://www.daniweb.com/code/snippet234518.html</link>
			<pubDate>Thu, 29 Oct 2009 20:00:49 GMT</pubDate>
			<description><![CDATA[Just another way to check if a word is palindromic or not. 
In my country (Greece) if a word is palindromic we say it is 
"καρκινική" that's why i named the fuction in the code kark(). 
 
-What it does? 
 
If we would say that word has n letters,then this 
compares the first with the n letter, next...]]></description>
			<content:encoded><![CDATA[<div>Just another way to check if a word is palindromic or not.<br />
In my country (Greece) if a word is palindromic we say it is<br />
&quot;καρκινική&quot; that's why i named the fuction in the code kark().<br />
<br />
-What it does?<br />
<br />
If we would say that word has n letters,then this<br />
compares the first with the n letter, next the second with the n-1 letter and so on..<br />
e.g. let's take the name &quot;anna&quot;<br />
compares the first 'a' with the last 'a'<br />
and the two 'n' in between.<br />
<br />
 <pre style="margin:20px; line-height:13px">a n n a<br />
&nbsp; |--|<br />
|-----|</pre><br />
Hope it's helpful...:)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>panagos</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234518.html</guid>
		</item>
		<item>
			<title><![CDATA[while condition won't work properly against \n]]></title>
			<link>http://www.daniweb.com/forums/thread234474.html</link>
			<pubDate>Thu, 29 Oct 2009 16:46:12 GMT</pubDate>
			<description><![CDATA[I'm focusing now on this I/O thing, even writing a guide by looking some sources. I want to cover it all i can about stdin i/o and if it looks good in the end i'd love to share with you. But that's still OT. 
 
I can't get rid of the line feed code char. x is a char, and when i write let's say...]]></description>
			<content:encoded><![CDATA[<div>I'm focusing now on this I/O thing, even writing a guide by looking some sources. I want to cover it all i can about stdin i/o and if it looks good in the end i'd love to share with you. But that's still OT.<br />
<br />
I can't get rid of the line feed code char. x is a char, and when i write let's say &quot;web&quot; and hit enter, it prints out w, e, b and also a line feed.<br />
I have tried with ((x = getchar()) &amp;&amp; x != '\n') and also ((x = getchar()) &amp;&amp; (int) x != 10).<br />
<br />
What am i missing?<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; while(1)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char x = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nInput: &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; while ((x = getchar()) &amp;&amp; x != '\n'){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nchar x -&gt; %c \nint x --&gt; %i\n&quot;, x, x);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; return 0;<br />
}</pre><br />
Thank you</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>neithan</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234474.html</guid>
		</item>
		<item>
			<title>C, do while loop.</title>
			<link>http://www.daniweb.com/forums/thread234454.html</link>
			<pubDate>Thu, 29 Oct 2009 15:39:34 GMT</pubDate>
			<description><![CDATA[I am trying to write a little program with a do while loop and if statements.  
 
I'm having trouble getting this to work the way I want. When I run the program, it produces two menus after making a selection. I would like it to produce one menu after making a selection 
 
 
the output is ----- 
 
...]]></description>
			<content:encoded><![CDATA[<div>I am trying to write a little program with a do while loop and if statements. <br />
<br />
I'm having trouble getting this to work the way I want. When I run the program, it produces two menus after making a selection. I would like it to produce one menu after making a selection<br />
<br />
<br />
the output is -----<br />
<br />
<br />
<br />
        Welcome to ABC bank ATM!<br />
<br />
        d:      Deposit<br />
        w:      Withdraw Amount<br />
        b:      Check Balance<br />
        e:      Exit the ATM program<br />
        Now Enter Your Choice:  b<br />
<br />
 Your Balance is:                               10000.00<br />
<br />
<br />
        d:      Deposit<br />
        w:      Withdraw Amount<br />
        b:      Check Balance<br />
        e:      Exit the ATM program<br />
        Now Enter Your Choice:<br />
        d:      Deposit<br />
        w:      Withdraw Amount<br />
        b:      Check Balance<br />
        e:      Exit the ATM program<br />
        Now Enter Your Choice:<br />
<br />
---<br />
<br />
As you can see after making my selection, the program produces two menus. Im sure I have the set up for my do while loop wrong, just cant seem to be able to pinpoint where. <br />
<br />
Advice would be appreciated. Thanks.<br />
<br />
This is the source code.<br />
---<br />
 <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
<br />
main()<br />
{<br />
&nbsp; //declare and intialize variables<br />
&nbsp; char cChoice = '\0';<br />
&nbsp; float balance = 10000.00;<br />
&nbsp; float amount = 0.00;<br />
<br />
&nbsp; system(&quot;clear&quot;); //a command to clear the screen<br />
<br />
&nbsp; //introductory messages to user and get the user choice for banking<br />
&nbsp; fprintf(stdout,&quot;\n\tWelcome to ABC bank ATM!\n&quot;);<br />
<br />
&nbsp; do&nbsp; {<br />
&nbsp; //introductory messages to user and get the user choice for banking<br />
&nbsp; fprintf(stdout,&quot;\n\td:\tDeposit\n\tw:\tWithdraw Amount\n\tb:\tCheck Balance\n\te:\tExit the ATM program\n&quot;);<br />
&nbsp; fprintf(stdout,&quot;\tNow Enter Your Choice:\t&quot;);<br />
&nbsp; fscanf(stdin,&quot;%c&quot;,&amp;cChoice);<br />
<br />
&nbsp; //Go further only IF the user enters a valid input<br />
&nbsp; //choice that is, 'd' or 'b' or 'w'<br />
<br />
&nbsp; if ( cChoice == 'd' || cChoice == 'w' || cChoice == 'b')<br />
&nbsp; {<br />
&nbsp; &nbsp; //if user choice is 'b' for checking balance do this..<br />
&nbsp; &nbsp; if (cChoice == 'b')<br />
&nbsp; &nbsp; &nbsp; &nbsp; fprintf(stdout, &quot;\n Your Balance is: \t\t\t\t%.2f\n\n&quot;,balance);<br />
&nbsp; &nbsp; //if user choice is 'd' for deposit do this..<br />
&nbsp; &nbsp; if (cChoice == 'd')<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; fprintf(stdout,&quot;\n\n Enter the amount to deposit:\t\t\t&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fscanf(stdin, &quot;%f&quot;, &amp;amount);<br />
&nbsp; &nbsp; &nbsp; &nbsp; balance = amount + balance;<br />
&nbsp; &nbsp; &nbsp; &nbsp; fprintf(stdout,&quot;\n\n Updated Balance is %.2f\n\n&quot;,balance);<br />
&nbsp; &nbsp; &nbsp; &nbsp; sleep(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;clear&quot;);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; //if choice is 'w' for withdraw amount do this..<br />
if(cChoice == 'w')<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; fprintf(stdout,&quot;\n Enter the amount to withdraw:\t\t\t&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fscanf(stdin, &quot;%f&quot;, &amp;amount);<br />
&nbsp; &nbsp; &nbsp; &nbsp; //nested if else, that allows withdrawl only if there is enough balance<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(balance&lt;amount)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(stdout,&quot;\nInsufficient Funds\n\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; balance = balance - amount;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(stdout,&quot;\n\n Updated Balance is %.2f\n\n&quot;, balance);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sleep(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; system(&quot;clear&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; } //choice entered is 'w' ends here<br />
&nbsp;  }<br />
&nbsp; }<br />
&nbsp; while ( cChoice !='e' );<br />
&nbsp; return 0;<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>cloisterham</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234454.html</guid>
		</item>
		<item>
			<title>Figuring out redirection of a child process to a file</title>
			<link>http://www.daniweb.com/forums/thread234452.html</link>
			<pubDate>Thu, 29 Oct 2009 15:26:13 GMT</pubDate>
			<description>Hi there, 
 
So im working on this assignment where the user is supposed to input a variety of UNIX commands and they must behave as if one typed it into the terminal. My current problem lies with when a user tries to redirect the inputted commands to some file. Currently it only works when a user...</description>
			<content:encoded><![CDATA[<div>Hi there,<br />
<br />
So im working on this assignment where the user is supposed to input a variety of UNIX commands and they must behave as if one typed it into the terminal. My current problem lies with when a user tries to redirect the inputted commands to some file. Currently it only works when a user has the redirect symbol along with one command:<br />
<br />
ls -l &gt; temp.txt<br />
<br />
However if I try to input:<br />
ls -l | sort -n<br />
<br />
or even:<br />
<br />
ls -l | sort -n &gt; temp.txt<br />
<br />
I just segfault. I know the problem most likely lies in how I wrote the redirect option, but I cant seem to figure out how to make it so that the two above commands work.<br />
<br />
Any Help would be greatly appreciated!<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;errno.h&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;unistd.h&gt;<br />
#include &lt;sys/types.h&gt;<br />
#include &lt;fcntl.h&gt;<br />
<br />
/*get args function*/<br />
<br />
#define MAXARGS 256<br />
char ** getargs(char * cmd) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; // assumes that cmd ends with NULL<br />
&nbsp; &nbsp; &nbsp; &nbsp; char** argsarray;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int nargs = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int nlen = strlen(cmd);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; argsarray = (char**) malloc(sizeof(char*) * MAXARGS);<br />
&nbsp; &nbsp; &nbsp; &nbsp; argsarray[0] = strtok(cmd,&quot; &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (argsarray[i] != NULL){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; argsarray[i] = strtok(NULL,&quot; &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return argsarray;<br />
}<br />
<br />
<br />
int main(void){<br />
<br />
&nbsp; pid_t childpid;<br />
&nbsp; int fd[256][2];<br />
&nbsp; char cmd[256];<br />
&nbsp; char * sepCmd[256];<br />
&nbsp; char * pch;<br />
&nbsp; char * srch;<br />
<br />
&nbsp; printf(&quot;Please enter a command sequence: \n&quot;);<br />
&nbsp; gets(cmd);<br />
&nbsp; //scanf(&quot;%s&quot;, cmd);<br />
&nbsp; printf(&quot;You have entered: %s \n&quot;, cmd);<br />
&nbsp; <br />
<br />
&nbsp; printf(&quot;Attempting to split up command: \n&quot;);<br />
&nbsp; pch = strtok (cmd, &quot;|&quot;);<br />
&nbsp; <br />
//This is where I think it goes wrong<br />
&nbsp; srch = strchr(cmd, '&gt;');<br />
&nbsp; *srch++ = '\0'<br />
&nbsp; while (*srch == ' ') ++srch;<br />
<br />
&nbsp; int count = 0;&nbsp; <br />
&nbsp; &nbsp; while (pch != NULL &amp;&amp; count &lt; 256) {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;%s\n&quot;, pch);<br />
&nbsp; &nbsp; &nbsp; sepCmd[count] = pch;<br />
&nbsp; &nbsp; &nbsp; printf(&quot;The value in this array value is: %s\n&quot;, sepCmd[count]);<br />
&nbsp; &nbsp; &nbsp; pch = strtok (NULL, &quot;|&quot;);<br />
&nbsp; &nbsp; &nbsp; count++;<br />
&nbsp; }<br />
&nbsp; <br />
&nbsp; char ** argue;<br />
&nbsp; int k;<br />
&nbsp; <br />
&nbsp; /* Block that deals with the first command given by the user */<br />
&nbsp; k = 0;<br />
&nbsp; pipe(fd[k]);<br />
&nbsp; if(!fork()) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dup2(fd[k][1], STDOUT_FILENO);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close(fd[k][0]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; argue = getargs(sepCmd[k]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; execvp(argue[0], argue);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; perror(argue[0]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; }<br />
<br />
&nbsp; /*Loop that will control all other comands except the last*/<br />
&nbsp; for(k = 1; k &lt;= count - 2; k++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close(fd[k-1][1]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pipe(fd[k]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!fork()) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close(fd[k][0]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dup2(fd[k-1][0], STDIN_FILENO);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dup2(fd[k][1], STDOUT_FILENO);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; argue = getargs(sepCmd[k]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; execvp(argue[0], argue);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; perror(argue[0]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; }<br />
&nbsp; <br />
&nbsp; <br />
&nbsp; /*Block that will take care of the last command in the sequence*/<br />
&nbsp; k = count - 1;<br />
&nbsp; <br />
&nbsp; close(fd[k-1][1]);<br />
&nbsp; if(!fork()) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dup2(fd[k-1][0], STDIN_FILENO);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; argue = getargs(sepCmd[k]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (srch) dup2(open(srch, O_RDWR|O_CREAT), STDOUT_FILENO);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; execvp(argue[0], argue);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; perror(argue[0]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; }<br />
&nbsp; while(waitpid(-1, NULL, 0) != -1);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>opt!kal</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234452.html</guid>
		</item>
		<item>
			<title>gedit plugin: code completion (gtk)</title>
			<link>http://www.daniweb.com/forums/thread234433.html</link>
			<pubDate>Thu, 29 Oct 2009 13:27:22 GMT</pubDate>
			<description>It is useful if you use gedit to code gtk. 
 
http://code.google.com/p/jcodecompletion</description>
			<content:encoded><![CDATA[<div>It is useful if you use gedit to code gtk.<br />
<br />
<a rel="nofollow" class="t" href="http://code.google.com/p/jcodecompletion" target="_blank">http://code.google.com/p/jcodecompletion</a></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>jqbsx</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234433.html</guid>
		</item>
		<item>
			<title>finding the middle element of the list with 0(n)</title>
			<link>http://www.daniweb.com/forums/thread234401.html</link>
			<pubDate>Thu, 29 Oct 2009 11:18:07 GMT</pubDate>
			<description>Hello , 
i have written the code for finding the middle element of the list with 
0(n) complexity. 
 
please gurus, verify that and let me know if it needs any modifications 
 
and ofcourse i have question to ask 
 
when the no of elements are odd 
we can easily find the middle element</description>
			<content:encoded><![CDATA[<div>Hello ,<br />
i have written the code for finding the middle element of the list with<br />
0(n) complexity.<br />
<br />
please gurus, verify that and let me know if it needs any modifications<br />
<br />
and ofcourse i have question to ask<br />
<br />
when the no of elements are odd<br />
we can easily find the middle element <br />
suppose<br />
1 2 3 4 5 the middle is 3<br />
but when the no of elements are even<br />
1 2 3 4 5 6<br />
how can we decide the middle element <br />
is there any most widely used way or experts  follow.<br />
<br />
please let me know<br />
<br />
<br />
NOTE : in my previous post i have given the insert  function you can have a look at it if you need<br />
<a rel="nofollow" class="t" href="http://www.daniweb.com/code/snippet234375.html" target="_blank">insert</a> <pre style="margin:20px; line-height:13px">int find_mid(struct node *nrml)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; struct node *adv=nrml;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(adv) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(adv-&gt;next !=NULL) {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  //if(adv-&gt;next-&gt;next != NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adv = adv-&gt;next-&gt;next ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nrml = nrml -&gt; next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;with odd :\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return nrml-&gt;data;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; printf(&quot;with even :\n&quot;);<br />
&nbsp; &nbsp; return nrml-&gt;data;<br />
}<br />
<br />
<br />
Driver code :<br />
<br />
#define ODD 9<br />
#define EVEN 10<br />
int main()<br />
{<br />
&nbsp;struct node *podd=NULL;<br />
&nbsp;struct node *peven=NULL;<br />
&nbsp;int n,d,i=0,ele;<br />
&nbsp;int odd[ODD]={1,2,3,4,5,6,7,8,9};<br />
&nbsp;int even[EVEN]={1,2,3,4,5,6,7,8,9,10};<br />
&nbsp;while(i&lt;ODD)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; insert(&amp;podd,odd[i++]);<br />
}<br />
<br />
i=0;<br />
while(i&lt;EVEN)<br />
{<br />
&nbsp;insert(&amp;peven,even[i++]);<br />
}<br />
<br />
display(podd);<br />
&nbsp;ele = find_mid(podd);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n%d&quot;,ele);<br />
<br />
printf(&quot;\n&quot;);<br />
display(peven);<br />
<br />
ele = find_mid(peven);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n%d&quot;,ele);<br />
<br />
return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Iam3R</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234401.html</guid>
		</item>
		<item>
			<title>Code Snippet finding nth last element with 0(n) complexity</title>
			<link>http://www.daniweb.com/code/snippet234375.html</link>
			<pubDate>Thu, 29 Oct 2009 09:32:36 GMT</pubDate>
			<description>I am very poor in calculating complexities. 
Please some one let me know what is the complexity of the below program. 
 
I actually  want to write a program for finding the nth last element with 0(n) complexity.  
but unable write, please give me some idea. 
 
the below code works perfectly and i...</description>
			<content:encoded><![CDATA[<div>I am very poor in calculating complexities.<br />
Please some one let me know what is the complexity of the below program.<br />
<br />
I actually  want to write a program for finding the nth last element with 0(n) complexity. <br />
but unable write, please give me some idea.<br />
<br />
the below code works perfectly and i considered all the posibilities.<br />
<br />
 <pre style="margin:20px; line-height:13px">if list empty : returns zero<br />
if postion is &lt; 0 : returns -2<br />
if position is &gt; no of elements in the list : returns -1</pre><br />
please mention if any other possibilities can be covered.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Iam3R</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234375.html</guid>
		</item>
		<item>
			<title>Code Snippet A question about signal</title>
			<link>http://www.daniweb.com/code/snippet234337.html</link>
			<pubDate>Thu, 29 Oct 2009 07:04:10 GMT</pubDate>
			<description><![CDATA[This code is just handling the SIGCHLD signal, but as you can see, the parent process should ignore this SIGCHLD signal according to the signal function. But in fact, the parent process will omit the signal function, and handling the child process using "wait". I wonder why the parent do not ignore...]]></description>
			<content:encoded><![CDATA[<div>This code is just handling the SIGCHLD signal, but as you can see, the parent process should ignore this SIGCHLD signal according to the signal function. But in fact, the parent process will omit the signal function, and handling the child process using &quot;wait&quot;. I wonder why the parent do not ignore the SIGCHLD signal?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>alien2006.happy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234337.html</guid>
		</item>
		<item>
			<title>Can we put coloured fonts or background in C programming?</title>
			<link>http://www.daniweb.com/forums/thread234326.html</link>
			<pubDate>Thu, 29 Oct 2009 06:39:03 GMT</pubDate>
			<description>Hi, 
 
is there a way to avoid the conventional Black Background of C program While its execution? can the fonts be changed or can we include graphics/photos in C so that we can view it during its execution?</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
is there a way to avoid the conventional Black Background of C program While its execution? can the fonts be changed or can we include graphics/photos in C so that we can view it during its execution?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Bips123</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234326.html</guid>
		</item>
		<item>
			<title>Which function builds argv ?</title>
			<link>http://www.daniweb.com/forums/thread234312.html</link>
			<pubDate>Thu, 29 Oct 2009 05:34:29 GMT</pubDate>
			<description><![CDATA[Suppose that I have a program named myprog, and I type this in a shell 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>Suppose that I have a program named myprog, and I type this in a shell<br />
 <pre style="margin:20px; line-height:13px">$ myprog -z hello -m &quot;this is a message&quot;</pre>The function main in myprog will receive a char** argv containing the following strings<br />
 <pre style="margin:20px; line-height:13px">&quot;-z&quot;, &quot;hello&quot;, &quot;-m&quot;, &quot;this is a message&quot;</pre>So there must be somewhere in a C library a function which takes the command line string and produces the char** argv.<br />
My question for you, C experts, is <span style="font-weight:bold">where is this function and how is it called ?</span></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Gribouillis</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234312.html</guid>
		</item>
		<item>
			<title>open file as soon asyou run a command. How?</title>
			<link>http://www.daniweb.com/forums/thread234253.html</link>
			<pubDate>Thu, 29 Oct 2009 01:36:51 GMT</pubDate>
			<description><![CDATA[I have a file called file.dat and have to write a program called sdev.c which adds up all of the numbers in file.dat from each line. (Assuming that one number is per line) 
 
which has to open like this 
 
$ ./sdev < file.dat 
 
Now I can do all of the work that adds up the numbers but how the hack...]]></description>
			<content:encoded><![CDATA[<div>I have a file called file.dat and have to write a program called sdev.c which adds up all of the numbers in file.dat from each line. (Assuming that one number is per line)<br />
<br />
which has to open like this<br />
<br />
$ ./sdev &lt; file.dat<br />
<br />
Now I can do all of the work that adds up the numbers but how the hack can I open it and scan each number from each line?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>desiguru</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234253.html</guid>
		</item>
		<item>
			<title>C program for 2D arrays</title>
			<link>http://www.daniweb.com/forums/thread234225.html</link>
			<pubDate>Wed, 28 Oct 2009 23:09:26 GMT</pubDate>
			<description><![CDATA[i need some help on this. I have the array numbers stored already but the array dosent display on the screen. Why? here is the code 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>i need some help on this. I have the array numbers stored already but the array dosent display on the screen. Why? here is the code<br />
 <pre style="margin:20px; line-height:13px"><br />
<br />
<br />
# include &lt;stdio.h&gt;<br />
# include &quot;simpio.h&quot;<br />
# include &quot;genlib.h&quot;<br />
# include &quot;strlib.h&quot;<br />
# include &lt;math.h&gt;<br />
# define size 3<br />
<br />
main()<br />
{<br />
&nbsp; &nbsp; &nbsp; int intArray[size][size];<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; intArray[0][0]=GetInteger();<br />
&nbsp; &nbsp; &nbsp; intArray[0][1]=GetInteger();<br />
&nbsp; &nbsp; &nbsp; intArray[0][2]=GetInteger();<br />
&nbsp; &nbsp; &nbsp; intArray[1][0]=GetInteger();<br />
&nbsp; &nbsp; &nbsp; intArray[1][1]=GetInteger();<br />
&nbsp; &nbsp; &nbsp; intArray[1][2]=GetInteger();<br />
&nbsp; &nbsp; &nbsp; intArray[2][0]=GetInteger();<br />
&nbsp; &nbsp; &nbsp; intArray[2][1]=GetInteger();<br />
&nbsp; &nbsp; &nbsp; intArray[2][2]=GetInteger();&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; void displayMatrix (int intArray[3][3]);&nbsp;  <br />
&nbsp; &nbsp; &nbsp; getchar();<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>wangatang126</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234225.html</guid>
		</item>
		<item>
			<title>problem regarding trees in data structures using c</title>
			<link>http://www.daniweb.com/forums/thread234202.html</link>
			<pubDate>Wed, 28 Oct 2009 21:27:53 GMT</pubDate>
			<description><![CDATA[hello i'm subhash n m persuing BCA IInd year n got an assignment of writing a program to create a binary tree n display the elements level wise ie i need to display in a form of tree. 
for example if elements are 6,4,8,3,5,7,9 then i need to display it as 
 
 
..........6..........]]></description>
			<content:encoded><![CDATA[<div>hello i'm subhash n m persuing BCA IInd year n got an assignment of writing a program to create a binary tree n display the elements level wise ie i need to display in a form of tree.<br />
for example if elements are 6,4,8,3,5,7,9 then i need to display it as<br />
<br />
<br />
..........6.......<br />
....4..........8...<br />
.3...5.....7....9...<br />
(here dots r used jst to seperate these values)<br />
i've writen a program to crate the tree but not getting how to write for displaying it.<br />
plz help me in writing this code.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>subhashkataria2</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234202.html</guid>
		</item>
		<item>
			<title>How to buffer output?</title>
			<link>http://www.daniweb.com/forums/thread234200.html</link>
			<pubDate>Wed, 28 Oct 2009 21:25:13 GMT</pubDate>
			<description><![CDATA[How to: 
1. Buffer output ? 
2. Get its size ? 
3. Print the buffer ? 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>How to:<br />
1. Buffer output ?<br />
2. Get its size ?<br />
3. Print the buffer ?<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
<br />
int main(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Tons of printf lines\n&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; // 1. Somehow buffer the output up until this point<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;The size of the buffer is: %i\n&quot;, SIZEOFBUFFER); // 2. Get and print the size of the buffer.<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Here is the output:\n\n%s&quot;, BUFFER); // 3. Print the buffer.<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>raigs</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234200.html</guid>
		</item>
		<item>
			<title>Compile program for both 32 and 64 bit?</title>
			<link>http://www.daniweb.com/forums/thread234195.html</link>
			<pubDate>Wed, 28 Oct 2009 21:04:09 GMT</pubDate>
			<description><![CDATA[N00B. If I compile a simple Hello World! program on a 64bit linux, will it work on a 32bit linux? (I'm using gcc). 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680"...]]></description>
			<content:encoded><![CDATA[<div>N00B. If I compile a simple Hello World! program on a 64bit linux, will it work on a 32bit linux? (I'm using gcc).<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
<br />
int main(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Hello World!&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>raigs</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234195.html</guid>
		</item>
		<item>
			<title>pass excel sheet in linux C using libxls</title>
			<link>http://www.daniweb.com/forums/thread234147.html</link>
			<pubDate>Wed, 28 Oct 2009 17:13:40 GMT</pubDate>
			<description>hi i want to pass excel sheet in linux C using libxls 
so lpz give me guideline</description>
			<content:encoded><![CDATA[<div>hi i want to pass excel sheet in linux C using libxls<br />
so lpz give me guideline</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>vishme</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234147.html</guid>
		</item>
		<item>
			<title>pass excel sheet in linux C using libxls</title>
			<link>http://www.daniweb.com/forums/thread234146.html</link>
			<pubDate>Wed, 28 Oct 2009 17:08:01 GMT</pubDate>
			<description>hi i want to pass excel sheet in linux C using libxls 
so lpz give me guideline</description>
			<content:encoded><![CDATA[<div>hi i want to pass excel sheet in linux C using libxls<br />
so lpz give me guideline</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>vishme</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234146.html</guid>
		</item>
		<item>
			<title>C language help required (2 Questions here )</title>
			<link>http://www.daniweb.com/forums/thread234102.html</link>
			<pubDate>Wed, 28 Oct 2009 09:15:32 GMT</pubDate>
			<description>Dear Sir  
 
Any one can help me in C language please here are 2 questions and i need th solution of them very simple question beginer level  
 
 
See Attachment file for the questions  
 
Regards</description>
			<content:encoded><![CDATA[<div>Dear Sir <br />
<br />
Any one can help me in C language please here are 2 questions and i need th solution of them very simple question beginer level <br />
<br />
<br />
See Attachment file for the questions <br />
<br />
Regards</div>  <br /> <div style="padding:5px">    <fieldset class="fieldset"> <legend>Attached Images</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/jpg.gif" alt="File Type: jpg" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12339&amp;d=1256721173" target="_blank">assg1.jpg</a> (57.8 KB)</td> </tr><tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/jpg.gif" alt="File Type: jpg" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12340&amp;d=1256720939" target="_blank">ag.jpg</a> (96.7 KB)</td> </tr> </table> </fieldset>   </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>afnan1</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234102.html</guid>
		</item>
		<item>
			<title>Restaurant Billing System in C help</title>
			<link>http://www.daniweb.com/forums/thread234073.html</link>
			<pubDate>Wed, 28 Oct 2009 07:16:38 GMT</pubDate>
			<description>A friend of mine is having problem with his C programming for his assignment. The question is as follows: 
 
THE QUESTION: RESTAURANT BILLING SYSTEM 
Write a program in C to computerize the billing system of a restaurant. The customer bill is charged 
based on the following information: 
• Assume...</description>
			<content:encoded><![CDATA[<div>A friend of mine is having problem with his C programming for his assignment. The question is as follows:<br />
<br />
THE QUESTION: RESTAURANT BILLING SYSTEM<br />
Write a program in C to computerize the billing system of a restaurant. The customer bill is charged<br />
based on the following information:<br />
• Assume that the restaurant offers the following menu (the price of each item for each adult is<br />
shown to the right of the item):<br />
1. Fish and Chips RM15.80<br />
2. Spaghetti RM10.50<br />
3. T-Bone Steak RM19.00<br />
4. Chicken Chop RM14.00<br />
5. Chicken Maryland RM12.00<br />
6. Red Lobster RM22.00<br />
7. Seafood Platter RM16.00<br />
• The prices per person shown are inclusive of drinks. Children’s meals will cost 60% of adult<br />
meals.<br />
• A tax rate, currently 5%, is added to the total bill.<br />
• User is able to input the new or edit items in the restaurant menu along with their prices.<br />
• To attract more customers to this restaurant, the owner wants to give discount. This discount<br />
depends on the amount of the total bill:<br />
-If the bill is less than RM10.00, the discount is 0.5%.<br />
-If the bill is at least RM10.00 but less than RM20.00, the discount is 1.0%.<br />
-If the bill is at least RM20.00 but less than RM30.00, the discount is 1.5%.<br />
-If the bill is at least RM30.00 but less RM40.00, the discount is 2%<br />
<br />
The code so far for him is:<br />
 <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
#include&lt;string.h&gt;<br />
#include&lt;stdlib.h&gt;<br />
<br />
<br />
double price[7] = {15.80 , 10.50 , 19.00 , 14.00 , 12.00 , 22.00 , 16.00 };<br />
double mealTaxPrices[7];<br />
int adultNumber,childNumber;<br />
<br />
<br />
void printMeals();<br />
void orderMeals();<br />
double orderForAdult();<br />
double orderForChildren();<br />
int main()<br />
{<br />
&nbsp; &nbsp; char response = 'y';<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp;  printMeals();<br />
&nbsp; &nbsp;  while(response == 'y'|| response == 'Y')<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;please enter number of adults&nbsp; :&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;,&amp;adultNumber);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;please enter number of children:&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;,&amp;childNumber);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; orderMeals();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nwould you like to continue(y/n):&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;\n%c&quot;,&amp;response);<br />
&nbsp; &nbsp; }<br />
&nbsp; <br />
&nbsp;printf(&quot;\n&nbsp; &nbsp; &nbsp; ******************** THANK YOU FOR COMING&nbsp; *************************\n&quot;);<br />
&nbsp;printf(&quot;\20**********************&nbsp;  PLEASE VISIT US NEXT TIME&nbsp; **************************\20 \n&quot;);<br />
&nbsp;  system(&quot;pause&quot;);<br />
&nbsp;  return 0;<br />
}<br />
<br />
void printMeals()<br />
{<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; printf(&quot;\20*******************&nbsp; WELCOME TO HADRAMOUT RESTURANT **************************\20\n&quot;);<br />
&nbsp; &nbsp; &nbsp; printf(&quot; \t\t\t Below is the menue:\20\n&quot;);<br />
&nbsp; &nbsp; &nbsp; printf(&quot; \t\t\t MEALS\t\t\tPRICE:\n&quot;);<br />
&nbsp; &nbsp; &nbsp; printf(&quot; \t\t\t \22*******************************\22\n&quot;);<br />
&nbsp; &nbsp; &nbsp; printf(&quot; \t\t\t 1- Fish and Chips\tRM15.80\n&quot;);<br />
&nbsp; &nbsp; &nbsp; printf(&quot; \t\t\t 2- Spaghetti\t\tRM10.50\n&quot;);<br />
&nbsp; &nbsp; &nbsp; printf(&quot; \t\t\t 3- T-Bone Steak\tRM19.00\n&quot;);<br />
&nbsp; &nbsp; &nbsp; printf(&quot; \t\t\t 4- Chicken Chop\tRM14.00\n&quot;);<br />
&nbsp; &nbsp; &nbsp; printf(&quot; \t\t\t 5- Chicken Maryland\tRM12.00\n&quot;);<br />
&nbsp; &nbsp; &nbsp; printf(&quot; \t\t\t 6- Red Lobster\t\tRM22.00\n&quot;);<br />
&nbsp; &nbsp; &nbsp; printf(&quot; \t\t\t 7- Seafood Platter\tRM16.00\n&quot;);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
}<br />
void orderMeals()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; double totalPriceForAdult, totalPriceForChildren;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double allPayment,discount;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \t\t**** ORDER MENUE****\n&quot;);&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; totalPriceForAdult =&nbsp; orderForAdult();<br />
&nbsp; &nbsp; &nbsp; &nbsp; totalPriceForChildren = orderForChildren();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; allPayment = totalPriceForAdult + totalPriceForChildren ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;  printf(&quot;\n \t\t&nbsp; &nbsp;  \22**************************************\22&nbsp; &nbsp; \n&quot;);<br />
&nbsp; &nbsp;  printf(&quot; \t\t&nbsp;  ******************&nbsp; final BILL&nbsp;  ************&nbsp; &nbsp; &nbsp; \n&quot;);<br />
&nbsp; &nbsp;  printf(&quot; \t\t\tadult/child\tcount\t\ttotal price\n&quot;);<br />
&nbsp; &nbsp;  printf(&quot; \t\t\tadults\t\t%d\t\t%5.2f\n&quot;,adultNumber,totalPriceForAdult);<br />
&nbsp; &nbsp;  printf(&quot; \t\t\tchildren\t%d\t\t%5.2f\n&quot;,childNumber,totalPriceForChildren);<br />
&nbsp; &nbsp;  printf(&quot; \t\t\tTotal bill\t\t\t%5.2f\n&quot;,allPayment );<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp;  if(allPayment &lt; 10)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  discount=((allPayment * 0.5)/100);<br />
&nbsp; &nbsp;  else if(allPayment&gt;= 10 &amp;&amp; allPayment&lt;20)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; discount=((allPayment * 1)/100);<br />
&nbsp; &nbsp;  else if(allPayment&gt;= 20 &amp;&amp; allPayment&lt;30)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; discount=((allPayment * 1.5)/100);<br />
&nbsp; &nbsp;  else if(allPayment&gt;= 30 &amp;&amp; allPayment&lt;40)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; discount=((allPayment * 2.0)/100);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; discount= ((allPayment * 5.0)/100);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot; \t\t\tTotal bill after discount\t%5.2f\n&quot;,allPayment-discount);<br />
<br />
}<br />
double orderForAdult()<br />
{<br />
&nbsp; &nbsp;  int menuOption,i,amount;<br />
&nbsp; &nbsp; &nbsp; char response = 'y';<br />
&nbsp; &nbsp; &nbsp; double totalPerPerson = 0.0,totalAllPerson = 0.0;<br />
&nbsp; &nbsp; &nbsp; double tax = 5.0;<br />
&nbsp; &nbsp; &nbsp; if(adultNumber &lt;=0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;\n &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; printf(&quot;*\tadults:\n&quot;);<br />
&nbsp; &nbsp; &nbsp; for(i=0;i&lt;adultNumber;i++)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;adult %d please enter your orders\n&quot;,i+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  while(response == 'y' || response == 'Y')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;please enter your option:&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;,&amp;menuOption);<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; if(menuOption&lt;1 || menuOption&gt;7)<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; {<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; &nbsp; printf(&quot;sorry we don`t have this order \nagain! &quot;);<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; &nbsp; continue;<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; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;please enter your amount of order:&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;,&amp;amount);<br />
&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; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  totalPerPerson = totalPerPerson + (amount * price[menuOption - 1] );<br />
&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; &nbsp; &nbsp; &nbsp; printf(&quot;\nWould you like to enter more orders(y/n):&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;\n%c&quot;,&amp;response);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&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; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  totalAllPerson += totalAllPerson +&nbsp; totalPerPerson;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  totalPerPerson = 0.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  response = 'y';<br />
&nbsp; &nbsp;  }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp;  return totalAllPerson + ((totalAllPerson * tax) / 100);<br />
}<br />
double orderForChildren()<br />
{<br />
&nbsp; &nbsp; &nbsp;  int menuOption,i,amount;<br />
&nbsp; &nbsp; &nbsp; char response = 'y';<br />
&nbsp; &nbsp; &nbsp; double totalPerChild = 0.0,totalAllChildren = 0.0;<br />
&nbsp; &nbsp; &nbsp; double tax = 5.0,oneOrder;<br />
&nbsp; &nbsp; &nbsp;  if(childNumber &lt;=0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;*\tChildren:\n&quot;);<br />
&nbsp; &nbsp; &nbsp;  for(i=0;i&lt;childNumber;i++)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;child %d please enter your orders\n&quot;,i+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  while(response == 'y' || response == 'Y')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;please enter your option:&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;,&amp;menuOption);<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; if(menuOption&lt;1 || menuOption&gt;7)<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; {<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; &nbsp; printf(&quot;sorry we don`t have this order \nagain! &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<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; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;please enter your amount of order:&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;,&amp;amount);<br />
&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; &nbsp; &nbsp; &nbsp; oneOrder = (price[menuOption - 1] * 60)/100 ;//this one order for a child with discount %60 of one order of adult<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; totalPerChild = totalPerChild + (amount * oneOrder)&nbsp; ;<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Would you like to enter more orders(y/n):&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;\n%c&quot;,&amp;response);<br />
&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; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  totalAllChildren += totalAllChildren +&nbsp; totalPerChild;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  response = 'y';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  totalPerChild = 0.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp;  }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp;  return totalAllChildren + ((totalAllChildren * tax) / 100);<br />
}</pre>the problem is all about how he can let the user to edit the entered data for the childes and adults , and how he can display the prices for every one. the most important is how he can lit the user to edit what her ordered. Or if anyone of you think there is a better way to improve the process of this code, your help is much appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>kingster113</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234073.html</guid>
		</item>
		<item>
			<title>Reading txt file in c</title>
			<link>http://www.daniweb.com/forums/thread234055.html</link>
			<pubDate>Wed, 28 Oct 2009 05:58:19 GMT</pubDate>
			<description>I have to read a moviea database txt file(attached) into an array and then implement string search. I am using fgets() but problem is that I can read only part and not compelete text. Any anyone can help please ??</description>
			<content:encoded><![CDATA[<div>I have to read a moviea database txt file(attached) into an array and then implement string search. I am using fgets() but problem is that I can read only part and not compelete text. Any anyone can help please ??</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/images/attach/txt.gif" alt="File Type: txt" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12336&amp;d=1256709435">movies.txt</a> (397.1 KB)</td> </tr><tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/c.gif" alt="File Type: c" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12337&amp;d=1256709477">a52.c</a> (829 Bytes)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Trueblue1234</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234055.html</guid>
		</item>
		<item>
			<title>C program for arrays</title>
			<link>http://www.daniweb.com/forums/thread234008.html</link>
			<pubDate>Wed, 28 Oct 2009 01:55:58 GMT</pubDate>
			<description><![CDATA[hi im trying to write a C program that produces an array like this 
1,2,4,8,16... 
Basically i produce an array with with the power of 2 starting at 0 and going up to n. Here is my current code: However the array dosent show. What is the problem? 
# include <stdio.h> 
# include "simpio.h" 
#...]]></description>
			<content:encoded><![CDATA[<div>hi im trying to write a C program that produces an array like this<br />
1,2,4,8,16...<br />
Basically i produce an array with with the power of 2 starting at 0 and going up to n. Here is my current code: However the array dosent show. What is the problem?<br />
# include &lt;stdio.h&gt;<br />
# include &quot;simpio.h&quot;<br />
# include &quot;genlib.h&quot;<br />
# include &quot;strlib.h&quot;<br />
# define maxElements 500<br />
 <br />
<br />
main()<br />
{<br />
      int a,b,c,d,e,f,g;<br />
      int nArray[maxElements];<br />
      <br />
      printf(&quot;what is the max amount of 2's you want?&quot;);<br />
      a=GetInteger();<br />
      b=0;<br />
      c=a;<br />
      d=2;<br />
      while(c!=0)<br />
      {<br />
      e=a;<br />
      while(e!=0)<br />
      {<br />
      d=d*2;<br />
      e=e-1;<br />
      printf(&quot;yo&quot;);<br />
      }<br />
      if(e==0)<br />
      {<br />
      d=1;<br />
      a=a-1;<br />
      nArray[b]=d;<br />
      b=b+1;<br />
      c=c-1;<br />
      break;<br />
      }<br />
else<br />
      a=a-1;<br />
      nArray[b]=d;<br />
      b=b+1;<br />
      c=c-1;<br />
      }<br />
      getchar();<br />
}</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>wangatang126</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234008.html</guid>
		</item>
		<item>
			<title>C program for a power function</title>
			<link>http://www.daniweb.com/forums/thread233998.html</link>
			<pubDate>Wed, 28 Oct 2009 00:58:31 GMT</pubDate>
			<description><![CDATA[Can someone help me edit this program. I am a begginer in C and suck at it somewhat. I can't figure out a way to make the function work since i have to initialize s to equal u and if i initialize it in the function it will always make s=u. However if i initialize it in the program s still equals u....]]></description>
			<content:encoded><![CDATA[<div>Can someone help me edit this program. I am a begginer in C and suck at it somewhat. I can't figure out a way to make the function work since i have to initialize s to equal u and if i initialize it in the function it will always make s=u. However if i initialize it in the program s still equals u. I'm lost can someone help me. Here is my code<br />
# include &lt;stdio.h&gt;<br />
# include &quot;simpio.h&quot;<br />
# include &quot;genlib.h&quot;<br />
# include &quot;strlib.h&quot;<br />
<br />
<br />
int power(int num){<br />
int u,v,r,s;<br />
s=s*v;<br />
}<br />
<br />
<br />
main()<br />
{<br />
      int u,v,r,s,pow;<br />
      printf(&quot;whats the base&quot;);<br />
      u=GetInteger();<br />
      printf(&quot;whats the power&quot;);<br />
      v=GetInteger();<br />
      r=v;<br />
      while(r!=0)<br />
      {<br />
      pow=power(s);<br />
      r=r-1;<br />
      }<br />
      if(u==0&amp;&amp;v&lt;0)<br />
      printf(&quot;undefined&quot;);<br />
else<br />
      printf(&quot;the result is %d&quot;,s);<br />
      getchar();<br />
}</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>wangatang126</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread233998.html</guid>
		</item>
		<item>
			<title>string array substitution</title>
			<link>http://www.daniweb.com/forums/thread233970.html</link>
			<pubDate>Tue, 27 Oct 2009 21:30:54 GMT</pubDate>
			<description><![CDATA[N00B. I keep getting a segmentation fault when I try to substitute a word with another. I'm using this tutorial as an example but don't seem to get it right: http://www.cplusplus.com/reference/clibrary/cstring/strstr/ 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>N00B. I keep getting a segmentation fault when I try to substitute a word with another. I'm using this tutorial as an example but don't seem to get it right: <a rel="nofollow" class="t" href="http://www.cplusplus.com/reference/clibrary/cstring/strstr/" target="_blank">http://www.cplusplus.com/reference/c...string/strstr/</a><br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
void REPLACE(char STRING[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char *MONTH[] = {&quot;January&quot;,&quot;February&quot;,&quot;March&quot;,&quot;April&quot;,&quot;May&quot;,&quot;June&quot;,&quot;July&quot;,&quot;August&quot;,&quot;September&quot;,&quot;October&quot;,&quot;November&quot;,&quot;December&quot;};<br />
&nbsp; &nbsp; &nbsp; &nbsp; char *MES[] = {&quot;Enero&quot;,&quot;Febrero&quot;,&quot;Marzo&quot;,&quot;Abril&quot;,&quot;Mayo&quot;,&quot;Junio&quot;,&quot;Julio&quot;,&quot;Agosto&quot;,&quot;Septiembre&quot;,&quot;Octubre&quot;,&quot;Noviembre&quot;,&quot;Diciembre&quot;};<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int B = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(B &lt; 12)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( strstr(STRING, MONTH[B]) )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char *pch;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pch = strstr(STRING, MONTH[B]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strncpy(pch, MES[B], strlen(MES[B]) ); // Segmentation fault<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; puts(STRING);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
int main (void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; REPLACE(&quot;The month is: January.&quot;); // Should be: &quot;The month is: Enero&quot;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>raigs</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread233970.html</guid>
		</item>
		<item>
			<title>Write a function to swap two values using pointers</title>
			<link>http://www.daniweb.com/forums/thread233960.html</link>
			<pubDate>Tue, 27 Oct 2009 20:07:17 GMT</pubDate>
			<description><![CDATA[Hello.  I am a beginner.  I have searched the past threads, but I haven't found any help.  My assignment says to write a function to swap 2 values using pointers.  Write a main function that inputs 2 numbers.  Have it call the swap function if the numbers are NOT in descending order - include a...]]></description>
			<content:encoded><![CDATA[<div>Hello.  I am a beginner.  I have searched the past threads, but I haven't found any help.  My assignment says to write a function to swap 2 values using pointers.  Write a main function that inputs 2 numbers.  Have it call the swap function if the numbers are NOT in descending order - include a loop to allow the user to enter 3 sets of numbers.<br />
<br />
I have been working on this for hours.  The deeper I get, the more I confuse myself.   <br />
<br />
Here's the code that I have.  It is nowhere close to complete.<br />
Can someone please give me some help?   Any help is appreciated!<br />
<br />
#include&lt;stdio.h&gt; <br />
int main()<br />
{<br />
void swap(int *, int *);    //prototype with a pointer parameter<br />
int count;<br />
int num1, num2;<br />
int swapvalue;<br />
int holdScreen; // holdscreen is used to keep the ouput window open<br />
   <br />
   for (count = 1; count &lt;4; count++)  //begin loop<br />
       printf(&quot;Enter the first number -&gt; &quot;);<br />
       scanf(&quot;%d&quot;, &amp;num1);<br />
       printf(&quot;Enter the second number -&gt; &quot;);<br />
       scanf(&quot;%d&quot;, &amp;num2);<br />
   <br />
    if (num1 &lt; num2 )<br />
    {<br />
     swap(&amp;num1, &amp;num2);                //Function Calling Statement    <br />
    }<br />
    else<br />
    printf(&quot;No swap needed&quot;)<br />
    <br />
    printf(&quot;The address that will be passed for num1 is %d\n\n&quot;, &amp;num1);<br />
    printf(&quot;The address that will be passed for num2 is %d\n\n&quot;, &amp;num2);<br />
    count ++<br />
<br />
<br />
   scanf(&quot;%d&quot;, &amp;holdScreen);<br />
   return 0;<br />
}<br />
<br />
void swap(int *num, *num2)    //Function Header Line<br />
{<br />
    <br />
        <br />
}</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>LostnC</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread233960.html</guid>
		</item>
	</channel>
</rss>
