<?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>Sun, 22 Nov 2009 08:38:28 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>dynamic array</title>
			<link>http://www.daniweb.com/forums/thread240385.html</link>
			<pubDate>Sun, 22 Nov 2009 06:52:18 GMT</pubDate>
			<description><![CDATA[I want to make a dynamic array. but when I view the array, I think there's something wrong with the index part. Please help. Thanks! 
 
here's my code: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>I want to make a dynamic array. but when I view the array, I think there's something wrong with the index part. Please help. Thanks!<br />
<br />
here's my code:<br />
 <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
<br />
<br />
main(){<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int* a;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int choice;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int index = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int head;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; while(choice!=4){<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\tMENU\t\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;[1] add number to array\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;[2] view array\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;[3] search using linear search\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;[4] quit program\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, &amp;choice);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch(choice){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 1: head = add(&amp;index, a);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &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; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 2:head = view(&amp;index,a);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //case 3:linsearch(&amp;index,array[5]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 4: return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default: printf(&quot;invalid input!!!\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
}<br />
<br />
&nbsp;int add(int* index, int* a){<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;enter number you want to enter in the array.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, &amp;number);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *a = (int) malloc (5*sizeof(int));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt;= *index; i ++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a[i] = number;<br />
&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; return *index;<br />
}<br />
<br />
&nbsp;view(int* index, int* a){<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i; <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt;= *index; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;index: %d, %d &quot;, *index, a[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return a[5];<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>cmsc</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240385.html</guid>
		</item>
		<item>
			<title>Scheduler</title>
			<link>http://www.daniweb.com/forums/thread240377.html</link>
			<pubDate>Sun, 22 Nov 2009 05:18:36 GMT</pubDate>
			<description>Iam currently working on the design of preemptive scheduler iln Borland C. I want to know about the use of interrupts and timers in Borland C for preempting the task. Just clue of upgrading about them is enough.</description>
			<content:encoded><![CDATA[<div>Iam currently working on the design of preemptive scheduler iln Borland C. I want to know about the use of interrupts and timers in Borland C for preempting the task. Just clue of upgrading about them is enough.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Cmad</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240377.html</guid>
		</item>
		<item>
			<title>How to color some text in Dev C</title>
			<link>http://www.daniweb.com/forums/thread240367.html</link>
			<pubDate>Sun, 22 Nov 2009 03:45:56 GMT</pubDate>
			<description><![CDATA[#include <stdio.h> 
#include <stdlib.h> 
 
#define SIZE 31 
 
int main() 
{ 
     int array[SIZE]={0}; 
     int i,j; 
     int startDay=0,numDays=30;]]></description>
			<content:encoded><![CDATA[<div>#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
#define SIZE 31<br />
<br />
int main()<br />
{<br />
     int array[SIZE]={0};<br />
     int i,j;<br />
     int startDay=0,numDays=30;<br />
     <br />
     printf(&quot;  S   M    T    W    TH    F    S\n&quot;);<br />
     <br />
     for (i=1;i&lt;=1+ startDay*5;i++)<br />
     printf(&quot; &quot;);<br />
     <br />
     for (i= 1; i &lt;= numDays; i++) <br />
     {<br />
               <br />
               printf(&quot;%2d&quot;,i);<br />
               if ((i+startDay)%7 &gt; 0)        <br />
                {    printf(&quot;   &quot;);<br />
                   system(&quot;color 6&quot;);}<br />
                    <br />
               else  <br />
                    printf(&quot;\n &quot;);<br />
     }<br />
     startDay = (startDay + numDays)%7;<br />
     <br />
     <br />
     <br />
            <br />
     <br />
     <br />
     getchar();<br />
     getchar();<br />
}<br />
     <br />
     <br />
I used  <pre style="margin:20px; line-height:13px">system(&quot;color &quot;);</pre> but it will only colorize my enter text...<br />
I only want to colorize the days in Sunday;<br />
<br />
I dont know how to do it...Can anyone teach me please?.,</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>DoEds</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240367.html</guid>
		</item>
		<item>
			<title>Converting long integer Into Array</title>
			<link>http://www.daniweb.com/forums/thread240276.html</link>
			<pubDate>Sat, 21 Nov 2009 17:05:11 GMT</pubDate>
			<description><![CDATA[What I am trying to accomplish here is to split a long integer apart so I can look at its first, last, and center digits. What I am currently using is this: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>What I am trying to accomplish here is to split a long integer apart so I can look at its first, last, and center digits. What I am currently using is this:<br />
<br />
 <pre style="margin:20px; line-height:13px">int main() {<br />
&nbsp; long i, t[1024];<br />
&nbsp; <br />
&nbsp; i = 100;<br />
<br />
&nbsp; while (i &lt; 150) {<br />
&nbsp; &nbsp; t = i; // My attempt at converting the long into an array.<br />
&nbsp; &nbsp; printf(&quot;%ld\n&quot;, t[2]);<br />
&nbsp; &nbsp; i += 1;<br />
&nbsp; }</pre><br />
Any help would be appreciated!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>dieom</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240276.html</guid>
		</item>
		<item>
			<title>FILE stream, syntax in getc</title>
			<link>http://www.daniweb.com/forums/thread240260.html</link>
			<pubDate>Sat, 21 Nov 2009 15:38:39 GMT</pubDate>
			<description><![CDATA[Hi everyone, i have this portion of code 
while(c = getc(file) != EOF) 
c is an int and file is a FILE *file = fopen(filename, "r"); 
 
The filename points to a file with 2 lines, 10 characters total. That while always makes c a value of 1 (accodring to ASCII -> start text, dunno what that mean)....]]></description>
			<content:encoded><![CDATA[<div>Hi everyone, i have this portion of code<br />
 <pre style="margin:20px; line-height:13px">while(c = getc(file) != EOF)</pre><br />
c is an int and file is a FILE *file = fopen(filename, &quot;r&quot;);<br />
<br />
The filename points to a file with 2 lines, 10 characters total. That while always makes c a value of 1 (accodring to ASCII -&gt; start text, dunno what that mean).<br />
But when i use this while:<br />
 <pre style="margin:20px; line-height:13px">while((c = getc(file)) != EOF)</pre><br />
It works perfect. I though that was equivalent...i'm missing something on basic syntax here. What's wrong in the first while?<br />
<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/thread240260.html</guid>
		</item>
		<item>
			<title>char in c?</title>
			<link>http://www.daniweb.com/forums/thread240214.html</link>
			<pubDate>Sat, 21 Nov 2009 10:32:32 GMT</pubDate>
			<description><![CDATA[hi, i am new to c have to write a program to check the shape.  
I think the error is somewhere at shape= square. I know i can use printf statements but i want it in this format. Can someone help me please?  
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>hi, i am new to c have to write a program to check the shape. <br />
I think the error is somewhere at shape= square. I know i can use printf statements but i want it in this format. Can someone help me please? <br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
int main (void)<br />
{<br />
int length,breadth;<br />
char shape;<br />
printf(&quot;Input your length: &quot;);<br />
scanf(&quot;%f&quot;, &amp;length);<br />
printf(&quot;Input your breadth: &quot;);<br />
scanf(&quot;%f&quot;, &amp;breadth);<br />
<br />
if (length=breadth)<br />
&nbsp; &nbsp; &nbsp;  { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shape= 'square';&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;  } <br />
else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shape = 'rectangle'<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
printf(&quot; the length is%d, breadth is %d , hence given shape is %s&quot;, length, breadth, shape);</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>dewdropz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240214.html</guid>
		</item>
		<item>
			<title>Need help to create matrix</title>
			<link>http://www.daniweb.com/forums/thread240250.html</link>
			<pubDate>Sat, 21 Nov 2009 06:54:14 GMT</pubDate>
			<description>I have to create a matrix in c  from microarray data that so I have to read each string line wise and compare they are related or not. help me....*****</description>
			<content:encoded><![CDATA[<div>I have to create a matrix in c  from microarray data that so I have to read each string line wise and compare they are related or not. help me....<span style="font-weight:bold">***</span></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>rahul.nutron</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240250.html</guid>
		</item>
		<item>
			<title>Error in simple C menu</title>
			<link>http://www.daniweb.com/forums/thread240171.html</link>
			<pubDate>Sat, 21 Nov 2009 06:21:58 GMT</pubDate>
			<description><![CDATA[If I run the program, and select q, it will quit correctly.  If I select e it goes to the edit menu *but prints it twice*.  If I then select q it goes to the main menu *and prints the default case, "please select from menu", then prints the main menu again*.  If I select q now, it goes to the *edit...]]></description>
			<content:encoded><![CDATA[<div>If I run the program, and select q, it will quit correctly.  If I select e it goes to the edit menu <span style="font-weight:bold">but prints it twice</span>.  If I then select q it goes to the main menu <span style="font-weight:bold">and prints the default case, &quot;please select from menu&quot;, then prints the main menu again</span>.  If I select q now, it goes to the <span style="font-weight:bold">edit menu</span>, not quitting the program like it did before. So now it's stuck in a loop between main and edit when I select q.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;&nbsp; <br />
#include &lt;stdlib.h&gt;<br />
<br />
void edit(void){<br />
<br />
printf (&quot;\nEDIT MENU\n&quot;);<br />
printf (&quot;&nbsp; (a)Add\n&quot;);<br />
printf (&quot;&nbsp; (p)Display\n&quot;);<br />
printf (&quot;&nbsp; (i)Reutrn\n&quot;);<br />
printf (&quot;&nbsp; (o)Check Out\n&quot;);<br />
printf (&quot;&nbsp; (d)Delete\n&quot;);<br />
printf (&quot;&nbsp; (q)Main Menu\n&quot;);<br />
<br />
<br />
char choice;<br />
scanf (&quot;%c&quot;,&amp;choice); <br />
<br />
switch (choice) {<br />
<br />
case 'a':<br />
&nbsp; system(&quot;./add&quot;);<br />
&nbsp; break;<br />
&nbsp; <br />
<br />
case 'p':<br />
&nbsp; system(&quot;./display&quot;);<br />
&nbsp; break;<br />
<br />
case 'i':<br />
&nbsp; system(&quot;./return&quot;);<br />
&nbsp; break;<br />
<br />
case 'o':<br />
&nbsp; system(&quot;./checkout&quot;);<br />
&nbsp; break;<br />
<br />
case 'd':<br />
&nbsp; system(&quot;./delete&quot;);<br />
&nbsp; break;<br />
<br />
case 'q':<br />
&nbsp; main();<br />
<br />
default:<br />
&nbsp; edit();<br />
<br />
}<br />
<br />
}<br />
<br />
void reports(void)<br />
{<br />
<br />
}<br />
<br />
void add(void)<br />
{<br />
}<br />
<br />
void del(voi)<br />
{<br />
}<br />
<br />
int main(void){<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
printf (&quot;MAIN MENU\n&quot;);<br />
printf (&quot;&nbsp; (e)Edit\n&quot;);<br />
printf (&quot;&nbsp; (r)Reports\n&quot;);<br />
printf (&quot;&nbsp; (q)Quit\n&quot;);<br />
<br />
char choice;<br />
scanf (&quot;%c&quot;,&amp;choice); <br />
<br />
switch (choice) {<br />
&nbsp; case 'e':<br />
&nbsp; edit();<br />
&nbsp; break;<br />
&nbsp; <br />
&nbsp; <br />
&nbsp; case 'r':<br />
&nbsp; reports();<br />
&nbsp; break;<br />
&nbsp; <br />
<br />
&nbsp; case 'q':<br />
&nbsp; break;<br />
<br />
&nbsp; default: <br />
&nbsp; printf(&quot;Choose from the menu\n&quot;);<br />
&nbsp; main();<br />
}<br />
return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Mattpd</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240171.html</guid>
		</item>
		<item>
			<title>how to use the local variable form one function to other function</title>
			<link>http://www.daniweb.com/forums/thread240138.html</link>
			<pubDate>Sat, 21 Nov 2009 02:21:55 GMT</pubDate>
			<description><![CDATA[Here is the problem:write in saparate function without using global variable 
1/(function input)enter N in the range [0,20], then enter N numbers 
2/(function display)Display N numbers in 2 columns 
Here is my source code 
 
#include<stdio.h> 
#include<conio.h> 
void Input(int *p,int n) 
{ 
    int...]]></description>
			<content:encoded><![CDATA[<div>Here is the problem:write in saparate function without using global variable<br />
1/(function input)enter N in the range [0,20], then enter N numbers<br />
2/(function display)Display N numbers in 2 columns<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 />
void Input(int *p,int n)<br />
{<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; do<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp;  printf(&quot;Enter N numbers u want to input: &quot;);<br />
&nbsp; &nbsp;  scanf(&quot;%d&quot;,&amp;n); <br />
&nbsp; &nbsp; }while ( (n&lt;0) || (n&gt;20) );<br />
&nbsp; &nbsp; p =(int *)malloc(n*sizeof(int));<br />
&nbsp; &nbsp; printf(&quot;Ennter %d numbers: &quot;,n);<br />
&nbsp; &nbsp; for( i=0; i&lt;n; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;\nNumber%: &quot;,i);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  scanf(&quot;%d&quot;,p+i);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
}<br />
<br />
void Display(int *p, int n)<br />
{<br />
&nbsp; &nbsp;  int i;<br />
&nbsp; &nbsp;  printf(&quot;test&quot;);<br />
&nbsp; &nbsp;  for( i=0; i&lt;n; i++)<br />
&nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot; %d&quot;,p&#91;i&#93;);&nbsp; <br />
&nbsp; &nbsp;  }<br />
}<br />
<br />
int main()<br />
{<br />
&nbsp; int *a, *N;<br />
&nbsp; Input(a,&amp;N);<br />
&nbsp; Display(a,&amp;N);<br />
&nbsp; getch();<br />
&nbsp; return 0;<br />
}</pre>I don't know how can I use the variable N in function input for the next function.</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/thread240138.html</guid>
		</item>
		<item>
			<title>memcpy with int clears entire buffer</title>
			<link>http://www.daniweb.com/forums/thread240119.html</link>
			<pubDate>Sat, 21 Nov 2009 00:21:09 GMT</pubDate>
			<description>Hi, 
 
I have a char* buffer that is 1024 bytes in size, and am trying to write an int to a particular offset in the buffer, in this case 0, but all offsets have the same problem. 
 
I initialize the buffer to some values when I first start up.  For example, the first 8 bytes contain two separate...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I have a char* buffer that is 1024 bytes in size, and am trying to write an int to a particular offset in the buffer, in this case 0, but all offsets have the same problem.<br />
<br />
I initialize the buffer to some values when I first start up.  For example, the first 8 bytes contain two separate ints, followed by 2 chars.  When I print this out, it shows up as full.<br />
<br />
However, when I try to add another value as shown in the code below, it completely destroys all the other data in the buffer.<br />
<br />
 <pre style="margin:20px; line-height:13px">char* buffer = new char[1024];<br />
<br />
***buffer initialization code***<br />
<br />
int fd = 4;<br />
int bufferOffset = 0;<br />
<br />
memcpy(buffer + bufferOffset, &amp;fd, 4);<br />
<br />
cout &lt;&lt; buffer &lt;&lt; endl;</pre><br />
Does anyone know why this could be happening?  I'm under the impression that the above code should copy the 4 bytes of an int to my buffer, not completely destroy it.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>cmk2901</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240119.html</guid>
		</item>
		<item>
			<title>Pixel Count</title>
			<link>http://www.daniweb.com/forums/thread240064.html</link>
			<pubDate>Fri, 20 Nov 2009 18:44:43 GMT</pubDate>
			<description><![CDATA[The purpose of the program is to take a position and count how many "pixels" are in the "blob". If there is no "pixel" aka the value is 0, the blob number is 0. If there is a pixel, the blob_check function recursively checks the surrounding cells for "pixels" aka values of 1. My program compiles...]]></description>
			<content:encoded><![CDATA[<div>The purpose of the program is to take a position and count how many &quot;pixels&quot; are in the &quot;blob&quot;. If there is no &quot;pixel&quot; aka the value is 0, the blob number is 0. If there is a pixel, the blob_check function recursively checks the surrounding cells for &quot;pixels&quot; aka values of 1. My program compiles but doesn't accurately count the number of pixels in the blob. Please help!<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdlib.h&gt;<br />
#include &lt;stdio.h&gt;<br />
<br />
int blob_check(int tab[][], int x, int y);<br />
<br />
#define N 5<br />
<br />
int main(int argc, char *argv[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int x,y,i,j;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int row=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char line[80];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int table[N][N] = { {1,1,0,0,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; {0,1,1,0,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; {0,0,1,0,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; {1,0,0,0,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; {0,1,0,1,1}};<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\t0\t1\t2\t3\t4\t&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&nbsp;  -----------------------------------------&quot;);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i=0;i&lt;5;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&nbsp;  |\n%d&nbsp; |\t&quot;, i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(j=0;j&lt;5;j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d\t&quot;, table[i][j]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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; printf(&quot;\n\nEnter x-y coordinates of cell&nbsp; =&gt; &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d %d&quot;, &amp;x, &amp;y);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Pixel quantity in blob: %i\n&quot;, blob_check(table, x, y));<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
int blob_check(int pic[N][N], int x, int y)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (pic[x][y] == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pic[x][y] = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int sum = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //check <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (x&gt;0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x-1, y);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y&lt;N-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x-1, y+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (y&lt;N-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x, y+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (x&lt;N-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x+1, y+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (x&lt;N-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x+1, y);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (y&gt;0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x+1, y-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; else if (y&gt;0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x, y-1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (x&gt;0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += blob_check(pic, x-1, y-1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return sum;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>cokacola</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240064.html</guid>
		</item>
		<item>
			<title>C program for to find optimal path</title>
			<link>http://www.daniweb.com/forums/thread240038.html</link>
			<pubDate>Fri, 20 Nov 2009 15:42:07 GMT</pubDate>
			<description>Time limit : 10 secs. (The program must produce output for all test cases within the stipulated time) 
 
A spaceship carrying a convention of high ranking officials had a close shave with a meteor. They are now scattered over the surface over a meteor and the spaceship is beyond repair. 
Fluke...</description>
			<content:encoded><![CDATA[<div>Time limit : 10 secs. (The program must produce output for all test cases within the stipulated time)<br />
<br />
A spaceship carrying a convention of high ranking officials had a close shave with a meteor. They are now scattered over the surface over a meteor and the spaceship is beyond repair.<br />
Fluke LandCrawler was an emergency replacement for a space rescue mission in the distant galaxy Alfa-Bentauri. You are KHAL – the computer on the land-Rover carrying Fluke. He needs to rescue as many survivors as possible but can’t figure out the best path. Fluke lied about his CompSc. Degree to get in to SpaceTravel Inc; he is banking on you to save his job. <br />
Just to make things worse, Fluke’s shuttle was designed by Elbonians and not tested before being deployed due to this unforeseen emergency. You now find that the “Back”, “Left”, “Right” and “Fwd” buttons on the shuttle are unintuitive to say the least: <br />
e.g. if Fluke’s Rover is in the slot marked as FL below  (facing east), there are 4 possible slots that he can move to (shown in Blue). In short, it can not move back (towards the west) and is always facing east. He can only rescue people by moving to the slot that they are standing in.<br />
 <br />
<br />
Each survivor of the crash has a rank R (1&lt;= R &lt;= 5) e.g. some are Chancellors Rank5 and at the other end of the spectrum are Guards Rank1. <br />
Determine the optimal path – that can <br />
-	 save a group of people with the maximum total rank. High ranking officials are key to maintaining peace across various factions in the federation. Guards are sworn to protect them and will stay behind if required.<br />
-	If you have one optimal path, you should tell Fluke the command seq for the same. If more than one path is optimal, you should tell Fluke all the possible command seq and let him decide<br />
-	Time is of the essence – it is critical that the people be rescued as quickly as possible. <br />
<br />
Input<br />
-	The first line contains n where n is the side of the square grid on which the rover will move. 4 &lt;= n &lt;= 100. Top-left co-ordinate is (0,0) and bottom right co-ordinate is (n-1, n-1)<br />
-	The next line is the number of test cases n (2 in the example below) that follow (&lt; 5). Each test case is comprised of a number of lines.<br />
o	The first line of the test case contains the position where the space rover is beamed down/placed initially (facing east).<br />
o	The next line contains the number of survivors, k.<br />
	This is followed by k lines, each having 3 integers relevant to each survivor. E.g. 1 3 5 indicates that there is a survivor at (1,3) and has Rank 5.<br />
<br />
4<br />
2<br />
0 1<br />
4<br />
1 3 5<br />
2 0 5<br />
2 2 1<br />
3 2 3<br />
0 1<br />
5<br />
1 3 5<br />
2 0 5<br />
2 2 5<br />
3 0 5<br />
3 2 3<br />
<br />
<br />
The test cases represent the following scenarios respectively.<br />
   					 <br />
<br />
Output<br />
You should print out the results to console (via printf or equivalent) <br />
For each test case, output the maximum cumulative rank of people you can save as the first line. That is to be followed by the command seq (1 or multiple) for the path(s) – See the example below.<br />
8 <br />
LB<br />
BL<br />
10 <br />
RF<br />
<br />
Explanation:<br />
<br />
     <br />
<br />
Rules:<br />
•	Your program must accept a string as a command line argument. It should then proceed to open the file of that name in the same/current directory, which contains one or more test cases. Output should be printed to console via printf (or equivalent).<br />
•	The program will not expect any user input. Please test your program for compile / run time errors before submitting.<br />
•	You may submit multiple submissions – strive for solutions that are elegant, memory and time efficient.<br />
•	The time limit if specified is for all the test cases to be executed; the time limit is NOT per test case</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/doc.gif" alt="File Type: doc" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12648&amp;d=1258731651">BIQ-004-KHAL_222.doc</a> (50.5 KB)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>kirtics344</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240038.html</guid>
		</item>
		<item>
			<title>Interesting C program for Accelerator</title>
			<link>http://www.daniweb.com/forums/thread240036.html</link>
			<pubDate>Fri, 20 Nov 2009 15:33:44 GMT</pubDate>
			<description>You’ve been given an assorted set of gears. Each gear has a different number of teeth – the notches on a gear that interlock with notches on another gear to transmit speed. You have a couple of belts one coupled to an input and the other for the output. You are given the rpm of the input belt Si...</description>
			<content:encoded><![CDATA[<div>You’ve been given an assorted set of gears. Each gear has a different number of teeth – the notches on a gear that interlock with notches on another gear to transmit speed. You have a couple of belts one coupled to an input and the other for the output. You are given the rpm of the input belt Si and a minimum value So (where So &gt; Si) so that you can increase the speed via a system of gears as shown above<br />
You need to figure out all the possible pairs of gears that can be used to achieve an output rpm &gt;= So.<br />
Input<br />
The input is specified in a file containing test-cases.<br />
•	The first line contains the number of gears that are available to you, g.<br />
•	The next line contains g numbers indicating the number of teeth on each gear, separated by spaces.<br />
•	The next line contains the number of test cases – n<br />
o	This is followed by n test cases. Each test case is specified by 2 speed values on a single line. (So here the first test case specifies that you need to design a gear-system that increases Si = 50 rpm to a value above 200 rpm)<br />
7<br />
20 10 4 6 40 25 100<br />
2<br />
50 200<br />
35 75<br />
<br />
Output<br />
9<br />
15<br />
<br />
E.g. for raising the speed from 50 to 200, any of the following 9 pairs can be used<br />
 [100, 6] [40, 6] [25, 6] [25, 4] [20, 4] [40, 4] [100, 4] [100, 20] [100, 10]<br />
<br />
Rules :<br />
•	Your program must accept a string as a command line argument. It should then proceed to open the file of that name in the same/current directory, which contains one or more test cases. Output should be printed to console via printf (or equivalent).<br />
•	The program will not expect any user input. Please test your program for compile / run time errors before submitting.<br />
•	You may submit multiple submissions – strive for solutions that are elegant, memory and time efficient.<br />
•	The time limit if specified is for all the test cases to be executed; the time limit is NOT per test case<br />
* We would compile your program into an executable and run it (e.g. c:\&gt;X.exe TestCases.txt)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>kirtics344</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240036.html</guid>
		</item>
		<item>
			<title>How to create a dynamic array in recursion?</title>
			<link>http://www.daniweb.com/forums/thread240008.html</link>
			<pubDate>Fri, 20 Nov 2009 12:55:13 GMT</pubDate>
			<description>Hi all. Just a simple question but I SERIOUSLY need some help from you guys for my programming assignment. 
 
The assignment given was water jug problem.  
 
Now my question is, does C allow for the creation of dynamic array during a recursion?  
Suppose I have another function, which returns a...</description>
			<content:encoded><![CDATA[<div>Hi all. Just a simple question but I SERIOUSLY need some help from you guys for my programming assignment.<br />
<br />
The assignment given was water jug problem. <br />
<br />
Now my question is, does C allow for the creation of dynamic array during a recursion? <br />
Suppose I have another function, which returns a value (well in my case the function returns a character), and I'm gonna store the character into a dynamic array(which in the current function). This means that the dynamic array is constantly &quot;enlarged&quot; as long as another function returns a value to the current function where the dynamic array is located. If the other function stops returning a value, the whole process stops.<br />
<br />
Thanks in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>beatenbob</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240008.html</guid>
		</item>
		<item>
			<title><![CDATA[Standards & Implementations]]></title>
			<link>http://www.daniweb.com/forums/thread239967.html</link>
			<pubDate>Fri, 20 Nov 2009 08:56:56 GMT</pubDate>
			<description>Hi ,  
this one is with respect to C. 
(i) 
when we use array an array index always starts from zero . 
is it a standard one? or compilers are implemented that way? 
if compilers are implented that way they must have followed some standard. 
(ii) 
the array name cannot be changed is it the standard...</description>
			<content:encoded><![CDATA[<div>Hi , <br />
this one is with respect to C.<br />
(i)<br />
when we use array an array index always starts from zero .<br />
is it a standard one? or compilers are implemented that way?<br />
if compilers are implented that way they must have followed some standard.<br />
(ii)<br />
the array name cannot be changed is it the standard or compiler dependent.<br />
<br />
i have never heard that array index starts from 1 and base address can be changed.<br />
<br />
Thanks,<br />
Danian</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/thread239967.html</guid>
		</item>
		<item>
			<title>errors in C program..plz help</title>
			<link>http://www.daniweb.com/forums/thread239931.html</link>
			<pubDate>Fri, 20 Nov 2009 05:57:06 GMT</pubDate>
			<description><![CDATA[Hi, 
I am new to this site. 
Can you please help me with this. I have written a C program and i m getting the following errors 
1)  "  'puts' was not declared in scope   " 
the same error for 'gets' and 'itoa' command...i have included stdio.h,string.h,stdlib.h,math.h  as the header files 
2)"...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
I am new to this site.<br />
Can you please help me with this. I have written a C program and i m getting the following errors<br />
1)  &quot;  'puts' was not declared in scope   &quot;<br />
the same error for 'gets' and 'itoa' command...i have included stdio.h,string.h,stdlib.h,math.h  as the header files<br />
2)&quot; expected constructor , destructor or type conversion before '=' token &quot;    ......for the code k=1.92 ....i have declared 'k' as a float<br />
3) expected ',' before '}' token<br />
<br />
kindly clear my queries<br />
Thank you,<br />
sahasra.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>sahasra</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239931.html</guid>
		</item>
		<item>
			<title>A challenging problem in Recursion</title>
			<link>http://www.daniweb.com/forums/thread239918.html</link>
			<pubDate>Fri, 20 Nov 2009 04:30:08 GMT</pubDate>
			<description><![CDATA[At least for me it is:) 
This is an assignment problem and I can really use some help! 
 
*_INTRO TO PROBLEM:_* 
So the problem is a basic logic problem, where I'm sure you're all familiar with... 
From my assignment page, the problem 
  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>At least for me it is:)<br />
This is an assignment problem and I can really use some help!<br />
<br />
<span style="font-weight:bold"><span style="text-decoration:underline">INTRO TO PROBLEM:</span></span><br />
So the problem is a basic logic problem, where I'm sure you're all familiar with...<br />
From my assignment page, the problem<br />
 <pre style="margin:20px; line-height:13px">Imagine that you have 2 jugs, a small one and a large one, with integer capacities of sCap<br />
and lCap gallons, respectively (sCap &lt; lCap). Initially both jugs are empty. You are<br />
allowed to completely fill each jug from a tap, or empty them on the ground. You can also<br />
pour one jug into the other: pouring stops when either the receiving jug is full or no water is left<br />
in the pouring jug (i.e. no water is spilled). Note that each pouring action will cause a positive<br />
number of whole gallons to be transferred.<br />
Given two integer values sFinal and lFinal, the problem is to find a valid sequence<br />
of actions such that after performing the actions, the small and large jugs contain exactly<br />
sFinal and lFinal gallons of water, respectively.</pre><br />
<span style="text-decoration:underline"><span style="font-weight:bold">WHAT I NEED HELP ON</span></span><br />
Basically I have a few functions that are ready to be used...<br />
I will attach a .c file at the end of this post for the code...<br />
I took a long time checking over this post and adding comments, any sort of help on recursion is appreciated...<br />
I just don't understand how to start this recursion<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;stdbool.h&gt;<br />
#include &lt;math.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
char&nbsp; *solve(const char curSequence[], int sCur, int lCur, int sCap, int lCap, int sFinal, int lFinal);<br />
void prettyPrint(const char solution[], int sCap, int lCap);<br />
bool actionIsPossible(char action, int sCur, int lCur, int sCap, int lCap);<br />
void getUpdatedJugsAmounts(char action, int sCur, int lCur, int sCap, int lCap, int *sUpdated, int *lUpdated);<br />
bool occurs(const char curSequence[], int sVal, int lVal, int sCap, int lCap);<br />
bool applyAction(char action, const char curSequence[], int sCur, int lCur, int sCap, int lCap, char updatedSequence[], int *sUpdated, int *lUpdated);<br />
<br />
//a testing main method that was given<br />
int main(int argc, char *argv[])<br />
{<br />
&nbsp; int sCap, lCap, sFinal, lFinal;<br />
&nbsp; if (argc &lt; 5)<br />
&nbsp; {<br />
&nbsp; &nbsp; printf(&quot;Usage: jugs smallCapacity largeCapacity smallFinal largeFinal\n&quot;);<br />
&nbsp; &nbsp; return 0;<br />
&nbsp; }<br />
&nbsp; sCap = atoi(argv[1]);<br />
&nbsp; lCap = atoi(argv[2]);<br />
&nbsp; sFinal = atoi(argv[3]);<br />
&nbsp; lFinal = atoi(argv[4]);*/<br />
<br />
&nbsp; char *solution;<br />
&nbsp; solution =&nbsp; solve(&quot;&quot;, 0, 0, 3, 4, 0, 2);<br />
&nbsp; printf(&quot;The solution is: %s\n&quot;, solution);<br />
&nbsp; if (strcmp(solution, &quot;Not Found&quot;) != 0)<br />
&nbsp; &nbsp;  prettyPrint(solution, sCap, lCap);<br />
<br />
&nbsp; free(solution);<br />
&nbsp; return 0;<br />
}<br />
//This is the function I'm having trouble with...<br />
//Basically this function should follow this idea<br />
////////////////////////////////////////////////////////////////////////<br />
/*char *solve(curSequence, curConfig, capacities, finalConfig)<br />
//&nbsp; &nbsp; &nbsp; &nbsp; if the current configuration == the final configuration then<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; it means that no further action is needed so simply<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; allocate space and return a copy of curSequence as the solution<br />
//&nbsp; &nbsp; &nbsp; &nbsp; else<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pick one of the 6 actions and apply it to the curConfig<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (you may want to call applyAction)<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if the action is applicable (i.e. it is possible and it<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; does not create a cycle) and a recursive call to<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; solve(updatedSequence, updatedConfig, capacities, finalConfig)<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returns a solution then return this solution<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; otherwise clean up any dynamically allocated spaces and if any<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; un-tried action is left, then try it (as above)<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if no more action is left to try then<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; allocate space and return the string &quot;Not Found&quot;.8?*/<br />
//////////////////////////////////////////////////////////////////////<br />
///////////////////my crappy recursion////////////////////////////////<br />
char *solve(const char curSequence[], int sCur, int lCur, int sCap, int lCap, int sFinal, int lFinal){<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (sCur == sFinal &amp;&amp; lCur == lFinal) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; curSequence[i] != '\0'; i++);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char *solution = (char *)malloc(i*sizeof(char *));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(solution,curSequence);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return solution;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char *solution = (char *)malloc(sizeof(char *));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;here\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char *curAct = (char *) malloc (sizeof(char *));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char god[] = {'f', 'F', 'p', 'P', 'e', 'E'};<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; 6; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(applyAction(god[i], solution, sCur, lCur, sCap, lCap, curAct, &amp;sCur, &amp;lCur)){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; curAct = solve(solution, sCur, lCur, sCap, lCap, sFinal, lFinal);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;recur\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; free(curAct);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcat(solution,curAct);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return solution;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  solution = (char *)malloc(sizeof(char)*(strlen(&quot;Not Found&quot;) + 1));<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcpy(solution,&quot;Not Found&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return solution;<br />
}<br />
//A simple print method in the format &lt;S0, L0&gt; A1 &lt;S1, L1&gt; so on<br />
void prettyPrint(const char curSequence[], int sCap, int lCap){<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i, j = strlen(curSequence)+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int s = 0, l = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i = 0 ; i &lt; j; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;&lt;%d,%d&gt; &quot;, s, l);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getUpdatedJugsAmounts(curSequence[i], s, l, sCap, lCap, &amp;s, &amp;l);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%c &quot;, curSequence[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
//There are certain restrictions on which action is possible at a given configuration<br />
//returns true if possible, false otherwise<br />
bool actionIsPossible(char action, int sCur, int lCur, int sCap, int lCap){<br />
&nbsp; &nbsp; bool final = false;<br />
&nbsp; &nbsp; if (action == 'f' &amp;&amp; sCur &lt; sCap){final = true;} //the small jug is not already full<br />
&nbsp; &nbsp; else if (action == 'F' &amp;&amp; lCur &lt; lCap){final = true;} //the big jug is not already full<br />
&nbsp; &nbsp; else if (action == 'p' &amp;&amp; sCur &gt; 0 &amp;&amp; lCur &lt; lCap){final = true;} //the small jug is not empty AND the big jug is not full<br />
&nbsp; &nbsp; else if (action == 'P' &amp;&amp; lCur &gt; 0 &amp;&amp; sCur &lt; sCap){final = true;} //the big jug is not empty AND the small jug is not full<br />
&nbsp; &nbsp; else if (action == 'e' &amp;&amp; sCur &gt; 0){final = true;} //the small jug is not already empty<br />
&nbsp; &nbsp; else if (action == 'E' &amp;&amp; lCur &gt; 0){final = true;} //the big jug is not already empty <br />
&nbsp; &nbsp; return final;<br />
}<br />
//calculated the new amounts and returns them through pointers<br />
void getUpdatedJugsAmounts(char action, int sCur, int lCur, int sCap, int lCap, int *sUpdated, int *lUpdated){<br />
&nbsp; &nbsp; *sUpdated = sCur; *lUpdated = lCur;<br />
&nbsp; &nbsp; if (action == 'f'){*sUpdated = sCap;}<br />
&nbsp; &nbsp; else if (action == 'F'){*lUpdated = lCap;}<br />
&nbsp; &nbsp; else if (action == 'p'){for (; lCur &lt; lCap &amp;&amp; sCur &gt; 0; sCur--, lCur++);*sUpdated = sCur; *lUpdated = lCur;}<br />
&nbsp; &nbsp; else if (action == 'P'){for (; sCur &lt; sCap &amp;&amp; lCur &gt; 0; lCur--, sCur++);*sUpdated = sCur; *lUpdated = lCur;}<br />
&nbsp; &nbsp; else if (action == 'e'){*sUpdated = 0;}<br />
&nbsp; &nbsp; else if (action == 'E'){*lUpdated = 0;}<br />
}<br />
//If the given sequence does not for a repeated config/cycle<br />
//ie: if you start wiht &lt;0,0&gt; and perform PP on sCap = 3 lCap = 4, first &lt;0,4&gt; then &lt;0,4&gt;, which gives u a repeated configuration...<br />
//returns true if there is a repeated config, false otherwise<br />
bool occurs(const char curSequence[], int sVal, int lVal, int sCap, int lCap){<br />
&nbsp; &nbsp; int i, j = strlen(curSequence)+1;<br />
&nbsp; &nbsp; int sCur = 0, lCur = 0;<br />
&nbsp; &nbsp; bool final = false;<br />
&nbsp; &nbsp; if (sVal == 0 &amp;&amp; lVal == 0){final = true;}<br />
&nbsp; &nbsp; for (i = 0; i &lt; j ; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp;  //printf(&quot;%d = %d %d = %d\n&quot;,sCur,sVal,lCur,lVal);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (actionIsPossible(curSequence[i], sCur, lCur, sCap, lCap)){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getUpdatedJugsAmounts(curSequence[i], sCur, lCur, sCap, lCap, &amp;sCur, &amp;lCur);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (sCur == sVal &amp;&amp; lCur == lVal){final = true;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
&nbsp; &nbsp; return final;<br />
}<br />
//apply the action, update the sequence with the new action, and pass the new values back with points and the updated sequence with the array.<br />
//return true if the action is possible and does not cycle, false otherwise<br />
bool applyAction(char action, const char curSequence[], int sCur, int lCur, int sCap, int lCap, char updatedSequence[], int *sUpdated, int *lUpdated){<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool final = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcpy(updatedSequence,curSequence);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int s = 0, l = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; const char act[2] = {action};<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (actionIsPossible(action, sCur, lCur, sCap, lCap)){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getUpdatedJugsAmounts(action, sCur, lCur, sCap, lCap, &amp;s, &amp;l);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!occurs(curSequence, sCur, lCur, sCap, lCap)){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *sUpdated = s;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *lUpdated = l;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; updatedSequence = strcat(updatedSequence,act);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; final = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return final;<br />
}</pre><br />
Thank you 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/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=12643&amp;d=1258691334">Waterjugs.c</a> (6.7 KB)</td> </tr> </table> </fieldset>  </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/thread239918.html</guid>
		</item>
		<item>
			<title>round robin</title>
			<link>http://www.daniweb.com/forums/thread239917.html</link>
			<pubDate>Fri, 20 Nov 2009 04:25:11 GMT</pubDate>
			<description>i want program for round robin in c</description>
			<content:encoded><![CDATA[<div>i want program for round robin in c</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>lathachowdary</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239917.html</guid>
		</item>
		<item>
			<title><![CDATA[left operand of -> has incompatible type]]></title>
			<link>http://www.daniweb.com/forums/thread239850.html</link>
			<pubDate>Thu, 19 Nov 2009 21:40:32 GMT</pubDate>
			<description><![CDATA[Hello  
 
Im trying to compile the following code but I get the error "left operand has incompatible type" because of the line:  
 
 test2_2_U->Out2=  test2_2_U->Out3; 
 
I have been looking through the forum but I couldnt find a hint what Im doing wrong. Any hint is appreciated.  
 
Thanks Thomas]]></description>
			<content:encoded><![CDATA[<div>Hello <br />
<br />
Im trying to compile the following code but I get the error &quot;left operand has incompatible type&quot; because of the line: <br />
<br />
 test2_2_U-&gt;Out2=  test2_2_U-&gt;Out3;<br />
<br />
I have been looking through the forum but I couldnt find a hint what Im doing wrong. Any hint is appreciated. <br />
<br />
Thanks Thomas<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">static BlockIO_test2_2 test2_2_B;&nbsp; &nbsp; &nbsp; /* Observable signals */<br />
static D_Work_test2_2 test2_2_DWork;&nbsp;  /* Observable states */<br />
static ExternalInputs_test2_2 test2_2_U;/* External inputs */<br />
static ExternalOutputs_test2_2 test2_2_Y;/* External outputs */<br />
<br />
void rt_OneStep(RT_MODEL_test2_2 *test2_2_M)<br />
{<br />
&nbsp;<br />
&nbsp;test2_2_step(&amp;test2_2_B, &amp;test2_2_DWork, &amp;test2_2_U, &amp;test2_2_Y);<br />
&nbsp;test2_2_Y-&gt;Out2=&nbsp; test2_2_Y-&gt;Out3;<br />
<br />
}</pre><br />
where test2_2_U is defined as: <br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
&nbsp;  66&nbsp;  typedef struct {<br />
&nbsp;  67&nbsp; &nbsp;  real_T Out1_f;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  /* '&lt;Root&gt;/Out1' */<br />
&nbsp;  68&nbsp; &nbsp;  real_T Out2;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  /* '&lt;Root&gt;/Out2' */<br />
&nbsp;  69&nbsp; &nbsp;  real_T Out3;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  /* '&lt;Root&gt;/Out3' */<br />
&nbsp;  70&nbsp; &nbsp;  real_T Out4;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  /* '&lt;Root&gt;/Out4' */<br />
&nbsp;  71&nbsp;  } ExternalOutputs_test2_2;<br />
&nbsp;  72</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>agentmusic</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239850.html</guid>
		</item>
		<item>
			<title>Problem with permuting bits</title>
			<link>http://www.daniweb.com/forums/thread239843.html</link>
			<pubDate>Thu, 19 Nov 2009 20:44:04 GMT</pubDate>
			<description><![CDATA[I am having a slight problem implementing this code.  What I need to do is take a list of 16 unsigned characters and permute the bits according to IPTable.  0 in IPTable refers to bit 0, 1 refers to bit 1, etc.  Here is my code which isn't working. 
 
 
unsigned char IPTable[128] = {0, 32, 64, 96,...]]></description>
			<content:encoded><![CDATA[<div>I am having a slight problem implementing this code.  What I need to do is take a list of 16 unsigned characters and permute the bits according to IPTable.  0 in IPTable refers to bit 0, 1 refers to bit 1, etc.  Here is my code which isn't working.<br />
<br />
 <pre style="margin:20px; line-height:13px">unsigned char IPTable&#91;128&#93; = {0, 32, 64, 96, 1, 33, 65, 97, 2, 34, 66, 98, 3, 35, 67, 99, 4, 36, 68, 100, 5, 37, 69, 101, 6, 38, 70, 102, 7, 39, 71, 103, 8, 40, 72, 104, 9, 41, 73, 105, 10, 42, 74, 106, 11, 43, 75, 107, 12, 44, 76, 108, 13, 45, 77, 109, 14, 46, 78, 110, 15, 47, 79, 111, 16, 48, 80, 112, 17, 49, 81, 113, 18, 50, 82, 114, 19, 51, 83, 115, 20, 52, 84, 116, 21, 53, 85, 117, 22, 54, 86, 118, 23, 55, 87, 119, 24, 56, 88, 120, 25, 57, 89, 121, 26, 58, 90, 122, 27, 59, 91, 123, 28, 60, 92, 124, 29, 61, 93, 125, 30, 62, 94, 126, 31, 63, 95, 127};<br />
<br />
void IP(unsigned char * input, unsigned char * output)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; unsigned char i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; 128; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output&#91;i / 8&#93; ^= (128 &gt;&gt; (IPTable&#91;i&#93; % 8)) &amp; input&#91;IPTable&#91;i&#93;&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</pre>Thanks for the help.  By the way this code definitely won't work if output isn't set to all zeroes, I already know that and that isn't the error.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>kolosick.m188</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239843.html</guid>
		</item>
		<item>
			<title>shell programming in c</title>
			<link>http://www.daniweb.com/forums/thread239817.html</link>
			<pubDate>Thu, 19 Nov 2009 18:09:39 GMT</pubDate>
			<description><![CDATA[hi 
please can any one help me in my shell project 
like this : 
 
Develop a c program which serve as s shell interface that accepts user command and then executes each command in separate process. The shell interface provides a command prompt ( sh> ) after which next command is entered .  
 
 ...]]></description>
			<content:encoded><![CDATA[<div>hi<br />
please can any one help me in my shell project<br />
like this :<br />
<br />
Develop a c program which serve as s shell interface that accepts user command and then executes each command in separate process. The shell interface provides a command prompt ( sh&gt; ) after which next command is entered . <br />
<br />
 <pre style="margin:20px; line-height:13px">#define TRUE 1 <br />
<br />
while(TRUE){ //repeat forever <br />
&nbsp; type_prompt(); //display prompt on the screen <br />
&nbsp; read_command (command, parameters); //read input from terminal <br />
&nbsp; if(fork()!=0){ //fork off child process <br />
&nbsp; waitpid(‐1, &amp;status, 0); //wait for child to exit <br />
&nbsp; } <br />
else{ <br />
&nbsp; execve(command, parameters, 0); //execute command <br />
&nbsp; } <br />
}</pre><br />
 <br />
Write a shell that is similar to the above code snippet, but contains enough code that it actually works so you can test it. You may also add some features such as redirection of in input and output, pipes, and background jobs. <br />
If the user entered “&amp; “ at the end of his/her command, then the process (command) will be executed in the background and the shell WILL Not WAIT It To Terminate. <br />
You can experience background process yourself by trying the following command on bash shell. <br />
&gt; kwrite <br />
The kwrite application will be run, and the shell prompt will not prompt a user until you terminate kwrite. On the contrary, if you tried the following command, the prompt will return to the user to accept other commands while kwrite (child process) is running in the background!<br />
 please</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>dena</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239817.html</guid>
		</item>
		<item>
			<title>Code Snippet Linked List</title>
			<link>http://www.daniweb.com/code/snippet239653.html</link>
			<pubDate>Thu, 19 Nov 2009 05:52:48 GMT</pubDate>
			<description><![CDATA[*This is just a linked list program for those who need help understanding the fundamentals. Put comments if you find some bugs. 
The program is about maintaining a student database (their roll number and their age) 
I've used Turbo C++ 4.5 as the compiler* 
 
:icon_cool:]]></description>
			<content:encoded><![CDATA[<div><span style="font-weight:bold">This is just a linked list program for those who need help understanding the fundamentals. Put comments if you find some bugs.<br />
The program is about maintaining a student database (their roll number and their age)<br />
I've used Turbo C++ 4.5 as the compiler</span><br />
<br />
:icon_cool:</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>xavier666</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239653.html</guid>
		</item>
		<item>
			<title>Comparing different lines in a file</title>
			<link>http://www.daniweb.com/forums/thread239641.html</link>
			<pubDate>Thu, 19 Nov 2009 04:31:55 GMT</pubDate>
			<description>Hello, 
If I want to say compare a line at a given line number to another line at a different given line number how can I do this? I know I could iterate through the file and store the lines into a data structure and perform comparisons that way but the file is very large and was wondering how I...</description>
			<content:encoded><![CDATA[<div>Hello,<br />
If I want to say compare a line at a given line number to another line at a different given line number how can I do this? I know I could iterate through the file and store the lines into a data structure and perform comparisons that way but the file is very large and was wondering how I could avoid that without taking up more memory? Or any other thoughts, thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>flipjoebanana</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239641.html</guid>
		</item>
		<item>
			<title>help with adding primes</title>
			<link>http://www.daniweb.com/forums/thread239629.html</link>
			<pubDate>Thu, 19 Nov 2009 03:23:39 GMT</pubDate>
			<description><![CDATA[now I have never posted before so I hope this is in the right spot/format.. 
 
this problem is driving me insane. I need prove the Goldbach conjecture that is, "every even integer n > 2 is equal to the sum of 2 prime numbers." Then with a starting point and ending point prove this. (Ei: start at 2...]]></description>
			<content:encoded><![CDATA[<div>now I have never posted before so I hope this is in the right spot/format..<br />
<br />
this problem is driving me insane. I need prove the Goldbach conjecture that is, &quot;every even integer n &gt; 2 is equal to the sum of 2 prime numbers.&quot; Then with a starting point and ending point prove this. (Ei: start at 2 end at 10 =&gt; 2 = 1 +1, 4 = 1 + 3....10 = 5 + 5)<br />
<br />
The problem that I have is that I cant seem to figure out what is wrong with my code. When I run it the loop jumps over some intervals that it couldn't find a prime for and I just don't really know how to fix this as well as making the intervals go up 2 instead of 1 without a syntax error.<br />
<br />
now this is what I have so far...<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;time.h&gt;<br />
<br />
<br />
/* function to create a random number */<br />
<br />
int randomInteger(int low, int high)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; static short firstRun = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int offset;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(firstRun)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //If this is the first call to this procedure, randomize the seed<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; srand(time(NULL));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //and set first run to 0 so we know its&nbsp; been run<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; firstRun = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; offset = low;<br />
&nbsp; &nbsp; &nbsp; &nbsp; low = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; high -=offset;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return ((rand()%high)+offset);<br />
}<br />
<br />
<br />
/* function to see if a number is prime */<br />
<br />
int prime_check(int num)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int check = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i=1;i&lt;=num;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(num % i == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; check = check +1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(check == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* printf(&quot;number is prime\n&quot;); */<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; /*printf(&quot;number is not prime\n&quot;);*/<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
<br />
<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int a,b,i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int prime1, prime2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int start = 2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int end = 20;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i = start; i &lt;= end; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prime1 = randomInteger(1,i);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a = prime_check(prime1);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(a==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prime2 = (i - prime1);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b = prime_check(prime2);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(b==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d = %d + %d\n&quot;, i, prime1, prime2);<br />
<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; randomInteger(1,i);<br />
&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; randomInteger(1,i);<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*lets me see what numbers the program skipped*/<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d\n&quot;, i);<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre><br />
when I compile and run it I get something that looks like this...<br />
<br />
2<br />
3<br />
4 = 2 +2<br />
5 = 3 +2<br />
6<br />
7 = 5 + 2<br />
8 = 5 + 3<br />
9<br />
10 = 5 +5<br />
11<br />
12<br />
13<br />
14 = 7 +7<br />
15 <br />
16<br />
17<br />
18 = 5 + 13<br />
19 = 17 + 2<br />
20</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>eskaflowne</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239629.html</guid>
		</item>
		<item>
			<title>Hash and Rehash</title>
			<link>http://www.daniweb.com/forums/thread239608.html</link>
			<pubDate>Thu, 19 Nov 2009 01:32:49 GMT</pubDate>
			<description>I have been working on a basic accounting program, the accounts were supposed to be stored in a array, but I never got that part of the program working.  Is there anyway I can get a sample of hash code that would help me understand what I need to do?  In my case, I am trying to get the account...</description>
			<content:encoded><![CDATA[<div>I have been working on a basic accounting program, the accounts were supposed to be stored in a array, but I never got that part of the program working.  Is there anyway I can get a sample of hash code that would help me understand what I need to do?  In my case, I am trying to get the account numbers to be stored in the hash array (that's how he worded it in class).  I have searched through my book for the class and I did not find anything about hashing.  <br />
<br />
Any tips, tricks, or code sample would be appreciated.  <br />
<br />
Thanks in advance!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>MeBjess</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239608.html</guid>
		</item>
		<item>
			<title>decimal to binary, palindrome!</title>
			<link>http://www.daniweb.com/forums/thread239589.html</link>
			<pubDate>Wed, 18 Nov 2009 22:58:27 GMT</pubDate>
			<description><![CDATA[hi all!!,  
 
can somebody help me?? 
 
I need to do a program that scan a decimal, transform it to binary and check if it is palindrome or not and print "palidrome" or "not palindrome".... 
 
i can only use functions and cant use arrays or anything else! 
 
can somebody help me??? 
these week i...]]></description>
			<content:encoded><![CDATA[<div>hi all!!, <br />
<br />
can somebody help me??<br />
<br />
I need to do a program that scan a decimal, transform it to binary and check if it is palindrome or not and print &quot;palidrome&quot; or &quot;not palindrome&quot;....<br />
<br />
i can only use functions and cant use arrays or anything else!<br />
<br />
can somebody help me???<br />
these week i got really sick and i need to give that in and im blank!!... help!<br />
<br />
thanx</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>lisedaton</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239589.html</guid>
		</item>
		<item>
			<title>read a string input</title>
			<link>http://www.daniweb.com/forums/thread239551.html</link>
			<pubDate>Wed, 18 Nov 2009 20:36:21 GMT</pubDate>
			<description><![CDATA[Hi, 
I want to make a program that reads a string.  
But I would like to read only characters, neither numbers nor special characters(@,#$%^&*()!). Also, no spaces between characters. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
I want to make a program that reads a string. <br />
But I would like to read only characters, neither numbers nor special characters(@,#$%^&amp;*()!). Also, no spaces between characters.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
char *enter_a_string(int maxcharacters)<br />
{<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; char *ptr;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int len;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Enter string : &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; char array[50];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s&quot;,array);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; len = strlen(array);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(len &gt; maxcharacters)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Maximum %d&nbsp; characters. Try again : &quot;,maxcharacters);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }while(len &gt; maxcharacters);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ptr = array;<br />
<br />
return ptr;<br />
}<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char array[50];<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcpy(array,get_personal_elements(15));<br />
}</pre><br />
Could someone help me please?<br />
Thanks a lot</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>bufospro</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239551.html</guid>
		</item>
		<item>
			<title>simple string problem</title>
			<link>http://www.daniweb.com/forums/thread239517.html</link>
			<pubDate>Wed, 18 Nov 2009 17:51:07 GMT</pubDate>
			<description>So everything in my program works except for the main itself.  The program is supposed to take in a file provided through standard input and print out the descending order of words followed by the frequency that they occur.  I can do this individually line for line but am having trouble putting it...</description>
			<content:encoded><![CDATA[<div>So everything in my program works except for the main itself.  The program is supposed to take in a file provided through standard input and print out the descending order of words followed by the frequency that they occur.  I can do this individually line for line but am having trouble putting it together as a whole to count all the lines and not just one specific line.  Here is my code:<br />
<br />
 <pre style="margin:20px; line-height:13px">blade71(382)% cat test.c<br />
#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
#define MAX_WORD_LENGTH&nbsp; &nbsp; 31<br />
#define MAX_TEXT_LENGTH 10000<br />
#define TRUE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1<br />
#define FALSE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  0<br />
#define BUFSIZE 100<br />
<br />
/* Structure defining a count of the occurrences of a given word */<br />
struct WordCounter<br />
{<br />
&nbsp;char *word;<br />
&nbsp;int word_count;<br />
&nbsp;struct WordCounter *pNext;&nbsp; /* Pointer to the next word counter in the list */<br />
};<br />
<br />
&nbsp; &nbsp; &nbsp; /* Function prototypes */<br />
void addWord(char *pWord);<br />
/* Adds a word to the list or updates exisiting word */<br />
int is_separator(char ch);<br />
/* Tests for a separator character */<br />
void show(struct WordCounter *pWordcounter);<br />
/* Outputs a word and its count of occurrences */<br />
struct WordCounter* createWordCounter(char *word);<br />
/* Creates a new WordCounter structure */<br />
int getword(char *, int);<br />
/* Self explanitory */<br />
int getch(void);<br />
void ungetch(int);<br />
<br />
&nbsp; &nbsp; &nbsp; /* Global variables */<br />
struct WordCounter *pStart = NULL;<br />
/* Pointer to first word counter in the list */<br />
char buf[BUFSIZE];<br />
int bufp = 0;<br />
<br />
main()<br />
{<br />
&nbsp;char text[MAX_TEXT_LENGTH];&nbsp; &nbsp; /* Stores input text */<br />
&nbsp;char buffer[MAX_WORD_LENGTH];&nbsp; /* Buffer to hold a word */<br />
&nbsp;size_t i = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Index to text */<br />
&nbsp;int len = 0 ;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Word length */<br />
&nbsp;struct WordCounter *pCounter = NULL;&nbsp; /* Pointer to a word counter */<br />
&nbsp;printf(&quot;Calculating frequency of word occurances:\n&quot;);<br />
<span style="color:Green">gets(text);</span> <span style="color:Red">This line only gets the first line.&nbsp; To get the next I thought I could do something like footnote 1.</span><br />
<br />
/* Extract the words from the text&nbsp; */<br />
&nbsp;while(text[i] != '\0')<br />
&nbsp;{<br />
&nbsp; /* Skip over separators */<br />
&nbsp; while(is_separator(text[i]))<br />
&nbsp; ++i;<br />
&nbsp; /* It is either the end of the string or the start of a word&nbsp; &nbsp; */<br />
&nbsp; /* As long as it is not the string terminator copy the character */<br />
&nbsp; len = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Reset character count&nbsp; &nbsp; */<br />
&nbsp; while((!is_separator(text[i])) &amp;&amp; (text[i] != '\0'))<br />
&nbsp; buffer[len++] = text[i++];<br />
&nbsp; if(len&gt;0)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  /* Check we have some characters in the word */<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp;  buffer[len] = '\0';&nbsp;  /* We reached the end of a word so add terminator */<br />
&nbsp; &nbsp;  addWord(buffer);&nbsp; &nbsp; &nbsp; /* Add the word to the list */<br />
&nbsp; &nbsp; }<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  /* List the words and their counts */<br />
&nbsp;pCounter = pStart;<br />
&nbsp;while(pCounter != NULL)<br />
&nbsp; {<br />
&nbsp;  show(pCounter);<br />
&nbsp;  pCounter = pCounter-&gt;pNext;<br />
&nbsp; }<br />
&nbsp;printf(&quot;\n&quot;);<br />
&nbsp;/* Free the memory that we allocated */<br />
&nbsp;pCounter = pStart;<br />
&nbsp;while(pCounter != NULL)<br />
&nbsp; {<br />
&nbsp;  free(pCounter-&gt;word);&nbsp; &nbsp; &nbsp; &nbsp; /* Free space for the word */<br />
&nbsp;  pStart = pCounter;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  /* Save address of current */<br />
&nbsp;  pCounter = pCounter-&gt;pNext;&nbsp; /* Move to next counter&nbsp; &nbsp; */<br />
&nbsp;  free(pStart);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Free space for current&nbsp; */<br />
&nbsp; }<br />
}<br />
<br />
/* Returns TRUE if the argument is a separator character and FALSE otherwise */<br />
int is_separator(char ch)<br />
{<br />
&nbsp;/* Separators are space, comma, colon, semicolon, double quote, question mark, exclamation, and period */<br />
&nbsp;static char separators[] = { ' ' , ',',':' , '\&quot;', '?' , '!' , '.'};<br />
&nbsp;int i = 0;<br />
&nbsp;for(i = 0 ; i&lt;sizeof separators ; i++)<br />
&nbsp; {<br />
&nbsp;  if(ch == separators[i])<br />
&nbsp;  return TRUE;<br />
&nbsp; }<br />
&nbsp;return FALSE;<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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void show(struct WordCounter *pWordcounter)<br />
{<br />
&nbsp;/* output the word left-justified in a fixed field width followed by the count */<br />
&nbsp;printf(&quot;\n%-30s&nbsp;  %5d&quot;, pWordcounter-&gt;word,pWordcounter-&gt;word_count);<br />
}<br />
<br />
void addWord(char *word)<br />
{<br />
&nbsp;struct WordCounter *pCounter = NULL;<br />
&nbsp;struct WordCounter *pLast = NULL;<br />
&nbsp;if(pStart == NULL)<br />
&nbsp; {<br />
&nbsp;  pStart = createWordCounter(word);<br />
&nbsp;  return;<br />
&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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  /* If the word is in the list, increment its count */<br />
&nbsp;pCounter = pStart;<br />
&nbsp;while(pCounter != NULL)<br />
&nbsp; {<br />
&nbsp;  if(strcmp(word, pCounter-&gt;word) == 0)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp;  ++pCounter-&gt;word_count;<br />
&nbsp; &nbsp;  return;<br />
&nbsp; &nbsp; }<br />
&nbsp;  pLast = pCounter;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Save address of last in case we need it */<br />
&nbsp;  pCounter = pCounter-&gt;pNext;&nbsp; /* Move pointer to next in the list&nbsp; &nbsp; &nbsp; &nbsp; */<br />
&nbsp; }<br />
<br />
&nbsp;/* If we get to here it's not in the list - so add it */<br />
&nbsp;  pLast-&gt;pNext = createWordCounter(word);<br />
}<br />
<br />
/* Create and returns a new WordCounter object for the argument */<br />
struct WordCounter* createWordCounter(char *word)<br />
{<br />
&nbsp; struct WordCounter *pCounter = NULL;<br />
&nbsp; pCounter = (struct WordCounter*)malloc(sizeof(struct WordCounter));<br />
&nbsp; pCounter-&gt;word = (char*)malloc(strlen(word)+1);<br />
&nbsp; strcpy(pCounter-&gt;word, word);<br />
&nbsp; pCounter-&gt;word_count = 1;<br />
&nbsp; pCounter-&gt;pNext = NULL;<br />
&nbsp; return pCounter;<br />
}</pre>1.  <pre style="margin:20px; line-height:13px">while(scanf(&quot;%s&quot;,&amp;text[x] != EOF))<br />
{<br />
gets(&amp;text[x]);<br />
x++;<br />
}</pre>However, C being the type dependent pain in the ass that it is...this doesn't work or I'm just unaware of how to cast it to work.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Ineedhelpplz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239517.html</guid>
		</item>
		<item>
			<title>bios.h: No such file or directory</title>
			<link>http://www.daniweb.com/forums/thread239514.html</link>
			<pubDate>Wed, 18 Nov 2009 17:27:36 GMT</pubDate>
			<description><![CDATA[Hello, 
 
I'm trying to compile a program related with serial communication via RS232. I've found this program at microsoft page http://support.microsoft.com/?scid=kb%3Ben-us%3B39501&x=9&y=11#top. When I try to compile this same program in Dev C++ editor the following message appears:  
bios.h: No...]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I'm trying to compile a program related with serial communication via RS232. I've found this program at microsoft page <a rel="nofollow" class="t" href="http://support.microsoft.com/?scid=kb%3Ben-us%3B39501&amp;x=9&amp;y=11#top" target="_blank">http://support.microsoft.com/?scid=k...1&amp;x=9&amp;y=11#top</a>. When I try to compile this same program in Dev C++ editor the following message appears: <br />
bios.h: No such file or directory. Please, help me about what can I do in order to advance or give me an alternative solution. Thanks in advance.<br />
 <pre style="margin:20px; line-height:13px">/* Compile options needed: none<br />
&nbsp;- The following program is a simple example which sends and receives<br />
&nbsp;  one character to/from COM1:<br />
*/ <br />
<br />
#include &lt;stdio.h&gt;<br />
#include &lt;bios.h&gt;<br />
<br />
void main(void)<br />
{<br />
&nbsp; &nbsp; unsigned com1_status;<br />
&nbsp; &nbsp; unsigned com1_send;<br />
&nbsp; &nbsp; unsigned com1_rec;<br />
&nbsp; &nbsp; unsigned com1_init;<br />
&nbsp; &nbsp; int result, mask;<br />
<br />
&nbsp; &nbsp; /* open serial port at 1200 baud, 8 data bits,<br />
&nbsp; &nbsp; ** No parity, 1 stop bit */ <br />
&nbsp; &nbsp; com1_init = _bios_serialcom(_COM_INIT, 0,<br />
&nbsp; &nbsp; &nbsp; &nbsp; _COM_CHR8 | _COM_NOPARITY | _COM_STOP1 | _COM_1200);<br />
&nbsp; &nbsp; printf(&quot;Init status: 0x%4.4X\n&quot;, com1_init);<br />
<br />
&nbsp; &nbsp; /* send an '*' to com1 */ <br />
&nbsp; &nbsp; com1_send = _bios_serialcom(_COM_SEND, 0, '*');<br />
&nbsp; &nbsp; printf(&quot;Send status: 0x%4.4X\n&quot;, com1_send);<br />
<br />
&nbsp; &nbsp; mask = 0x6100;<br />
&nbsp; &nbsp; /* value used to mask:<br />
&nbsp; &nbsp; *&nbsp; &nbsp; bits 0-7 are related to modems,<br />
&nbsp; &nbsp; *&nbsp; &nbsp; bits 8-15 are for port status,<br />
&nbsp; &nbsp; *&nbsp; &nbsp; &nbsp; check to see that the following bits are set:<br />
&nbsp; &nbsp; *&nbsp; &nbsp; &nbsp; &nbsp;  8 (data ready)<br />
&nbsp; &nbsp; *&nbsp; &nbsp; &nbsp; &nbsp; 13 (Transmission-hold&nbsp; register empty)<br />
&nbsp; &nbsp; *&nbsp; &nbsp; &nbsp; &nbsp; 14 (Transmission-shift register empty)<br />
&nbsp; &nbsp; */ <br />
<br />
&nbsp; &nbsp; /* check the status */ <br />
&nbsp; &nbsp; com1_status = _bios_serialcom(_COM_STATUS, 0, 0);<br />
&nbsp; &nbsp; printf(&quot;COM1 status: 0x%4.4X\n&quot;, com1_status);<br />
<br />
&nbsp; &nbsp; /* wait until a character is ready */ <br />
&nbsp; &nbsp; do {<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* check the status */ <br />
&nbsp; &nbsp; &nbsp; &nbsp; com1_status = _bios_serialcom(_COM_STATUS, 0, 0);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* mask off the low order byte of com1_status */ <br />
&nbsp; &nbsp; &nbsp; &nbsp; com1_status = com1_status &amp; 0xFF00;<br />
&nbsp; &nbsp; } while( (mask &amp; com1_status) == 0);<br />
<br />
&nbsp; &nbsp; /* get a character */ <br />
&nbsp; &nbsp; com1_rec =&nbsp; _bios_serialcom(_COM_RECEIVE, 0, 0);<br />
&nbsp; &nbsp; printf(&quot;Read status: 0x%4.4X\n&quot;, com1_rec);<br />
<br />
&nbsp; &nbsp; /* print the character we just received */ <br />
&nbsp; &nbsp; result = com1_rec &amp; 0x00FF;<br />
&nbsp; &nbsp; printf(&quot;Character: 0x%2.2X&nbsp; =&nbsp; %c\n&quot;, result, (char)result);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>jmangu</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239514.html</guid>
		</item>
		<item>
			<title>Dynamic include in C</title>
			<link>http://www.daniweb.com/forums/thread239511.html</link>
			<pubDate>Wed, 18 Nov 2009 17:17:29 GMT</pubDate>
			<description><![CDATA[Hi All, 
Let me explain the problem. 
 
I have multiple include files as in class1.inc, class2.inc, class3.inc etc. Contents of an include file will be like 
 
class1.inc 
 
 
{ 
"john",]]></description>
			<content:encoded><![CDATA[<div>Hi All,<br />
Let me explain the problem.<br />
<br />
I have multiple include files as in class1.inc, class2.inc, class3.inc etc. Contents of an include file will be like<br />
<br />
class1.inc<br />
<br />
 <pre style="margin:20px; line-height:13px">{<br />
&quot;john&quot;,<br />
12,<br />
68,<br />
<br />
&quot;steve&quot;,<br />
12,<br />
98,<br />
<br />
&quot;mat&quot;,<br />
12,<br />
95,<br />
<br />
};</pre><br />
This will basically serve as a static array of structures. Here there are three field name(char*), age(int), avg(float).<br />
In my program I want to assign the value of one of these file to a structure variable. My code goes like this<br />
<br />
 <pre style="margin:20px; line-height:13px">struct std_<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char name&#91;50&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int age;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float avg;<br />
}<br />
std_str, *std_ptr;<br />
<br />
int main(int argc, char **argv)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if(!strcmp(argv&#91;2&#93;,&quot;class1&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; static std_str obj&#91;200&#93; = <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #include &quot;class1.inc&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(!strcmp(argv&#91;2&#93;,&quot;class2&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
return 0;<br />
}</pre><br />
The above code will work fine. But what I want is<br />
 <pre style="margin:20px; line-height:13px">int main(int argc, char **argv)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char file&#91;50&#93;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* I want to dynamically generate the include file name and include it */<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcat(file, argv&#91;2&#93;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcat(file, &quot;.inc&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; static std_str obj&#91;200&#93; = <br />
&nbsp; &nbsp; &nbsp; &nbsp; #include file<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
return 0;<br />
}</pre><br />
But unfortunately, the compilation fails, saying #include expects a file name.<br />
<br />
Is there anyway to achieve this?<br />
<br />
Thanks and Regards,<br />
Ahamed.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>ahamed101</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239511.html</guid>
		</item>
		<item>
			<title>Asynchronous Server with threads</title>
			<link>http://www.daniweb.com/forums/thread239449.html</link>
			<pubDate>Wed, 18 Nov 2009 13:20:46 GMT</pubDate>
			<description><![CDATA[I'm trying to create a simple server that starts a new thread for each new client that connects. I know I can use fork(), but I've heard that threads are more efficient. Also I have some global queues, so if I used fork(), each process would get their own version of the queues. (I could fix this...]]></description>
			<content:encoded><![CDATA[<div>I'm trying to create a simple server that starts a new thread for each new client that connects. I know I can use fork(), but I've heard that threads are more efficient. Also I have some global queues, so if I used fork(), each process would get their own version of the queues. (I could fix this with shared memory).<br />
<br />
But I'm not sure where to implement this in my code.<br />
Heres the pseudocode of my server and main accept() loop:<br />
<br />
 <pre style="margin:20px; line-height:13px">Global queue1;<br />
Global queue2;<br />
<br />
&lt;create socket and request socket, fill address structure, bind(), listen()&gt;<br />
while(1) {<br />
&nbsp; &nbsp; &lt;socket = accept()&gt;<br />
&nbsp; &nbsp; &lt;close request socket&gt;<br />
&nbsp; &nbsp; &lt;Processing the request&gt;<br />
&nbsp; &nbsp; &lt;Closing socket&gt;<br />
}</pre><br />
So I need to know where/how, in my code, to implement threads, and which type of threads to use. It is supposed to run on Linux. <br />
Also I need to know how to synchronize Global queue1 and Global queue2 so that the threads can access and write/delete from them without problems.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>siggivara</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239449.html</guid>
		</item>
		<item>
			<title>How to output all the letters of the alphabet randomly?</title>
			<link>http://www.daniweb.com/forums/thread239425.html</link>
			<pubDate>Wed, 18 Nov 2009 11:01:40 GMT</pubDate>
			<description><![CDATA[Hello people :) 
 
My teacher gave me a new project to work on. 
I need to write an application that output all the letters of the alphabet  in a random order. 
I've made some applications before but im still kinda new to this. 
Could any of you give me a hint or put me in the right direction? 
...]]></description>
			<content:encoded><![CDATA[<div>Hello people :)<br />
<br />
My teacher gave me a new project to work on.<br />
I need to write an application that output all the letters of the alphabet  in a random order.<br />
I've made some applications before but im still kinda new to this.<br />
Could any of you give me a hint or put me in the right direction?<br />
<br />
Kind regards,<br />
Jelmund<br />
<br />
PS: i already searched on the internet</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Jelmund</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239425.html</guid>
		</item>
		<item>
			<title>Socket programming in C</title>
			<link>http://www.daniweb.com/forums/thread239156.html</link>
			<pubDate>Tue, 17 Nov 2009 08:11:30 GMT</pubDate>
			<description>Hi all, 
How to do socket programming in C.I need to control an external device through TCP/IP or UDP/IP so that when I send a query the device should  be capable to respond.</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
How to do socket programming in C.I need to control an external device through TCP/IP or UDP/IP so that when I send a query the device should  be capable to respond.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>george_82</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239156.html</guid>
		</item>
		<item>
			<title>Interrupts in C</title>
			<link>http://www.daniweb.com/forums/thread239110.html</link>
			<pubDate>Tue, 17 Nov 2009 04:26:57 GMT</pubDate>
			<description><![CDATA[Dear colleagues I am currently working on designing a scheduler using Borland C. I am struck with the concept of interrupts. I am trying clock tick interrupt for task switching. In all materials they say you will continue to your regular job until the interrupt occurs. I don't think it suddenly...]]></description>
			<content:encoded><![CDATA[<div>Dear colleagues I am currently working on designing a scheduler using Borland C. I am struck with the concept of interrupts. I am trying clock tick interrupt for task switching. In all materials they say you will continue to your regular job until the interrupt occurs. I don't think it suddenly occurs with out setting it in the context of the task. this is my first project in C. currently my tasks don't have separate stack of their own. all share the same stack. so i will be happy if you people tell me in what way i should update my knowledge.<br />
in my part i will help to you people too.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Mathura</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239110.html</guid>
		</item>
		<item>
			<title><![CDATA[find the 3rd ',' in a string line]]></title>
			<link>http://www.daniweb.com/forums/thread239083.html</link>
			<pubDate>Tue, 17 Nov 2009 02:08:46 GMT</pubDate>
			<description><![CDATA[Hi experts, 
 
i have this line of string: a1,b2,c3,a2,b1,c2,a3,b2,c4, 
 
from this line,i want to load into a string array like this: 
array[0]=a1,b2,c3, 
array[1]=a2,b1,c2, 
array[3]=a3,b2,c4, 
 
seriously i have no idea at all.ive done sumthing but looks like rubbish.i really hope dat u experts...]]></description>
			<content:encoded><![CDATA[<div>Hi experts,<br />
<br />
i have this line of string: a1,b2,c3,a2,b1,c2,a3,b2,c4,<br />
<br />
from this line,i want to load into a string array like this:<br />
array[0]=a1,b2,c3,<br />
array[1]=a2,b1,c2,<br />
array[3]=a3,b2,c4,<br />
<br />
seriously i have no idea at all.ive done sumthing but looks like rubbish.i really hope dat u experts can help me.<br />
<br />
thanks for advance<br />
 <pre style="margin:20px; line-height:13px">void seeding()<br />
{<br />
&nbsp;  char seed_array[100];//line of characters in this array<br />
&nbsp;  printf (&quot;seed real=&gt; %s\n&quot;,seed);<br />
&nbsp;  char *p=NULL;<br />
<br />
&nbsp;  for (int i=0;i&lt;= 100;i++)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  p=strchr(seed,',');<br />
&nbsp; &nbsp; &nbsp;  if (atoi(p)==3)<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcpy (seed_array[i],p);<br />
&nbsp; &nbsp; &nbsp; &nbsp; *p='\n';<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  printf (&quot;seed array=&gt; %s\n&quot;,seed_array[i]);<br />
&nbsp;  }<br />
<br />
&nbsp;  printf(&quot;seeding test is running!!!!\n&quot;);<br />
&nbsp;}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>ubi_ct83</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239083.html</guid>
		</item>
		<item>
			<title>Starting out using structures . . .</title>
			<link>http://www.daniweb.com/forums/thread239007.html</link>
			<pubDate>Mon, 16 Nov 2009 19:05:26 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 />
<br />
struct poly {<br />
&nbsp; &nbsp; &nbsp; &nbsp; int len;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int arr[];<br />
&nbsp; &nbsp; &nbsp; &nbsp; char *name;<br />
};<br />
<br />
<br />
int main() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; struct poly p;<br />
&nbsp; &nbsp; &nbsp; &nbsp; p.len = 45;<br />
&nbsp; &nbsp; &nbsp; &nbsp; p.arr[3] = {1,1,1};<br />
&nbsp; &nbsp; &nbsp; &nbsp; p.name = &quot;Josh&quot;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d&quot;,p.len);<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; p.arr[i] != NULL ; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d&quot;,p.arr[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%s&quot;,p.name);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre><br />
I tried to make a simple program to see if I understood structures. Apparently, I do not. Haha.<br />
<br />
I am getting these error messages when I compile:<br />
struct.c:5: error: flexible array member not at end of struct<br />
struct.c: In function âmainâ:<br />
struct.c:14: error: expected expression before â{â token<br />
<br />
Does anyone mind helping me learn what I did wrong and how to fix it?<br />
<br />
Thank you!</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/thread239007.html</guid>
		</item>
		<item>
			<title>What is the correct o/p for the following code?</title>
			<link>http://www.daniweb.com/forums/thread238989.html</link>
			<pubDate>Mon, 16 Nov 2009 17:56:02 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 />
void main()<br />
{<br />
int i=5;<br />
int c;<br />
c=i++ + ++i + i++ + --i;<br />
printf(&quot;\n%d&quot;,i++ + ++i + i++ + --i);<br />
printf(&quot;\n%d&quot;,c);<br />
}</pre>The o/p that I'm getting is <br />
31<br />
23<br />
<br />
while my friend got<br />
34<br />
20.<br />
<br />
<br />
Also why are the 2 (printf ' c 'and printf 'expression') values different. Is it because printf evaluation is different from how a normal expression would be evaluated?<br />
<br />
thanks in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>userits</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238989.html</guid>
		</item>
		<item>
			<title>Avegare number of comparisons</title>
			<link>http://www.daniweb.com/forums/thread238960.html</link>
			<pubDate>Mon, 16 Nov 2009 15:41:41 GMT</pubDate>
			<description><![CDATA[Hello, 
 
I have a program which searches for  (using binary search) specific word in ordered list and counts number of comparisons it makes until it finds the target!  
 
My problem is: how can I count average of number of comparisons? 
 
Here is how searching function works: 
 
  <div...]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I have a program which searches for  (using binary search) specific word in ordered list and counts number of comparisons it makes until it finds the target! <br />
<br />
My problem is: how can I count average of number of comparisons?<br />
<br />
Here is how searching function works:<br />
<br />
 <pre style="margin:20px; line-height:13px">int binary_search(char *array[], int end, char *target, int *location, int *compare_count){<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int first;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int middle;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int last;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; first = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; last = end;<br />
&nbsp; &nbsp; &nbsp; &nbsp; *compare_count = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(first &lt;= last){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; middle = (first + last)/2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(strcmp(array[middle], target) &lt; 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first = middle + 1;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(strcmp(array[middle], target) &gt; 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; last = middle - 1;<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; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (*compare_count)++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; *location = middle; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if(first == last) first--;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return(strcmp(target, array[middle]) == 0);<br />
}</pre></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/thread238960.html</guid>
		</item>
		<item>
			<title>Winsock hooks</title>
			<link>http://www.daniweb.com/forums/thread238956.html</link>
			<pubDate>Mon, 16 Nov 2009 15:34:14 GMT</pubDate>
			<description><![CDATA[I'm looking for code to inject code into a webpage at the specified location. Can we do this using winsock hooks.  
Can somebody help me with this. I need this urgently:confused:]]></description>
			<content:encoded><![CDATA[<div>I'm looking for code to inject code into a webpage at the specified location. Can we do this using winsock hooks. <br />
Can somebody help me with this. I need this urgently:confused:</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>lacompsr</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238956.html</guid>
		</item>
		<item>
			<title>Homework: parking problem</title>
			<link>http://www.daniweb.com/forums/thread238943.html</link>
			<pubDate>Mon, 16 Nov 2009 14:25:13 GMT</pubDate>
			<description><![CDATA[im new at C, actually just started programming in general, and im having a good amount of problems with this program. 
 
#include <stdio.h> 
 
 
 
int main(void) 
 
{ 
char vehicle;]]></description>
			<content:encoded><![CDATA[<div>im new at C, actually just started programming in general, and im having a good amount of problems with this program.<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
<br />
<br />
<br />
int main(void)<br />
<br />
{<br />
char vehicle;<br />
char car;<br />
char truck;<br />
int hrsn, minn;<br />
int hrso, mino;<br />
int time;<br />
int rt;<br />
int amo;<br />
<br />
printf(&quot;What time did you park(military time-(hh,mm))?&quot;);<br />
scanf(&quot;%d,%d&quot;, &amp;hrsn, &amp;minn);<br />
<br />
printf(&quot;What time did you leave(military time-(hh,mm))?&quot;);<br />
scanf(&quot;%d,%d&quot;, &amp;hrso, &amp;mino);<br />
<br />
printf(&quot;Where you driving a car or truck?&quot;);<br />
scanf(&quot;%c&quot;, &amp;vehicle );<br />
<br />
if (hrsn &lt; (hrso - 1) &amp;&amp; minn &gt; mino)<br />
{ hrso = hrso - 1;<br />
mino = mino + 60;<br />
}<br />
if (mino - minn &gt; 1 &amp;&amp; mino - minn &lt; 30)<br />
{<br />
mino - minn = 30;<br />
}<br />
<br />
else if (mino - minn &gt; 30 &amp;&amp; mino - minn &lt; 60)<br />
{<br />
mino - minn = 60;<br />
}<br />
<br />
else {<br />
mino - minn = 00;<br />
}<br />
<br />
rt = hrso - hrsn:mino - minn;<br />
<br />
if (vehicle == car)<br />
{ scanf(&quot;%c&quot;, &amp;car);<br />
if (time &lt; 3)<br />
{car = 0;<br />
}<br />
else<br />
{car = 1.5;<br />
}<br />
}<br />
<br />
<br />
else {<br />
scanf(&quot;%c&quot;, &amp;truck):<br />
if (time &lt; 2)<br />
{truck = 1;<br />
}<br />
else<br />
{truck = 2.3;<br />
}<br />
}<br />
amo = rt * %c;<br />
<br />
<br />
<br />
}<br />
printf(&quot;%c&quot;);<br />
Printf(&quot;Time in %d:%d\n&quot;, hrsn, minn);<br />
Printf(&quot;Time out %d:%d\n&quot;, hrso, mino);<br />
<br />
printf(&quot;Parking Time %d\n&quot;, time);<br />
printf(&quot;Rounded time %d\n&quot;, rt);<br />
<br />
printf(&quot;Ammount Owed $ %d\n&quot;, amo);<br />
<br />
<br />
return 0;<br />
<br />
<br />
}</pre><br />
im trying to do this:<br />
<br />
Problem 2: (P) Write a C program to calculate the parking fare for customers who park their cars in a parking lot when the following information is given:<br />
a. A character showing the type of vehicle: C for car, T for truck.<br />
b. An integcr between 0 and 24 showing the hour the vehicle entered the lot.<br />
c. An integer between 0 and 60 showing the minute the vehicle entered the lot.<br />
d. An integer between 0 and 24 showing the hour the vehicle left the lot.<br />
e. An integer between 0 and 60 showing the minute the vehicle left the lot.<br />
This is a public lot. To encourage people to park for a short period of time, the management uses two different rates for each type of vehicle, as shown in Table<br />
CAR $0 / hr first 3 hr $1.50 / hr after 3 hr<br />
TRUCK $1 / hr first 2 hr $2.30 / hr after 2 hr<br />
Input data consists of a character and a set of four integers. The character represents type of vehicle and the four integers indicate: Hour entered the lot, Minute entered lot, Hour exited lot, and Minute exited the lot. <br />
<br />
Output should be like:<br />
<br />
Type of vehicle: &lt;car , bus, or truck&gt;<br />
TIME-IN HR:MN<br />
TIME-OUT HR:MN<br />
----------<br />
PARKING TIME HR:MN<br />
ROUNDED TIME HOURS<br />
<br />
TOTAL CHARGE $ _____.__<br />
<br />
<br />
im sure there are alot of mistakes<br />
any help is greatly appriciated</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Hanyack</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238943.html</guid>
		</item>
		<item>
			<title>problem in passing strings from array of atring</title>
			<link>http://www.daniweb.com/forums/thread238886.html</link>
			<pubDate>Mon, 16 Nov 2009 10:22:15 GMT</pubDate>
			<description>i have a problem in which i have to remove char from strings by sending one string and char ata time to a function. 
in the below code it works fine for first string but for each successive string initial characters are not passed ..like for second call first chatcter of string will not be passed...</description>
			<content:encoded><![CDATA[<div>i have a problem in which i have to remove char from strings by sending one string and char ata time to a function.<br />
in the below code it works fine for first string but for each successive string initial characters are not passed ..like for second call first chatcter of string will not be passed and so on.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
#define MAXLEN 100<br />
void fnRemChar(char*,char);<br />
int main(int argc,char *argv&#91;&#93;)<br />
{<br />
<br />
&nbsp; &nbsp; system(&quot;clear&quot;);<br />
&nbsp; &nbsp; int iNoOfStr;<br />
&nbsp; &nbsp; char acInpStr&#91;MAXLEN&#93;&#91;MAXLEN&#93;;<br />
&nbsp; &nbsp; char cChar;<br />
&nbsp; &nbsp; printf(&quot;\nEnter number of strings to be entered(should not be greater than %d):&quot;,MAXLEN);<br />
&nbsp; &nbsp; fflush(stdin);<br />
&nbsp; &nbsp; scanf(&quot;%d&quot;,&amp;iNoOfStr);<br />
&nbsp; &nbsp; void (*REMOVE) (char* ,char);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* REMOVE Pointer to Function fnRemChar */<br />
&nbsp; &nbsp; &nbsp; &nbsp; REMOVE = fnRemChar;<br />
<br />
&nbsp; &nbsp; for(int iCount=0;iCount&lt;iNoOfStr;iCount++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n ENTER %d String: &quot;,iCount+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; getchar();<br />
&nbsp; &nbsp; &nbsp; &nbsp; fgets(acInpStr&#91;iCount&#93;,MAXLEN,stdin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fflush(stdout);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fflush(stdin);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; printf(&quot;\n Enter character to be removed: &quot;);<br />
&nbsp; &nbsp; scanf(&quot;%c&quot;,&amp;cChar);<br />
<br />
&nbsp; &nbsp; for(int iCount=0;iCount&lt;iNoOfStr;iCount++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; REMOVE(acInpStr&#91;iCount&#93;,cChar);<br />
&nbsp; &nbsp; }<br />
}<br />
void fnRemChar(char *acInpStr,char cChar)<br />
{<br />
&nbsp; &nbsp; char acFinalStr&#91;MAXLEN&#93;;<br />
&nbsp; &nbsp; int iCount=0,iCount1=0;<br />
&nbsp; &nbsp; while(acInpStr&#91;iCount&#93;!='\0')<br />
&nbsp;if(acInpStr&#91;iCount&#93; != cChar)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n %c&quot;,acInpStr&#91;iCount&#93;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acFinalStr&#91;iCount1&#93;=acInpStr&#91;iCount&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iCount1++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; iCount++;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; printf(&quot;\n %s\n&quot;,acFinalStr);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>arsh_arsh</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238886.html</guid>
		</item>
		<item>
			<title>about recursion</title>
			<link>http://www.daniweb.com/forums/thread238874.html</link>
			<pubDate>Mon, 16 Nov 2009 09:17:23 GMT</pubDate>
			<description>helllo  
last day i did program related to recursion that is factorial of numbers i red lot of books in my library but i found only this program only in every book. 
i also thought lot on recursion but i did not find any more program please can anybody tell me or can give any clue to do more...</description>
			<content:encoded><![CDATA[<div>helllo <br />
last day i did program related to recursion that is factorial of numbers i red lot of books in my library but i found only this program only in every book.<br />
i also thought lot on recursion but i did not find any more program please can anybody tell me or can give any clue to do more programs by using this concept.<br />
i do not want program coding i just want question on it or any clue<br />
please help me.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>aman rathi</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238874.html</guid>
		</item>
		<item>
			<title>about pointers</title>
			<link>http://www.daniweb.com/forums/thread238871.html</link>
			<pubDate>Mon, 16 Nov 2009 09:01:06 GMT</pubDate>
			<description>hello  
i am a student of sgrrits dehradun doing bca now a days my pointers chapter is going on its difficult to understand but mostly i did it but i want to know that how it is use ful for us in the c. 
i only find its 1 benefit that is by using pointers you can return two or more values in a...</description>
			<content:encoded><![CDATA[<div>hello <br />
i am a student of sgrrits dehradun doing bca now a days my pointers chapter is going on its difficult to understand but mostly i did it but i want to know that how it is use ful for us in the c.<br />
i only find its 1 benefit that is by using pointers you can return two or more values in a function.<br />
please can anybody tell how it is more useful for us and what are that programs that can be excutes by using only pointers?<br />
please also tell me any site or give me any link where i find lot of lot clues to do programs by using pointer.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>aman rathi</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238871.html</guid>
		</item>
		<item>
			<title>Code or function for key press like mouse button press</title>
			<link>http://www.daniweb.com/forums/thread238867.html</link>
			<pubDate>Mon, 16 Nov 2009 08:29:37 GMT</pubDate>
			<description><![CDATA[Hi, 
 
Is there a way to write code or do functions exist for keypress down and keypress up of the keyboard.There are functions for mouseleft button down and mouse left button up.Is it possible with keyboard keys in windows?Like "Alt"+"F" etc... 
 
Any sample code or resource would greatly...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
Is there a way to write code or do functions exist for keypress down and keypress up of the keyboard.There are functions for mouseleft button down and mouse left button up.Is it possible with keyboard keys in windows?Like &quot;Alt&quot;+&quot;F&quot; etc...<br />
<br />
Any sample code or resource would greatly help.Thanks in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>danibootstrap</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238867.html</guid>
		</item>
		<item>
			<title>Serial port reading error</title>
			<link>http://www.daniweb.com/forums/thread238853.html</link>
			<pubDate>Mon, 16 Nov 2009 07:18:48 GMT</pubDate>
			<description><![CDATA[//The below mentioned code is not working on my C compiler.The //errors im getting  is :(1)Extra parameter in call to_ inport b_. 
//(2)Too few parameters in call to "outport".(line 25) 
//(3)Not an allowed type(line 25) 
 
 
#include<stdio.h> 
#include<conio.h> 
#include<dos.h> 
 
void main()]]></description>
			<content:encoded><![CDATA[<div>//The below mentioned code is not working on my C compiler.The //errors im getting  is :(1)Extra parameter in call to_ inport b_.<br />
//(2)Too few parameters in call to &quot;outport&quot;.(line 25)<br />
//(3)Not an allowed type(line 25)<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
#include&lt;conio.h&gt;<br />
#include&lt;dos.h&gt;<br />
<br />
void main()<br />
&nbsp; {<br />
&nbsp; &nbsp; char data;<br />
&nbsp; &nbsp; int choice;<br />
&nbsp; &nbsp; clrscr();<br />
<br />
&nbsp; printf(&quot;Enter the choice to send or receive from COM1::&quot;);<br />
&nbsp; scanf(&quot;%d&quot;,&amp;choice);<br />
<br />
<br />
&nbsp; if(choice==1)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; printf(&quot;Enter data to send::&quot;);<br />
&nbsp; &nbsp; &nbsp; scanf(&quot;%c&quot;,data);<br />
&nbsp; &nbsp; &nbsp; inportb(0x03f8,data);<br />
&nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; else<br />
&nbsp; &nbsp; {<br />
data=outport(0x3f8);<br />
printf(&quot;reding from&nbsp; COM1::%d&quot;,data);<br />
<br />
&nbsp; &nbsp; }<br />
getch();<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>george_82</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238853.html</guid>
		</item>
		<item>
			<title>put void function into loop statement?</title>
			<link>http://www.daniweb.com/forums/thread238836.html</link>
			<pubDate>Mon, 16 Nov 2009 05:14:33 GMT</pubDate>
			<description>is it possible to put void function into loop statement?</description>
			<content:encoded><![CDATA[<div>is it possible to put void function into loop statement?</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/thread238836.html</guid>
		</item>
		<item>
			<title>Calendar in C program using julian dates</title>
			<link>http://www.daniweb.com/forums/thread238825.html</link>
			<pubDate>Mon, 16 Nov 2009 04:21:44 GMT</pubDate>
			<description><![CDATA[I need help understanding julian dates. 
I am trying to create a program using julian dates where user enters month & year and show the calendar of that month. 
I especially don't understand the "int toJulian()"... 
 
here is what I have so far: 
 
  <div class="codeblock"> <div class="spaced">...]]></description>
			<content:encoded><![CDATA[<div>I need help understanding julian dates.<br />
I am trying to create a program using julian dates where user enters month &amp; year and show the calendar of that month.<br />
I especially don't understand the &quot;int toJulian()&quot;...<br />
<br />
here is what I have so far:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#define START 1900 //fixed year<br />
<br />
//PROTOTYPES here<br />
<br />
void main(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int day, month, year, startDay, numDays;<br />
&nbsp; &nbsp; &nbsp; &nbsp; numDays = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; startDay = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; day = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; getMonthYear(&amp;month, &amp;year);<br />
&nbsp; &nbsp; &nbsp; &nbsp; toJulian(month, day, year);<br />
&nbsp; &nbsp; &nbsp; &nbsp; yearsToDays(year);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printCalendar(startDay, numDays);<br />
}<br />
void getMonthYear(int *month, int *year)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Enter month: &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf_s(&quot;%d&quot;, month);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Enter year: &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf_s(&quot;%d&quot;, year);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;); <br />
<br />
}<br />
int toJulian(int month, int day, int year) //takes calendar date and calculates its julian day within the year<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int count;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(count = 1; count &lt; month; ++count)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; day =+ daysInMonth(month, year);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
}<br />
int daysInMonth(int month, int year) //takes a month and year and calculates how many days are in this particular month<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int numDays;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (month == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 31;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (month == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 28 + leapYear(year);<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (month == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 31;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (month == 4)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 30;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (month == 5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 31;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (month == 6)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 30;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (month == 7)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 31;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (month == 8)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 31;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (month == 9)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 30;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (month == 10)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 31;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (month == 11)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 30;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (month == 12)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numDays = 31;<br />
}<br />
int leapYear(int year) //takes year and returns 1 if leap year otherwise 0<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (year % 400 == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
long yearsToDays(int year) // takes year returns the number of days from 1/1/1900 to end of previous year.<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int count;<br />
&nbsp; &nbsp; &nbsp; &nbsp; long days;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(count = START; count &lt; year; ++count)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; days = 365 + leapYear(year);<br />
}<br />
void printCalendar(int startDay, int numDays)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int num, dayid;<br />
&nbsp; &nbsp; &nbsp; &nbsp; printHeader();<br />
<br />
}<br />
void printHeader()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;SUN MON TUE WED THU FRI SAT\n&quot;);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>julie_kaz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238825.html</guid>
		</item>
		<item>
			<title>need help with pointers</title>
			<link>http://www.daniweb.com/forums/thread238811.html</link>
			<pubDate>Mon, 16 Nov 2009 03:24:23 GMT</pubDate>
			<description><![CDATA[Hi 
i'm trying to compile this code, but getting warning. need some help to understand what I'm doing wrong. 
 
void printGraph(FILE *out, GraphRef G){ 
 
  out = fopen (out, "w"); 
  if( out==NULL ){ 
      printf("Unable to open file %s for writing\n", out); 
      exit(1); 
   }]]></description>
			<content:encoded><![CDATA[<div>Hi<br />
i'm trying to compile this code, but getting warning. need some help to understand what I'm doing wrong.<br />
<br />
void printGraph(FILE *out, GraphRef G){<br />
<br />
  out = fopen (out, &quot;w&quot;);<br />
  if( out==NULL ){<br />
      printf(&quot;Unable to open file %s for writing\n&quot;, out);<br />
      exit(1);<br />
   }<br />
}<br />
<br />
warning: passing arg 1 of `fopen' from incompatible pointer type</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>hosh</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238811.html</guid>
		</item>
		<item>
			<title>Code Snippet fseeko64() and ftello64() for deal with large files (eg. file dimension)</title>
			<link>http://www.daniweb.com/code/snippet238780.html</link>
			<pubDate>Sun, 15 Nov 2009 23:39:01 GMT</pubDate>
			<description><![CDATA[*fseek()* and *ftell()* work only for files < 2,147,483,647 bytes 
 
*fseeko64()* and *ftello64()* from *<stdio.h>* can deal with files up to 18,446,744,073,709,552,000 bytes 
 
the printf format for unsigned long long val is *%I64d* 
 
eg. Obtaining the file dimension  (this code was tested with...]]></description>
			<content:encoded><![CDATA[<div><span style="font-weight:bold">fseek()</span> and <span style="font-weight:bold">ftell()</span> work only for files &lt; 2,147,483,647 bytes<br />
<br />
<span style="font-weight:bold">fseeko64()</span> and <span style="font-weight:bold">ftello64()</span> from <span style="font-weight:bold">&lt;stdio.h&gt;</span> can deal with files up to 18,446,744,073,709,552,000 bytes<br />
<br />
the printf format for unsigned long long val is <span style="font-weight:bold">%I64d</span><br />
<br />
eg. Obtaining the file dimension  (this code was tested with <span style="font-weight:bold">GNU GCC compiler</span> (MinGW/Cygwin) from code::blocks)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>AuSsIeStOnE</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238780.html</guid>
		</item>
		<item>
			<title>stdio.h function body</title>
			<link>http://www.daniweb.com/forums/thread238737.html</link>
			<pubDate>Sun, 15 Nov 2009 19:14:01 GMT</pubDate>
			<description>stdio.h only includes function declarations. Where does the compiler look for the function bodies?</description>
			<content:encoded><![CDATA[<div>stdio.h only includes function declarations. Where does the compiler look for the function bodies?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>ybean4</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238737.html</guid>
		</item>
		<item>
			<title>Weird characters with char pointer</title>
			<link>http://www.daniweb.com/forums/thread238672.html</link>
			<pubDate>Sun, 15 Nov 2009 16:18:22 GMT</pubDate>
			<description><![CDATA[Hi, i'm facing a weird behavior in this code that i just wrote. It was supposed to read a string from stdin and just write it out. 
I've debugged it and for me it reads perfectly, but in the while (line 38), *p just seems to be taking weird chars although it's pointing to the correct mem address...]]></description>
			<content:encoded><![CDATA[<div>Hi, i'm facing a weird behavior in this code that i just wrote. It was supposed to read a string from stdin and just write it out.<br />
I've debugged it and for me it reads perfectly, but in the while (line 38), *p just seems to be taking weird chars although it's pointing to the correct mem address (checked with those printf i put).<br />
What's going on?<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#define LONG 100<br />
<br />
char * leer();<br />
void printar(char *);<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; printf(&quot;Insert a string: &quot;);<br />
&nbsp; &nbsp; //char *str = leer();<br />
&nbsp; &nbsp; printar(leer());<br />
&nbsp; &nbsp; return 0;<br />
}<br />
<br />
char * leer()<br />
{<br />
&nbsp; &nbsp; char str[LONG], *p;<br />
&nbsp; &nbsp; int c;<br />
&nbsp; &nbsp; p = str;<br />
<br />
&nbsp; &nbsp; while((c = getchar()) != EOF)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(c == '\n')<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *p = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; *p = c;<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;p = %p, *p = c = %c\n&quot;, p, *p);<br />
&nbsp; &nbsp; &nbsp; &nbsp; p++;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; return str;<br />
}<br />
<br />
void printar(char *str)<br />
{<br />
&nbsp; &nbsp; char *p = str;<br />
&nbsp; &nbsp; while(*p != 0)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;p = %p, *p = %c\n&quot;, p, *p);<br />
&nbsp; &nbsp; &nbsp; &nbsp; putchar(*p);<br />
&nbsp; &nbsp; &nbsp; &nbsp; p++;<br />
&nbsp; &nbsp; }<br />
<br />
}</pre></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/thread238672.html</guid>
		</item>
		<item>
			<title>Help with a network design problem</title>
			<link>http://www.daniweb.com/forums/thread238669.html</link>
			<pubDate>Sun, 15 Nov 2009 15:47:35 GMT</pubDate>
			<description><![CDATA[Hello All! 
 
I have been working on a network design problem and am having a problem in the following part- 
 
What I am trying to do here -- 
{ 
for every set of edges (a,b), 
{ for all arcs (l,m) 
assign length of -- arc [l,m] = edge [a,b][l,m] 
shortest_path (num_nodes, arr_nodes, source);]]></description>
			<content:encoded><![CDATA[<div>Hello All!<br />
<br />
I have been working on a network design problem and am having a problem in the following part-<br />
<br />
What I am trying to do here --<br />
{<br />
for every set of edges (a,b),<br />
{ for all arcs (l,m)<br />
assign length of -- arc [l,m] = edge [a,b][l,m]<br />
shortest_path (num_nodes, arr_nodes, source);<br />
}<br />
----------------------------------------------------------------------------<br />
Part of the Code which does the above looks like this -<br />
 <pre style="margin:20px; line-height:13px">for ( node = arr_nodes; node &lt; arr_nodes + num_nodes; node++ )<br />
{<br />
edge_tail = (node - arr_nodes) + min_node;<br />
<br />
for ( arc_pointer = node -&gt; first; arc_pointer != (node+1) -&gt; first; arc_pointer++ )<br />
{<br />
edge_head = ((arc_pointer -&gt; head_edge) - arr_nodes) + min_node;<br />
<br />
for ( node1 = arr_nodes; node1 &lt; arr_nodes + num_nodes; node1++ )<br />
{<br />
tail_arc = tail1[count1];<br />
<br />
for ( arc_pointer1 = node1 -&gt; first; arc_pointer1 != (node1+1) -&gt; first; arc_pointer1++ )<br />
{<br />
head_arc = ((arc_pointer-&gt;head_edge)-ndp)+nmin;<br />
printf ( &quot; Tail_Edge = %2ld Head_Edge = %2ld Tail_Arc = %2ld Head_Arc = %2ld Length = %4lf\n&quot;, edge_tail, head_in, tail_arc, head_arc, ta-&gt;len );<br />
arc_pointer1 -&gt; length = weight2[edge_tail][edge_head][tail_arc][head_arc];<br />
shortest_path (num_nodes, arr_nodes, source);<br />
}<br />
count1++;<br />
}<br />
}<br />
}</pre>As of now it gives segmentation fault while displaying output at the print statement.<br />
<br />
Kindly guide me in knowing what is wrong in my coding so that it could give the desired result.<br />
<br />
Thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>rt.arti</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238669.html</guid>
		</item>
		<item>
			<title>I need 2d array program</title>
			<link>http://www.daniweb.com/forums/thread238670.html</link>
			<pubDate>Sun, 15 Nov 2009 14:57:38 GMT</pubDate>
			<description>i need 2d array programm</description>
			<content:encoded><![CDATA[<div>i need 2d array programm</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>dipisahu</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238670.html</guid>
		</item>
		<item>
			<title>How to draw lines or circle (graphics) onto windows screen?</title>
			<link>http://www.daniweb.com/forums/thread238641.html</link>
			<pubDate>Sun, 15 Nov 2009 12:34:20 GMT</pubDate>
			<description>Hi , 
 
Is there a way that I can draw lines or circles etcc..(graphics) onto windows screen? 
 
Please let me know.Sample code would greatly help.</description>
			<content:encoded><![CDATA[<div>Hi ,<br />
<br />
Is there a way that I can draw lines or circles etcc..(graphics) onto windows screen?<br />
<br />
Please let me know.Sample code would greatly help.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>danibootstrap</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238641.html</guid>
		</item>
		<item>
			<title>How to open and external file or program using C</title>
			<link>http://www.daniweb.com/forums/thread238640.html</link>
			<pubDate>Sun, 15 Nov 2009 12:31:41 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I want to write code for opening an external file or program from the C program.Could anyone tell me how to do this? 
 
Say if I want to open calculator.exe I mention the path in the program and it should open it or say if I want to open "image.jpg" with the default program...How shall I do...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I want to write code for opening an external file or program from the C program.Could anyone tell me how to do this?<br />
<br />
Say if I want to open calculator.exe I mention the path in the program and it should open it or say if I want to open &quot;image.jpg&quot; with the default program...How shall I do this?<br />
<br />
Any sample code would be of great help.<br />
<br />
Thanks in advance</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>danibootstrap</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238640.html</guid>
		</item>
		<item>
			<title>Operarors in C?</title>
			<link>http://www.daniweb.com/forums/thread238622.html</link>
			<pubDate>Sun, 15 Nov 2009 10:00:41 GMT</pubDate>
			<description>Hi 
 
Anyonem, could you please explain clearly about the order of evaluation of increment, decrement operators in an expression in C? 
 
 
Thanks in advance..</description>
			<content:encoded><![CDATA[<div>Hi<br />
<br />
Anyonem, could you please explain clearly about the order of evaluation of increment, decrement operators in an expression in C?<br />
<br />
<br />
Thanks in advance..</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>jk2005.jeeva</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238622.html</guid>
		</item>
		<item>
			<title>problem with struct creation</title>
			<link>http://www.daniweb.com/forums/thread238617.html</link>
			<pubDate>Sun, 15 Nov 2009 09:06:11 GMT</pubDate>
			<description><![CDATA[Hi,   
I would like to make a database with users. 
But I take errors in the function 
 
Could someone help me please? 
 
My code is : 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hi,  <br />
I would like to make a database with users.<br />
But I take errors in the function<br />
<br />
Could someone help me please?<br />
<br />
My code is :<br />
<br />
 <pre style="margin:20px; line-height:13px">typedef struct user user;<br />
<br />
int id2=0;<br />
<br />
struct user<br />
{<br />
&nbsp;  char name[20];<br />
&nbsp; char last[20];<br />
&nbsp; int id;<br />
};<br />
<br />
int function(user* users, int id, char name[], char surname[]){<br />
user* u = users+id2;<br />
strcpy(u-&gt;name,name1);<br />
strcpy(u-&gt;surname,surname1);<br />
u-&gt;id=id2;<br />
}<br />
<br />
main()<br />
{<br />
&nbsp; char name1[20];<br />
&nbsp; char surname1[20];<br />
&nbsp; users[50];<br />
<br />
if(function(users, id,name1,surname1))<br />
&nbsp; &nbsp; ++id2;<br />
<br />
// and then I would like to print name,surname,id form created struct ..... ??<br />
}</pre><br />
Thanks a lot</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>bufospro</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238617.html</guid>
		</item>
		<item>
			<title><![CDATA[error C2059: syntax error : '<']]></title>
			<link>http://www.daniweb.com/forums/thread238600.html</link>
			<pubDate>Sun, 15 Nov 2009 07:19:01 GMT</pubDate>
			<description><![CDATA[hello guys, 
 
I get this error MSG and I can't understand what is the problem with my code. my program consist a menu with 5 options: 
1. The program remove double digit from a given number. 
2. The program rotate the first number to the right according to the second number. 
3. The program checks...]]></description>
			<content:encoded><![CDATA[<div>hello guys,<br />
<br />
I get this error MSG and I can't understand what is the problem with my code. my program consist a menu with 5 options:<br />
1. The program remove double digit from a given number.<br />
2. The program rotate the first number to the right according to the second number.<br />
3. The program checks if the 2 numbers are permmutations of each other.<br />
4. The program search how many times the second number appear in the first number,<br />
9. Exit.<br />
<br />
I know it's very long but please try to help me, I really don't have a clue. All programs work fine when I run them in a seperate file but when I put them all together I get this error so I assume there's something wrong with the menu.<br />
<br />
cheers,<br />
Elad.</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=12561&amp;d=1258269343">site.txt</a> (4.9 KB)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>redroze</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238600.html</guid>
		</item>
		<item>
			<title>Need Help Translating</title>
			<link>http://www.daniweb.com/forums/thread238587.html</link>
			<pubDate>Sun, 15 Nov 2009 03:56:57 GMT</pubDate>
			<description><![CDATA[Hi,  
I was wondering if anyone can help me translate this into java. 
Thanks 
  <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>Hi, <br />
I was wondering if anyone can help me translate this into java.<br />
Thanks<br />
 <pre style="margin:20px; line-height:13px">#include &quot;Element.h&quot;<br />
#include &lt;stdlib.h&gt;<br />
<br />
element * Element(int s1, int w1, double c1, int x1, int k1)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; element * retval = malloc(sizeof(element));<br />
&nbsp; &nbsp; &nbsp; &nbsp; retval-&gt;s = s1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; retval-&gt;w = w1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; retval-&gt;c = (float) s1 / (float) w1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; retval-&gt;x = x1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; retval-&gt;k = k1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return retval;<br />
}</pre> <pre style="margin:20px; line-height:13px">typedef struct<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int s; //value of coin<br />
&nbsp; &nbsp; &nbsp; &nbsp; int w; // weight of coin<br />
&nbsp; &nbsp; &nbsp; &nbsp; float c; // (s / w) <br />
&nbsp; &nbsp; &nbsp; &nbsp; int x; // number of coin to be used<br />
&nbsp; &nbsp; &nbsp; &nbsp; int k; // index of coin of this value in S[n]<br />
} element;<br />
<br />
element * Element(int s1, int w1, double c1, int x1, int k1);</pre> <pre style="margin:20px; line-height:13px">#include &quot;externals.h&quot;<br />
<br />
int B = 7;<br />
int n = N;<br />
<br />
int S[N] = {4, 1, 3};<br />
int X[N];<br />
int W[N];<br />
<br />
element * A[N];<br />
element * Solution[N];</pre> <pre style="margin:20px; line-height:13px">#include &quot;Element.h&quot;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;stdio.h&gt;<br />
<br />
#define N 3<br />
<br />
#define new <br />
#define BOOL int<br />
#define FALSE 0<br />
#define TRUE 1<br />
<br />
<br />
extern int B;<br />
extern int n;<br />
<br />
extern int S[N];<br />
extern int X[N];<br />
extern int W[N];<br />
<br />
extern element * A[N];<br />
extern element * Solution[N];</pre> <pre style="margin:20px; line-height:13px">#include &quot;functions.h&quot;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;math.h&gt;<br />
<br />
<br />
/**************************************************************<br />
&nbsp;Algorithm:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sort<br />
&nbsp;<br />
&nbsp;Parameters:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; an array of pointers to element objects.<br />
&nbsp;<br />
&nbsp;Description:&nbsp; &nbsp; &nbsp; &nbsp; algorithm looks at the &quot;value density&quot; (c) of <br />
&nbsp;the objects and sorts them upon that parameter<br />
&nbsp;in non-increasing order.<br />
&nbsp;<br />
&nbsp;Side Effects:&nbsp; &nbsp; &nbsp; &nbsp; algorithm modifies global array &quot;A&quot;<br />
&nbsp;parameter is technically not used, but<br />
&nbsp;replacement of &quot;A&quot; with the parameter<br />
&nbsp;will cause effect to be on the parameter<br />
&nbsp;this is strictly unecessary in this particular<br />
&nbsp;algorithm<br />
&nbsp;**************************************************************/<br />
void Sort(element * array[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; element * largest;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i, j;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; n; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; largest = A[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (j = i; j &lt; n; j++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (A[j]-&gt;c &gt; largest-&gt;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; largest = A[j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[j] = A[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[i] = largest;<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; }<br />
}<br />
<br />
<br />
<br />
<br />
/**************************************************************<br />
&nbsp;Algorithm:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Greedy<br />
&nbsp;<br />
&nbsp;Parameters:&nbsp; &nbsp; &nbsp; &nbsp; A &quot;remainder&quot; (number to be consumed), and an<br />
&nbsp;integer &quot;i&quot; marked as a starting index for<br />
&nbsp;manipulations on global array.<br />
&nbsp;<br />
&nbsp;Description:&nbsp; &nbsp; &nbsp; &nbsp; A greedy algorithm to increase the concentrations<br />
&nbsp;of each object in the sorted array to consume as<br />
&nbsp;much of the remainder as possible given the<br />
&nbsp;starting element lovcated at the index.<br />
&nbsp;<br />
&nbsp;Side Effects:&nbsp; &nbsp; &nbsp; &nbsp; The algorithm modifies both global arrays &quot;A&quot; <br />
&nbsp;(necessarily) and &quot;Solution&quot; (conditionally). <br />
&nbsp;Producing viable solutions to the value partitioning<br />
&nbsp;problem, and replacing the global solution<br />
&nbsp;if the local one is more efficient based on the<br />
&nbsp;constraints of the problem.<br />
&nbsp;**************************************************************/<br />
void Greedy(int remainder, int i)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; number = floor(remainder / A[i]-&gt;s);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; A[i]-&gt;x = number;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (totalValue(A, 0, N-1) == B) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!Solution[0] || totalWeight(A, 0, N-1) &lt; totalWeight(Solution, 0, N-1)) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; copyArr(A, Solution);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if (i == (N-1))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<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; Greedy((remainder % A[i]-&gt;s), (i+1));<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
<br />
/**************************************************************<br />
&nbsp;Algorithm:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Backtrack<br />
&nbsp;<br />
&nbsp;Parameters:&nbsp; &nbsp; &nbsp; &nbsp; Integers &quot;start&quot; and &quot;stop&quot; marking the indicies<br />
&nbsp;of the global array &quot;A&quot; over which the algorithm<br />
&nbsp;will operate during its call. <br />
&nbsp;<br />
&nbsp;Description:&nbsp; &nbsp; &nbsp; &nbsp; A backtracking algorithm, assuming a pre-sorted<br />
&nbsp;array in &quot;locally greedy&quot; (between the indicies) <br />
&nbsp;concentrations. The algorithm moves slowly between<br />
&nbsp;start and stop, from right to left, decrementing <br />
&nbsp;the concentration of the object at the current<br />
&nbsp;index, calling Greedy() from that point. This<br />
&nbsp;forces a trace over the entire permutation space<br />
&nbsp;of all viable solutions. Comparisons to the global<br />
&nbsp;solution array, as described in documentation above,<br />
&nbsp;are performed in Greedy(). The algorithm recurses<br />
&nbsp;until the entire solution space between the indicies<br />
&nbsp;is mapped. Then returns control to the calling<br />
&nbsp;function. (In terminus, main())<br />
&nbsp;<br />
&nbsp;Side Effects:&nbsp; &nbsp; &nbsp; &nbsp; The algorithm modifies global array &quot;A&quot; directly<br />
&nbsp;and &quot;Solution&quot; indirectly by calling Greedy()<br />
&nbsp;which has this known side effect.<br />
&nbsp;**************************************************************/<br />
void Backtrack(int stop, int start)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int dec_pos = start;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (TRUE) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (dec_pos &lt; 0) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (A[dec_pos]-&gt;x != 0) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[dec_pos]-&gt;x--;<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; dec_pos--;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Greedy(B-totalValue(A, 0, dec_pos), (dec_pos + 1));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Backtrack((dec_pos + 1), N-2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (dec_pos != stop)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dec_pos--;<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; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
<br />
/**************************************************************<br />
&nbsp;Algorithm:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; totalValue<br />
&nbsp;<br />
&nbsp;Parameters:&nbsp; &nbsp; &nbsp; &nbsp; An array of pointers to element objects<br />
&nbsp;two integers start and end.<br />
&nbsp;<br />
&nbsp;Description:&nbsp; &nbsp; &nbsp; &nbsp; Computes the total value of the objects between<br />
&nbsp;the indicies given their concentrations and<br />
&nbsp;individual values.<br />
&nbsp;<br />
&nbsp;Side Effects:&nbsp; &nbsp; &nbsp; &nbsp; None<br />
&nbsp;**************************************************************/<br />
int totalValue(element * array[], int start, int end)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; register int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int total = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; element * e;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = start; i &lt;= end ; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e = array[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; total += e-&gt;s * e-&gt;x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return total;<br />
}<br />
<br />
<br />
/**************************************************************<br />
&nbsp;Algorithm:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; totalWeight<br />
&nbsp;<br />
&nbsp;Parameters:&nbsp; &nbsp; &nbsp; &nbsp; An array of pointers to element objects<br />
&nbsp;two integers start and end.<br />
&nbsp;<br />
&nbsp;Description:&nbsp; &nbsp; &nbsp; &nbsp; Computes the total weight of the objects between<br />
&nbsp;the indicies given their concentrations and<br />
&nbsp;individual weights.<br />
&nbsp;<br />
&nbsp;Side Effects:&nbsp; &nbsp; &nbsp; &nbsp; None<br />
&nbsp;**************************************************************/<br />
int totalWeight(element * array[], int start, int end)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; register int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int total = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; element * e;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = start; i &lt;= end ; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e = array[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; total += e-&gt;w * e-&gt;x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return total;<br />
}<br />
<br />
<br />
//prints the entire array to STDIO<br />
void printArr(element * array[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; register int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; N; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%i, &quot;, array[i]-&gt;x);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
}<br />
<br />
<br />
//prints elements and their values to STDIO, used for debugging and for useful info<br />
void printElements(element * array[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; register int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; N; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%i:\n\t%i\n\t%i\n\t%i\n\t%f\n\n&quot;, i, array[i]-&gt;s, array[i]-&gt;w, array[i]-&gt;k, array[i]-&gt;c);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
//copies the contents of one array of element objects into another to preserve the values.<br />
void copyArr(element * source[], element * target[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; register int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; N; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element * old_e = source[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element * new_e = new Element(old_e-&gt;s, old_e-&gt;w, old_e-&gt;c, old_e-&gt;x, old_e-&gt;k);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; target[i] = new_e;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
<br />
/**************************************************************<br />
&nbsp;Algorithms:&nbsp; &nbsp; &nbsp; &nbsp; initialization functions<br />
&nbsp;<br />
&nbsp;Parameters:&nbsp; &nbsp; &nbsp; &nbsp; None<br />
&nbsp;<br />
&nbsp;Description:&nbsp; &nbsp; &nbsp; &nbsp; Computes the weight values for each object based<br />
&nbsp;on the total function w() given as input in this<br />
&nbsp;assignment. The array of objects &quot;A&quot; is constructed.<br />
&nbsp;The first element in &quot;Solution&quot; is set to NULL to <br />
&nbsp;prevent a segfault when first checking against the<br />
&nbsp;total weight in Greedy().<br />
&nbsp;<br />
&nbsp;Side Effects:&nbsp; &nbsp; &nbsp; &nbsp; Global arrays W, A, and Solution are modified.<br />
&nbsp;**************************************************************/<br />
<br />
void initialize()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Solution[0] = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; initialize_W();<br />
&nbsp; &nbsp; &nbsp; &nbsp; initialize_A();<br />
}<br />
<br />
void initialize_A()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; register int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; N; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A[i] = new Element(S[i], W[i], 1, 0, i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
void initialize_W()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; register int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; N; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; W[i] = w(S[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
<br />
//total function w given in the assignment, this can be any total function on the set of real integers<br />
//it is currently set to return 1, as the last step in debugging was to check the condition for objects<br />
//with equal weight. <br />
int w(int s)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
}</pre> <pre style="margin:20px; line-height:13px">#include &quot;externals.h&quot;<br />
<br />
void Sort(element * array[]);<br />
void Greedy(int remainder, int i);<br />
void Backtrack(int stop, int start);<br />
<br />
int totalValue(element * array[], int start, int end);<br />
int totalWeight(element * array[], int start, int end);<br />
<br />
void printArr(element * array[]);<br />
void printElements(element * array[]);<br />
void copyArr(element * source[], element * target[]);<br />
<br />
void initialize();<br />
void initialize_A();<br />
void initialize_W();<br />
int w(int s);</pre> <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &quot;functions.h&quot;<br />
<br />
int main (int argc, const char * argv[]) <br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; initialize();<br />
&nbsp; &nbsp; &nbsp; &nbsp; Sort(A);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printElements(A);<br />
&nbsp; &nbsp; &nbsp; &nbsp; Greedy(B, 0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; Backtrack(0, N-2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (totalValue(Solution, 0, N-1) != B) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;No Solution\n&quot;);<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; printArr(Solution);<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>vampgirl13</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238587.html</guid>
		</item>
		<item>
			<title>arrays</title>
			<link>http://www.daniweb.com/forums/thread238549.html</link>
			<pubDate>Sat, 14 Nov 2009 21:53:14 GMT</pubDate>
			<description><![CDATA[I am trying to write a program that reads a string and shortens it if the letters are in a row. For instance abcdghigjhkhdf becomes a-dg-igkhkhdf. I want that it erases the ;etters it erases but it is not working. HEre is my code: 
  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>I am trying to write a program that reads a string and shortens it if the letters are in a row. For instance abcdghigjhkhdf becomes a-dg-igkhkhdf. I want that it erases the ;etters it erases but it is not working. HEre is my code:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
<br />
#define MAXSTRING 100 <br />
void main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char str[MAXSTRING]={0};<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Please input a string of letters without a space or numbers.&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf_s(&quot;%s&quot;, &amp;str);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; convertString(str);<br />
<br />
}<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; void convertString(char string[])<br />
&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; char startOfNewConinuation=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (string[i]!= 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (string[i]!= '-')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startOfNewConinuation=string[i];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((string[i+1]=string[i]+1) &amp;&amp; (startOfNewConinuation=string[i]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string[i+1]='-';<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; string[i]='';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nThe new string is %s&quot;,string);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>leeba</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238549.html</guid>
		</item>
		<item>
			<title>Passing a pointer</title>
			<link>http://www.daniweb.com/forums/thread238515.html</link>
			<pubDate>Sat, 14 Nov 2009 18:08:54 GMT</pubDate>
			<description><![CDATA[In an assignment for class we have to ask the user how many characters they'd like to enter and then read the characters into an array of that size. I've had problems with calling a function to do this. I will also be passing this array to other functions, so I'm not sure if anything has to be...]]></description>
			<content:encoded><![CDATA[<div>In an assignment for class we have to ask the user how many characters they'd like to enter and then read the characters into an array of that size. I've had problems with calling a function to do this. I will also be passing this array to other functions, so I'm not sure if anything has to be modified either.<br />
<br />
This is what I've done so far<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
void Test(char, int);<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; char *text;<br />
&nbsp; &nbsp; int i, size, *sizeptr;<br />
&nbsp; &nbsp; sizeptr = &amp;size;<br />
&nbsp; &nbsp; Test(text, size);<br />
&nbsp; &nbsp; for(i = 0; i &lt; size; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; putchar(text[i]);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; system(&quot;PAUSE&quot;);<br />
&nbsp; &nbsp; return(0);<br />
}<br />
<br />
void Test(char *text, int *sizeptr)<br />
{<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; printf(&quot;How many characters do you want to enter?\t&quot;);<br />
&nbsp; &nbsp; scanf(&quot;%d&quot;, sizeptr);<br />
&nbsp; &nbsp; text = (char*) malloc(*sizeptr * sizeof(char));<br />
&nbsp; &nbsp; memset(text, 0, *sizeptr);<br />
&nbsp; &nbsp; printf(&quot;Enter your text: (DO NOT INCLUDE SPACES)\n&quot;);<br />
&nbsp; &nbsp; scanf(&quot;%s&quot;, text);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>kgomes</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238515.html</guid>
		</item>
		<item>
			<title>Parsing in C</title>
			<link>http://www.daniweb.com/forums/thread238496.html</link>
			<pubDate>Sat, 14 Nov 2009 14:25:32 GMT</pubDate>
			<description><![CDATA[Hi,  
 
I'm new to this site so apologies for any mistakes. I'm trying to write a program to parse string from a file. In each string I then have to parse the different strings for example: 
 
add  h'13', 4 
 
So I've to parse the 'add' bit, the '13' bit and the '4' bit. At the minute I'm trying to...]]></description>
			<content:encoded><![CDATA[<div>Hi, <br />
<br />
I'm new to this site so apologies for any mistakes. I'm trying to write a program to parse string from a file. In each string I then have to parse the different strings for example:<br />
<br />
add  h'13', 4<br />
<br />
So I've to parse the 'add' bit, the '13' bit and the '4' bit. At the minute I'm trying to use strtok but I'm getting a run time error. <br />
<br />
 <pre style="margin:20px; line-height:13px">/* Libraries */<br />
#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
/* Main Function */<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* Declarations */<br />
&nbsp; &nbsp; char *instruction;<br />
&nbsp; &nbsp; char *action;<br />
&nbsp; &nbsp; char *number;<br />
&nbsp; &nbsp; char *number2;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; instruction = &quot;add&nbsp; h'13', 4&quot;;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; printf(&quot;%s \n&quot;,instruction);<br />
<br />
// The run time error occurs here<br />
<br />
&nbsp; &nbsp; action = strtok ( instruction, &quot; &quot; );<br />
&nbsp; &nbsp; number = strtok ( NULL, &quot; ' &quot; );<br />
number2 = strtok ( NULL, &quot;,&quot; );<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%s \n %s \n %s \n&quot;, action, number, number2);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;PAUSE&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre><br />
Any help you can give me would be greatly appreciated. Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>pmee</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238496.html</guid>
		</item>
		<item>
			<title>Remove Duplicate Items from char Array</title>
			<link>http://www.daniweb.com/forums/thread238452.html</link>
			<pubDate>Sat, 14 Nov 2009 08:08:56 GMT</pubDate>
			<description><![CDATA[What is the method to remove dupplicate items from an character array?? 
 
A Sample Program is Here which take two arrays merge them and sort them please include some lines that should remove duplicates from an resulted array?? 
 
 
  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>What is the method to remove dupplicate items from an character array??<br />
<br />
A Sample Program is Here which take two arrays merge them and sort them please include some lines that should remove duplicates from an resulted array??<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
<br />
&nbsp; <br />
// A simple bubble sort<br />
void sort(char data[], int length)<br />
{<br />
&nbsp;  int end = length - 1;<br />
&nbsp;  for (int i = 0; i &lt; length; ++i) <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  for (int j = 0; j &lt; end; ++j) <br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (data[j] &gt; data[j+1])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  char tmp = data[j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  data[j] = data[j+1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  data[j+1] = tmp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  --end;<br />
&nbsp;  }<br />
}<br />
<br />
int main(void)<br />
{<br />
&nbsp;  char firstArray[10];<br />
&nbsp;  char secondArray[10];<br />
&nbsp;  char mergedArray[20];<br />
<br />
&nbsp;  int i;<br />
&nbsp;  int mergedIndex;<br />
<br />
&nbsp;  printf(&quot;Put in the first array\n&quot;);<br />
&nbsp;  fgets(firstArray, sizeof(firstArray), stdin);<br />
<br />
&nbsp;  printf(&quot;Put in the second array\n&quot;);<br />
&nbsp;  fgets(secondArray, sizeof(secondArray), stdin);<br />
<br />
&nbsp;  // Copy the first array into the merged array<br />
&nbsp;  for(i = 0; firstArray[i] != '\n'; ++i)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  mergedArray[i] = firstArray[i];<br />
&nbsp;  }<br />
&nbsp;  mergedIndex = i;<br />
&nbsp;  for(i = 0; secondArray[i] != '\n'; ++i)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  mergedArray[mergedIndex++] = secondArray[i];<br />
&nbsp;  }<br />
&nbsp;  mergedArray[mergedIndex] = 0;<br />
<br />
&nbsp;  sort(mergedArray, mergedIndex);<br />
&nbsp;  printf(&quot;Merged array is '%s'\n&quot;, mergedArray);<br />
&nbsp;  return 0;<br />
}</pre><br />
Thanks inAdvance</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>voxis</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238452.html</guid>
		</item>
		<item>
			<title>Help with loops</title>
			<link>http://www.daniweb.com/forums/thread238431.html</link>
			<pubDate>Sat, 14 Nov 2009 04:52:01 GMT</pubDate>
			<description><![CDATA[My 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 with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>C...]]></description>
			<content:encoded><![CDATA[<div>My code: <br />
 <pre style="margin:20px; line-height:13px">&nbsp; printf(&quot;\n&quot;); <br />
&nbsp; printf(&quot;\tSlalom Race, Version 1.0\t\t\n\n&quot;);<br />
&nbsp; printf(&quot;1. Play\n&quot;);<br />
&nbsp; printf(&quot;2. Instructions\n&quot;); <br />
&nbsp; printf(&quot;3. Quit\n\n&quot;); <br />
&nbsp; printf(&quot;Your choice: &quot;); <br />
&nbsp; scanf(&quot;%d&quot;, &amp;choice); <br />
&nbsp; }&nbsp; <br />
&nbsp;<br />
&nbsp; /* Initializes loop to begin game */ <br />
&nbsp; while (choice != 3) { <br />
&nbsp;<br />
&nbsp; /* Begins execution of game and Selects instructions if needed */ <br />
&nbsp; while (choice == 1) { <br />
&nbsp; printf(&quot;You are at the start.\n&quot;); <br />
&nbsp;  printf(&quot;Time elapsed: 0.000000 sec\n&quot;); <br />
&nbsp; printf(&quot;Current velocity: 0.000000 m/sec\n&quot;); <br />
&nbsp; printf(&quot;Next Gate: 1. Velocity limit: 10.00 m/sec\n&quot;); <br />
&nbsp;  printf(&quot;Your action (1 - 7):&quot;); <br />
&nbsp;  scanf(&quot;%d&quot;, &amp;accelComand); <br />
&nbsp;<br />
<br />
&nbsp;  /* Determines if the command is in between 1 and 7 */ <br />
&nbsp;  while (!(accelComand &lt;=SEVEN) || !(accelComand &gt;= 1)) { <br />
&nbsp;  printf(&quot;Your action (1 - 7):&quot;); <br />
&nbsp;  scanf(&quot;%d&quot;, &amp;accelComand); <br />
&nbsp;  } <br />
&nbsp;<br />
&nbsp; &nbsp; /* Calculates velocity and time of Leg1 */ <br />
&nbsp;  accelLeg1 = acceleration[accelComand-1]; <br />
&nbsp;  velLeg1 = sqrt(TWO*accelLeg1*FIFTY); <br />
&nbsp;  timeLeg1 = (velLeg1 / accelLeg1); <br />
&nbsp;  printf(&quot;\n\n&quot;); <br />
&nbsp;<br />
&nbsp;  if (velLeg1 &gt; 10) { <br />
&nbsp;  printf(&quot;\n\n\n&quot;);<br />
&nbsp; &nbsp; printf(&quot;Your velocity at gate 1 was %f m/sec\n&quot;,velLeg1); <br />
&nbsp;  printf(&quot;You have lost control and went into&quot;); <br />
&nbsp;  printf(&quot; a nearby snow pile!\n&quot;);<br />
&nbsp; &nbsp; printf(&quot;You failed the race and went&quot;); <br />
&nbsp;  printf(&quot; face down into the snow!\n&quot;); <br />
&nbsp;  printf(&quot;Better luck next time!\n&quot;); <br />
&nbsp;<br />
&nbsp; &nbsp; } <br />
&nbsp;else { <br />
&nbsp; if (velLeg1 &lt;= 0) {<br />
&nbsp;  printf(&quot;You stopped before reaching the gate.\n&quot;); <br />
&nbsp; printf(&quot;Your attempt to pick up the speed laned you&quot;); <br />
&nbsp; printf(&quot; in a snow pile.\n&quot;); <br />
&nbsp; printf(&quot;You failed the race due to your&quot;); <br />
&nbsp; printf(&quot;overburdening caution.\n&quot;); <br />
&nbsp; printf(&quot;Better luck next time.\n&quot;);<br />
&nbsp; }<br />
&nbsp;  } <br />
&nbsp; printf(&quot;\n&quot;); <br />
&nbsp; printf(&quot;You are at Gate 1\n&quot;); <br />
&nbsp; printf(&quot;Time elapsed: %f sec\n&quot;, timeLeg1);<br />
&nbsp;  printf(&quot;Current velocity: %f m/sec\n&quot;,velLeg1); <br />
&nbsp;  p rintf(&quot;Next Gate: 2. Velocity limit: 18.00 m/sec\n&quot;); <br />
&nbsp; &nbsp; printf(&quot;Your action (1 - 7):&quot;); 60. scanf(&quot;%d&quot;, &amp;accelComand);</pre><br />
As you can see my code asks the user to input 3 numbers: 1,2,3 in lines 1-7. My only concern is when they choose 1. When they select &quot;1&quot;, game execution begins and depending on the given command (the command itself is the acceleration which determines the time and velocity) lines 34 - 51 will determine the output of lines 54-60. If one of the conditions are satisfied in lines 34-51 THEN the program will go back in asking the user in lines 1-7 again. That is my problem, i dont know what to put in lines 34-51 if one of the conditions are satisfied and go back in asking the user in lines 1-7. Any suggestions?????</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>speedy94519</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238431.html</guid>
		</item>
		<item>
			<title>help making MakeFile</title>
			<link>http://www.daniweb.com/forums/thread238411.html</link>
			<pubDate>Sat, 14 Nov 2009 01:20:09 GMT</pubDate>
			<description><![CDATA[I am suppose to make a MakeFile for the 2 source files named p4a.c and p4b.c 
Am i doing this makefile correctly? Any suggestions would be so helpful 
 
my MakeFile so far 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>I am suppose to make a MakeFile for the 2 source files named p4a.c and p4b.c<br />
Am i doing this makefile correctly? Any suggestions would be so helpful<br />
<br />
my MakeFile so far<br />
<br />
 <pre style="margin:20px; line-height:13px">.SUFFIXES: .c .o<br />
CC - gcc<br />
CFLAGS = -g<br />
.c.o:<br />
&nbsp; &nbsp;  $(CC) $(CFLAGS) -c $,<br />
<br />
sample: p4a.c p4b.c<br />
&nbsp; &nbsp; &nbsp;  gcc p4a.c p4b.c -o sample<br />
<br />
p4a.c:<br />
<br />
p4b.c:<br />
<br />
clean:<br />
&nbsp; &nbsp; &nbsp;  rm -f *.o core</pre><br />
<br />
p4a.c<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
#include&lt;string.h&gt;<br />
<br />
<br />
main(int argc,char* argv[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; short int a[100][5];<br />
&nbsp; &nbsp; &nbsp; &nbsp; short int res;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; FILE *fp1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(!(fp1=fopen(argv[1],&quot;r&quot;)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Error opening file\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; FILE *fp2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i,j,k,l;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i=j=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(!feof(fp1))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(j=0;j&lt;4;j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fscanf(fp1,&quot;%d&quot;,&amp;a[i][j]); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&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; for(k=0;k&lt;i;k++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unsigned short int musk=!0; //musk=11...111<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; musk=musk|15;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //musk=000..001111<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; musk=musk&lt;&lt;12;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //musk=111100..000<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; res=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(l=0;l&lt;4;l++)<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; short int temp=(a[k][l]&amp;musk);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res=res|temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; musk=musk&gt;&gt;4;<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; a[k][4]=res;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!(fp2=fopen(argv[2],&quot;w&quot;)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Error:cannot open file&quot;);<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; for(k=0;k&lt;i;k++)<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; for(j=0;j&lt;5;j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp2,&quot;%d%s&quot;,a[k][j],&quot;\t&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp2,&quot;%s&quot;,&quot;\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; fclose(fp1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fclose(fp2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
}<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre><br />
p4b.c<br />
<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 />
typedef struct token<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char name[15];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int def,usecount,use[100];<br />
}identifier;<br />
<br />
identifier id[1000];<br />
int idcounter;<br />
<br />
void search(char* token,int linenum)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i=0;i&lt;idcounter;i++)&nbsp; &nbsp; &nbsp; &nbsp; //check if already exist<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!strcmp(token,id[i].name))&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; &nbsp; &nbsp; &nbsp; &nbsp; id[i].use[id[i].usecount]=linenum;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id[i].usecount++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; //insert<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcpy(id[idcounter].name,token);<br />
&nbsp; &nbsp; &nbsp; &nbsp; id[idcounter].def=linenum;<br />
&nbsp; &nbsp; &nbsp; &nbsp; id[idcounter].usecount=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; idcounter++;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
}<br />
<br />
void check(char line[81],int linenum)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char token1[15];<br />
&nbsp; &nbsp; &nbsp; &nbsp; char* token=(char*)malloc(sizeof(char)*15);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(line[0]=='_' || (line[0]&gt;='a' &amp;&amp; line[0]&lt;='z') || (line[0]&gt;='A' &amp;&amp; line[0]&lt;='Z'))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token=strtok(line,&quot; ,\t&quot;);&nbsp; &nbsp; &nbsp; &nbsp; //take label<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(token1,token);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(token1[strlen(token1)-1]==':')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token1[strlen(token1)-1]='\0';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; search(token1,linenum);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token=strtok(0,&quot; ,\t&quot;);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //skip opcode\datatype<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(token1,token);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(token1[0]=='.')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //check data type<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(token)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token=strtok(0,&quot; ,\t&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(token)<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; strcpy(token1,token);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(token1[0]=='#')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //start of comment<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(token1[0]=='_' || (token1[0]&gt;='a' &amp;&amp; token1[0]&lt;='z') || (token1[0]&gt;='A' &amp;&amp; token1[0]&lt;='Z'))<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(token1[strlen(token)-1]=='\n')<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; token1[strlen(token)-1]='\0';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; search(token1,linenum);<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; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token=strtok(line,&quot; ,\t&quot;);&nbsp; &nbsp; &nbsp; &nbsp; //skip opcode<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token=strtok(0,&quot; ,\t&quot;);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //search for optional operands<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(token)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(token1,token);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(token1[0]=='#')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //start of comment<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(token1[0]=='_' || (token1[0]&gt;='a' &amp;&amp; token1[0]&lt;='z') || (token1[0]&gt;='A' &amp;&amp; token1[0]&lt;='Z'))<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; if(token1[strlen(token)-1]=='\n')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token1[strlen(token)-1]='\0';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; search(token1,linenum);<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; token=strtok(0,&quot; ,\t&quot;);&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
main(int argc,char* argv[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char line[81],line2[81];&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int i,linenum,p,q;<br />
&nbsp; &nbsp; &nbsp; &nbsp; FILE *fp1,*fp2;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(argc!=3)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //check invalid command<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Invalid command argument number\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(!(fp1=fopen(argv[1],&quot;r&quot;)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Error opening inputfile\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(!(fp2=fopen(argv[2],&quot;w&quot;)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Error opening outputfile\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; linenum=i=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(fgets(line,81,fp1))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(line[0]=='#')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //fputs(strcat(strcat(itoa(i,str,100),&quot;.&nbsp; &quot;),line),fp2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //fputs(&quot;\n&quot;,fp2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp2,&quot;%d%s&quot;,i,&quot;.&nbsp; &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fputs(line,fp2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; linenum++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(strlen(line)&gt;1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(line2,line);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp2,&quot;%d%s&quot;,i,&quot;.&nbsp; &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fputs(line2,fp2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //fputs(strcat(strcat(itoa(i,str,100),&quot;.&nbsp; &quot;),line2),fp2);&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; check(line,linenum);&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; &nbsp; &nbsp; &nbsp; &nbsp; linenum++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //printf(&quot;%d.\t%s&quot;,i,line);<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; fputs(line,fp2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //fputs(&quot;\n&quot;,fp2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; linenum++;<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; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp2,&quot;%s&quot;,&quot;\n\n\tCross Reference Table\n&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp2,&quot;%s&quot;,&quot;\n\nname\t\t def\t \tuse\n\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(p=0;p&lt;idcounter;p++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp2,&quot;%s\t\t%d\t\t&quot;,id[p].name,id[p].def);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(q=0;q&lt;id[p].usecount;q++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(q==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp2,&quot;%d&quot;,id[p].use[q]);<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; fprintf(fp2,&quot;%c%d&quot;,',',id[p].use[q]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp2,&quot;%s&quot;,&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; fclose(fp1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; fclose(fp1);<br />
<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>cabosun</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238411.html</guid>
		</item>
		<item>
			<title>fread() and fseek()</title>
			<link>http://www.daniweb.com/forums/thread238369.html</link>
			<pubDate>Fri, 13 Nov 2009 19:44:40 GMT</pubDate>
			<description><![CDATA[If I am fread()'ing through a file and want to append it when i find a particular item, can i just do an fwrite() when i find it or do i have to first fseek() to that location and then do an fwrite()?]]></description>
			<content:encoded><![CDATA[<div>If I am fread()'ing through a file and want to append it when i find a particular item, can i just do an fwrite() when i find it or do i have to first fseek() to that location and then do an fwrite()?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>candoc</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238369.html</guid>
		</item>
		<item>
			<title>Decide number of arguments in vararg method</title>
			<link>http://www.daniweb.com/forums/thread238360.html</link>
			<pubDate>Fri, 13 Nov 2009 18:56:51 GMT</pubDate>
			<description><![CDATA[I've written a method that takes a variable number of arguments. My problem is that the method is supposed to do one thing if there is only one argument, and something different if it recieves multiple arguments. 
If it's one argument I'm supposed to get info from a global variable, but if its more...]]></description>
			<content:encoded><![CDATA[<div>I've written a method that takes a variable number of arguments. My problem is that the method is supposed to do one thing if there is only one argument, and something different if it recieves multiple arguments.<br />
If it's one argument I'm supposed to get info from a global variable, but if its more than one I'm getting the info from the last argument given.<br />
<br />
Here is what the method looks like and what it does when there is multiple arguments. Since the last argument always is 4 digits I know when to stop the for loop. <br />
<br />
 <pre style="margin:20px; line-height:13px">//Sends the message<br />
void sendMessage(int tlfNumber1, ...) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Initiating va_list element<br />
&nbsp; &nbsp; &nbsp; &nbsp; va_list argumentList;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Starting/getting the parameters<br />
&nbsp; &nbsp; &nbsp; &nbsp; va_start(argumentList, tlfNumber1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int j;<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Looping all the elements<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (i = tlfNumber1; j != 4; i = va_arg(argumentList, int)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Checking what parameter it is by converting the int argument to string and check the length of the string.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  * If the argument was 4 digits it was the message_ID and therefore the last argument.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char paramAsString&#91;20&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sprintf(paramAsString, &quot;%d&quot;, i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = strlen(paramAsString);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d &quot;, j);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre><br />
So I need som way to check the number of arguments passed to this method.<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>siggivara</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238360.html</guid>
		</item>
		<item>
			<title>C program for writing test cases</title>
			<link>http://www.daniweb.com/forums/thread238294.html</link>
			<pubDate>Fri, 13 Nov 2009 14:43:45 GMT</pubDate>
			<description>Code Exercise – BIQ-001 
Mr.X owns a small business in a region with poor law-and-order. Recently his warehouse has been plagued by thieves. Gangs of thieves raid over his warehouse from time to time, stealing his raw material, affecting his business. He has studied the occurrances and noticed it...</description>
			<content:encoded><![CDATA[<div>Code Exercise – BIQ-001<br />
Mr.X owns a small business in a region with poor law-and-order. Recently his warehouse has been plagued by thieves. Gangs of thieves raid over his warehouse from time to time, stealing his raw material, affecting his business. He has studied the occurrances and noticed it that they are cyclical.<br />
<br />
Assuming that a work week starts every Monday, and Sat and Sun are holidays, predict the total number of days when business would be affected.<br />
<br />
Picture (Metafile) please see attached jpgeg<br />
<br />
e.g. (Refer to Image) He has noticed that currently there seem to be 2 gangs. Gang1 raids every 4 days, whereas Gang2 strikes every 6 days.<br />
<br />
Raids On Holidays are okay - since there is no raw material on those days. If more than gang raids the warehouse on a particular day, it is still counted as one bad day. So the answer in this case is 5.<br />
<br />
Sample Input: (file)<br />
The input is in the form of text file containing test cases.<br />
2<br />
2<br />
4 6<br />
21<br />
3<br />
3 4 8<br />
14<br />
<br />
The first line indicates the number of test cases - 2 above.  Each test case is made up of 3 lines.<br />
The first line of every test case indicates the number of gangs, n. (i.e 2 for TestCase#1)<br />
The next line contains n integers, where each number k indicates that the gangi  strikes every k days. (i.e. 4 and 6 for TestCase#1)<br />
<br />
The next line is the number of days d, for which the prediction is needed. 0 &lt;= d &lt;= 365 (i.e. 21 days for TestCase#1)<br />
<br />
Sample output: (can be printed to console.. via printf or equivalent)<br />
5<br />
5<br />
<br />
Your program should accept the name of the input file (in the same dir) as a command line argument and print out the output of each test case on a new line.</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=12551&amp;d=1258123164" target="_blank">Simulation.jpg</a> (14.5 KB)</td> </tr> </table> </fieldset>   <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/doc.gif" alt="File Type: doc" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12549&amp;d=1258123111">Entrepreneur_X.doc</a> (43.5 KB)</td> </tr><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=12550&amp;d=1258123157">Entrepreneur_X.txt</a> (2.2 KB)</td> </tr> </table> </fieldset>  </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>kirtics34</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238294.html</guid>
		</item>
		<item>
			<title>a simple question about a program</title>
			<link>http://www.daniweb.com/forums/thread238277.html</link>
			<pubDate>Fri, 13 Nov 2009 13:33:13 GMT</pubDate>
			<description><![CDATA[Hi, 
I need your help for my program. 
 
My code is : 
  <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...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
I need your help for my program.<br />
<br />
My code is :<br />
 <pre style="margin:20px; line-height:13px"><br />
void user()<br />
{<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; char str[15];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nPrint str.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fgets(str,15,stdin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = strlen(str);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }while(i&gt;15);<br />
}<br />
<br />
void menu()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Press :\n&quot;); <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;0. \n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;1. \n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;2. \n&quot;);<br />
}<br />
<br />
int get_choice()<br />
{<br />
&nbsp;int choice = 0 ;<br />
&nbsp;const char* const valid_choices = &quot;012&quot; ;<br />
<br />
&nbsp;do<br />
&nbsp;{<br />
&nbsp;  fputs( &quot;Your choice : &quot;, stdout ) ;<br />
&nbsp;  fflush( stdin ) ;<br />
&nbsp;  choice = toupper( fgetc( stdin ) ) ;<br />
&nbsp;  fgetc( stdin ) ;<br />
<br />
&nbsp;  if( strchr(valid_choices, choice) == NULL )<br />
&nbsp;  {<br />
&nbsp; &nbsp;  fputs(&quot;Invalid option.\n&quot;);<br />
&nbsp; &nbsp;  choice = 0 ;<br />
&nbsp;  }<br />
&nbsp;} while( choice == 0 ) ;<br />
<br />
&nbsp;return choice ;<br />
}<br />
<br />
<br />
<br />
main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int choice=0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; do<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  menu() ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  choice = get_choice() ;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch(choice)<br />
&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; case 0: user();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; case 1: break ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 2: break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }while(choice != 2);<br />
&nbsp; <br />
}</pre><br />
When I press string with &lt;15 number of characters all is ok.<br />
But if my str is 17 characters , then is printed two times <br />
'Your choice : Invalid Option'<br />
<br />
Could anyone help me fix it ?<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>bufospro</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238277.html</guid>
		</item>
		<item>
			<title>Finding middle value in C...</title>
			<link>http://www.daniweb.com/forums/thread238265.html</link>
			<pubDate>Fri, 13 Nov 2009 12:12:19 GMT</pubDate>
			<description>Can anyone give me some ideas on how to find the middle value between 3 numbers.? I really dont know how to start...  
 
I know how find minimum and maximum but finding the Middle value is kinda hard for me...  
 
For those C Wizards give me some idea advice please?., just an idea u dont have to...</description>
			<content:encoded><![CDATA[<div>Can anyone give me some ideas on how to find the middle value between 3 numbers.? I really dont know how to start... <br />
<br />
I know how find minimum and maximum but finding the Middle value is kinda hard for me... <br />
<br />
For those C Wizards give me some idea advice please?., just an idea u dont have to give codes... thx!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>DoEds</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238265.html</guid>
		</item>
		<item>
			<title>Can this be done in a faster way?</title>
			<link>http://www.daniweb.com/forums/thread238139.html</link>
			<pubDate>Thu, 12 Nov 2009 22:27:03 GMT</pubDate>
			<description>*Given an array of elements. An element is called as a leader if it is greater than all 
the elements to the right of it. Print all the leaders in O(n)?* 
The following is my approach.Can anyone tell me how to improve the code and also the current time complexity? 
Is recursion more efficient in...</description>
			<content:encoded><![CDATA[<div><span style="font-weight:bold">Given an array of elements. An element is called as a leader if it is greater than all<br />
the elements to the right of it. Print all the leaders in O(n)?</span><br />
The following is my approach.Can anyone tell me how to improve the code and also the current time complexity?<br />
Is recursion more efficient in this case?<br />
 <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
void findLeaders(int a[],int n)<br />
{<br />
&nbsp;int i,j=n-1,flag=0;<br />
&nbsp;for(i=0;i&lt;n;i++)<br />
&nbsp;{<br />
&nbsp;  if(a[i] &gt; a[i+1])<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(a[i]&gt;a[j])<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if((i+1) ==j) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nleader = %d&quot;,a[i]);<br />
&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; else&nbsp;  j--;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; j=n-1;<br />
&nbsp;  }<br />
&nbsp;}<br />
&nbsp;if(!flag)&nbsp; printf(&quot;\nNo leader in the given array\n&quot;);<br />
}<br />
&nbsp;<br />
<br />
int main()<br />
{<br />
&nbsp;int a[100],n=0,i=0;<br />
&nbsp;printf(&quot;\nEnter n:&quot;);<br />
&nbsp;scanf(&quot;%d&quot;,&amp;n);<br />
&nbsp;for(i=0;i&lt;n;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;,&amp;a[i]);<br />
&nbsp;findLeaders(a,n);<br />
&nbsp;printf(&quot;\n\n&quot;);<br />
&nbsp;return 0;<br />
}</pre>Thanks in advance.</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/thread238139.html</guid>
		</item>
		<item>
			<title>Error in network prog. code....</title>
			<link>http://www.daniweb.com/forums/thread238114.html</link>
			<pubDate>Thu, 12 Nov 2009 20:24:10 GMT</pubDate>
			<description><![CDATA[I am trying to run this program but it is giving "unable to open socket" eror.  
i am running this program on a server via putty which is hosted in my univerity server with wireless network. 
the code is : 
 
 
#include <pthread.h> 
#include <netinet/ip.h> 
#include <netinet/tcp.h> 
#include...]]></description>
			<content:encoded><![CDATA[<div>I am trying to run this program but it is giving &quot;unable to open socket&quot; eror. <br />
i am running this program on a server via putty which is hosted in my univerity server with wireless network.<br />
the code is :<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;pthread.h&gt;<br />
#include &lt;netinet/ip.h&gt;<br />
#include &lt;netinet/tcp.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;sys/socket.h&gt;<br />
#include &lt;netinet/in.h&gt;<br />
#include &lt;arpa/inet.h&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;linux/if.h&gt;<br />
#include &lt;sys/ioctl.h&gt;<br />
<br />
#define PROTOCOL htons(0x0800)<br />
#define BUFFERLENGTH 1500<br />
<br />
char *r_cInterface = NULL;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //stores the name of interface to be captured from<br />
int r_iTime = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //time for which sniffer will run<br />
int sock;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //socket to be opened and programmed for capturing<br />
long r_lPacketCount = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //no of packets captured<br />
int r_iContinue = 1;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //usd for thread<br />
struct ip *r_pIPHeader = NULL;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //ipheader<br />
<br />
pthread_t r_Capture;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //capturing thread<br />
void initializeInterface (char *r_cInterface);&nbsp; &nbsp; &nbsp; &nbsp; //programs interface in promic mode<br />
void *captureTraffic(void * args);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //capture packets from interface and displays <br />
void capture_start ();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //start capturing thread<br />
void capture_stop ();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //stop capturing thread<br />
<br />
void initializeInterface(char *r_cInterface)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; struct ifreq ifr;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //structure to hold interface data<br />
&nbsp; &nbsp; &nbsp; &nbsp; strcpy (ifr.ifr_name, r_cInterface);&nbsp; &nbsp; &nbsp; &nbsp; //copy name of interface into structure<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( (sock=socket(PF_PACKET,SOCK_DGRAM,PROTOCOL)) &lt; 0)&nbsp; &nbsp; &nbsp; &nbsp; //open socket on interface<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nUnable to open Socket&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(EXIT_FAILURE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((ioctl (sock , SIOCGIFFLAGS , &amp;ifr)) &lt; 0)&nbsp; &nbsp; &nbsp; &nbsp; // get flags of socket into structure<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close (sock);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nUnable to get flags&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit (EXIT_FAILURE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ifr.ifr_flags |= IFF_PROMISC;&nbsp; &nbsp; &nbsp; &nbsp; //set flags to promisc<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ioctl (sock , SIOCSIFFLAGS , &amp;ifr) &lt; 0)&nbsp; &nbsp; &nbsp; &nbsp; //send structure data back to socket flags<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close (sock);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nUnable to set flags&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit (EXIT_FAILURE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
void *captureTraffic(void * args)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char r_caBuffer &#91;BUFFERLENGTH&#93;;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //holds bytes recieved<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  r_lPacketCount = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int r_iBytesReceived = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (r_iContinue)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r_iBytesReceived = recvfrom (sock,r_caBuffer,BUFFERLENGTH,0,NULL,NULL);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r_lPacketCount ++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r_pIPHeader = (struct ip *)r_caBuffer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n\n\nPacket Number : %d&quot;,r_lPacketCount);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nSource IP&nbsp; &nbsp;  : %s&quot;,inet_ntoa(r_pIPHeader-&gt;ip_src));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nDestination IP: %s&quot;,inet_ntoa(r_pIPHeader-&gt;ip_dst));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (i=0;i&lt;r_iBytesReceived;i++)<br />
&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; if ((i%10) == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf(&quot;%x\t&quot;,r_caBuffer&#91;i&#93;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }&nbsp; // end while<br />
}<br />
<br />
<br />
void capture_start ()&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; int result;<br />
&nbsp; &nbsp; &nbsp; &nbsp; r_iContinue = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; result = pthread_create (&amp;r_Capture, NULL, captureTraffic, (void *) 0);//create capturing thread<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (result != 0) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nunable to start sniffer\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(EXIT_FAILURE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
void capture_stop ()&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; r_iContinue = 0;<br />
}<br />
<br />
<br />
int main (int argc, char * argv&#91;&#93;)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (argc != 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  printf (&quot;\nUSAGE: sniffer &lt;monitoring interface&gt; &lt;time&gt;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(EXIT_FAILURE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; r_cInterface = argv&#91;1&#93;;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //get interface name from input<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  r_iTime = (int)atol(argv&#91;2&#93;);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //get running time from input<br />
&nbsp; &nbsp; &nbsp; &nbsp; initializeInterface(r_cInterface);<br />
&nbsp; &nbsp; &nbsp; &nbsp; capture_start ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; sleep(r_iTime);<br />
&nbsp; &nbsp; &nbsp; &nbsp; capture_stop ();<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>henabibi</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238114.html</guid>
		</item>
		<item>
			<title>strtok</title>
			<link>http://www.daniweb.com/forums/thread238107.html</link>
			<pubDate>Thu, 12 Nov 2009 20:06:18 GMT</pubDate>
			<description>I am trying to write a program that accepts a dollar rate and hte accepts a list of amounts adn converts tehm to Shekels and prints in a list with the sums.  
HEre si my code: 
It is giving em lots of errors and I am having no luck. I think strtok is the main problem but not sure how else to do it....</description>
			<content:encoded><![CDATA[<div>I am trying to write a program that accepts a dollar rate and hte accepts a list of amounts adn converts tehm to Shekels and prints in a list with the sums. <br />
HEre si my code:<br />
It is giving em lots of errors and I am having no luck. I think strtok is the main problem but not sure how else to do it.<br />
 <pre style="margin:20px; line-height:13px">/*<br />
Requests exchange rate and hen a list of dollar amount.<br />
It then prints in a table the dollar and shekel amount and adds them up<br />
*/<br />
#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
void main ()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* defines maximum list of dollar amounts*/<br />
&nbsp; &nbsp; &nbsp; &nbsp; #define MAXLINE 100<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; float rate;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float *dollar[MAXLINE]={0}; /*starts the array with a 0 so the rest of the array will be set to 0*/ <br />
&nbsp; &nbsp; &nbsp; &nbsp; int x=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float sumDollars,sumShekels; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int i=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char c;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int spaceCount=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; /*starts the sums to 0*/<br />
&nbsp; &nbsp; &nbsp; &nbsp; sumDollars=0.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; sumShekels=0.0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Please input the current dollar exchange rate&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf_s(&quot;%f&quot;,&amp;rate);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Please input dollar amounts to calculate into Shekels. Return will end the list.&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; /* reads the list of dollar amounts*/<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (spaceCount&lt;=MAXLINE) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((c=getchar())==' ')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spaceCount++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((c=getchar())=='\n')<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i=0; dollar[i]=strtok(c,&quot; &quot;), i++);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;$ \t IS\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;__ \t __\n&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* Prints the list*/<br />
&nbsp; &nbsp; &nbsp; &nbsp; for ( x=0; dollar[x]!= '\n'; x++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sumDollars=sumDollars+dollar[x];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sumShekels=sumShekels+(dollar[x]*rate);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%5.2f \t %5.2f&quot;, dollar[x], dollar[x]*rate);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; getchar();<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>leeba</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238107.html</guid>
		</item>
		<item>
			<title>program to get product matrix</title>
			<link>http://www.daniweb.com/forums/thread238071.html</link>
			<pubDate>Thu, 12 Nov 2009 16:51:38 GMT</pubDate>
			<description><![CDATA[void main() 
{  
int a[10][10],b[10][10],c[10][10],i,j,k,m,n,p,q;  
 
printf("Enter The Rows And Cloumns And Of The First Matrix:");  
scanf("%d %d",&m,&n);  
printf("\nEnter The Rows And Cloumns And Of The Second Matrix:");  
scanf("%d %d",&p,&q);  
 
printf("\nEnter Elements Of The First...]]></description>
			<content:encoded><![CDATA[<div>void main()<br />
{ <br />
int a[10][10],b[10][10],c[10][10],i,j,k,m,n,p,q; <br />
<br />
printf(&quot;Enter The Rows And Cloumns And Of The First Matrix:&quot;); <br />
scanf(&quot;%d %d&quot;,&amp;m,&amp;n); <br />
printf(&quot;\nEnter The Rows And Cloumns And Of The Second Matrix:&quot;); <br />
scanf(&quot;%d %d&quot;,&amp;p,&amp;q); <br />
<br />
printf(&quot;\nEnter Elements Of The First Matrix:\n&quot;); <br />
<br />
for(i=0;i&lt; m;i++)<br />
{ <br />
for(j=0;j&lt; n;j++) <br />
{<br />
scanf(&quot;%d&quot;,&amp;a[i][j]);<br />
}<br />
<br />
} <br />
<br />
printf(&quot;\nEnter Elements Of The Second Matrix:\n&quot;); <br />
<br />
for(i=0;i&lt; p;i++) { <br />
for(j=0;j&lt; q;j++) <br />
scanf(&quot;%d&quot;,&amp;b[i][j]); <br />
} <br />
<br />
printf(&quot;The First Matrix Is:\n&quot;); /* Print the first matrix */ <br />
<br />
for(i=0;i&lt; m;i++) { <br />
for(j=0;j&lt; n;j++) <br />
printf(&quot; %d &quot;,a[i][j]); <br />
printf(&quot;\n&quot;); <br />
} <br />
<br />
printf(&quot;The Second Matrix Is:\n&quot;); /* Print the second matrix */ <br />
<br />
for(i=0;i&lt; p;i++) { <br />
for(j=0;j&lt; q;j++) <br />
printf(&quot; %d &quot;,b[i][j]); <br />
printf(&quot;\n&quot;); <br />
} <br />
<br />
if(n!=p) { <br />
printf(&quot;Aborting./nMultiplication Of The Above Matrices Not Possible.&quot;); <br />
exit(0); <br />
} <br />
<br />
else { <br />
for(i=0;i&lt; m;i++) { <br />
for(j=0;j&lt; q;j++) { <br />
c[i][j] = 0; <br />
<br />
for(k=0;k&lt; n;k++) { <br />
c[i][j] = c[i][j] + a[i][k] * b[k][j]; <br />
} <br />
} <br />
} <br />
<br />
printf(&quot;\nThe Product Of The Two Matrices Is:\n\n&quot;); <br />
<br />
for(i=0;i&lt; m;i++) { <br />
for(j=0;j&lt; q;j++) { <br />
printf(&quot; %d &quot;,c[i][j]); <br />
} <br />
<br />
printf(&quot;\n&quot;); <br />
<br />
} <br />
} <br />
<br />
<br />
return 0; <br />
<br />
}</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Ankush dhingra</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238071.html</guid>
		</item>
		<item>
			<title>program to construct a matrix</title>
			<link>http://www.daniweb.com/forums/thread238067.html</link>
			<pubDate>Thu, 12 Nov 2009 16:41:11 GMT</pubDate>
			<description><![CDATA[#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int a[10][10],b[10][10],c[10][10],i,j,k,m,n,p,q; 
 
printf("Enter The Rows And Cloumns in the Matrix:"); 
scanf("%d %d",&m,&n); 
 
printf("\nEnter Elements Of The Matrix:\n");]]></description>
			<content:encoded><![CDATA[<div>#include&lt;stdio.h&gt;<br />
#include&lt;conio.h&gt;<br />
void main()<br />
{<br />
int a[10][10],b[10][10],c[10][10],i,j,k,m,n,p,q;<br />
<br />
printf(&quot;Enter The Rows And Cloumns in the Matrix:&quot;);<br />
scanf(&quot;%d %d&quot;,&amp;m,&amp;n);<br />
<br />
printf(&quot;\nEnter Elements Of The Matrix:\n&quot;);<br />
<br />
for(i=0;i&lt; m;i++)<br />
{<br />
for(j=0;j&lt; n;j++)<br />
{<br />
scanf(&quot;%d&quot;,&amp;a[i][j]);<br />
}<br />
}<br />
printf(&quot;The First Matrix Is:\n&quot;); /* Print the first matrix */<br />
for(i=0;i&lt; m;i++)<br />
{<br />
for(j=0;j&lt; n;j++)<br />
printf(&quot; %d &quot;,a[i][j]);<br />
printf(&quot;\n&quot;);<br />
}<br />
getch();<br />
}</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Vishu Madaan</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238067.html</guid>
		</item>
		<item>
			<title>AntiVir reports code as trojan: TR/Eplx.IMG-WMF.bfg</title>
			<link>http://www.daniweb.com/forums/thread238058.html</link>
			<pubDate>Thu, 12 Nov 2009 16:01:40 GMT</pubDate>
			<description><![CDATA[Hello, 
 
  <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>Hello,<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
<br />
int main(void)<br />
{<br />
&nbsp; &nbsp; enum BOOL {foo, bar};<br />
&nbsp; &nbsp; enum BOOL bFlag;<br />
&nbsp; &nbsp; return 0;<br />
}</pre><br />
When I compile this and run it AntiVir claims it's the TR/Eplx.IMG-WMF.bfg trojan. Isn't that weird?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Pim</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238058.html</guid>
		</item>
		<item>
			<title><![CDATA[[C][for loop] How to print this pattern use "for" ???]]></title>
			<link>http://www.daniweb.com/forums/thread238044.html</link>
			<pubDate>Thu, 12 Nov 2009 14:48:55 GMT</pubDate>
			<description><![CDATA[How to print this pattern use "for" ??? 
 
Image: http://ser1.share.ysk.cc/upload/photo/20091112/754158.JPG  
:?::?::?:]]></description>
			<content:encoded><![CDATA[<div>How to print this pattern use &quot;for&quot; ???<br />
<br />
<img src="http://ser1.share.ysk.cc/upload/photo/20091112/754158.JPG" border="0" alt="" /><br />
:?::?::?:</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/thread238044.html</guid>
		</item>
		<item>
			<title>client server talk prob</title>
			<link>http://www.daniweb.com/forums/thread238031.html</link>
			<pubDate>Thu, 12 Nov 2009 13:41:16 GMT</pubDate>
			<description><![CDATA[ok so i am having problems with my program. its a client program talking to the server program. i have both programs working fine but i do not know how to get the conversation to display on the server side of the conversation. here are the codes and makefile 
 
 
 
 
serv.c 
 
 
#include <string.h>...]]></description>
			<content:encoded><![CDATA[<div>ok so i am having problems with my program. its a client program talking to the server program. i have both programs working fine but i do not know how to get the conversation to display on the server side of the conversation. here are the codes and makefile<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
serv.c<br />
<br />
<br />
#include &lt;string.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;sys/socket.h&gt;<br />
#include &lt;netinet/in.h&gt;<br />
#include &lt;sys/types.h&gt;<br />
<br />
#define MAXLINE 4096<br />
#define SA struct sockaddr<br />
#define SERV_PORT 9877<br />
#define LISTENQ 1024<br />
#define EINTR 0<br />
<br />
void str_echo(int sockfd);<br />
<br />
int main(int argc,char **argv)<br />
{&nbsp; &nbsp; &nbsp;  int listenfd,connfd,errno;<br />
&nbsp; &nbsp; &nbsp; &nbsp; pid_t childpid;<br />
&nbsp; &nbsp; &nbsp; &nbsp; socklen_t clilen;<br />
&nbsp; &nbsp; &nbsp; &nbsp; struct sockaddr_in cliaddr, servaddr;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; listenfd=socket(AF_INET,SOCK_STREAM,0);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; bzero(&amp;servaddr,sizeof(servaddr));<br />
&nbsp; &nbsp; &nbsp; &nbsp; servaddr.sin_family= AF_INET;<br />
&nbsp; &nbsp; &nbsp; &nbsp; servaddr.sin_addr.s_addr= htonl(INADDR_ANY);<br />
&nbsp; &nbsp; &nbsp; &nbsp; servaddr.sin_port= htons(SERV_PORT);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; bind(listenfd,(SA*) &amp;servaddr,sizeof(servaddr));<br />
&nbsp; &nbsp; &nbsp; &nbsp; listen(listenfd,LISTENQ);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(;;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp;  clilen=sizeof(cliaddr);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; connfd=accept(listenfd,(SA*) &amp;cliaddr, &amp;clilen);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if((childpid=fork())==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp;  close(listenfd);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str_echo(connfd);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close(connfd);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
void str_echo(int sockfd)<br />
{&nbsp; &nbsp; &nbsp;  ssize_t n, errno;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char rec_buf&#91;MAXLINE&#93;, send_buf&#91;MAXLINE&#93;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; again:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while((n=read(sockfd,rec_buf,MAXLINE))&gt;0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp;  fputs(rec_buf,stdout);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fgets(send_buf,MAXLINE,stdin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write(sockfd,send_buf,MAXLINE);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(n&lt;0 &amp;&amp; errno==EINTR)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp;  goto again;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else if(n&lt;0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp;  fprintf(stderr,&quot;str_echo: read error&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
<br />
<br />
cli.c<br />
<br />
<br />
#include &lt;string.h&gt;<br />
#include &lt;sys/socket.h&gt;<br />
#include &lt;netinet/in.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;sys/types.h&gt;<br />
<br />
#define SA struct sockaddr<br />
#define SERV_PORT 9877<br />
#define MAXLINE 4096<br />
<br />
void str_cli(FILE *fp, int sockfd);<br />
<br />
int main(int argc, char**argv)<br />
{&nbsp; &nbsp; &nbsp;  int sockfd;<br />
&nbsp; &nbsp; &nbsp; &nbsp; struct sockaddr_in servaddr;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(argc !=2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp;  fprintf(stderr,&quot;usage:tcpcli &lt;IPaddress&gt;&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; sockfd=socket(AF_INET,SOCK_STREAM,0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; bzero(&amp;servaddr,sizeof(servaddr));<br />
&nbsp; &nbsp; &nbsp; &nbsp; servaddr.sin_family=AF_INET;<br />
&nbsp; &nbsp; &nbsp; &nbsp; servaddr.sin_port=htons(SERV_PORT);<br />
&nbsp; &nbsp; &nbsp; &nbsp; inet_pton(AF_INET,argv&#91;1&#93;,&amp;servaddr.sin_addr);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; connect(sockfd,(SA*) &amp;servaddr, sizeof(servaddr));<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; str_cli(stdin,sockfd);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
}<br />
<br />
void str_cli(FILE *fp, int sockfd)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char sendline&#91;MAXLINE&#93;,recvline&#91;MAXLINE&#93;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(fgets(sendline,MAXLINE,fp) != NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp;  write(sockfd,sendline,strlen(sendline));<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(read(sockfd,recvline,MAXLINE)==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp;  fprintf(stderr,&quot;str_cli: server terminated&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fputs(recvline,stdout);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
<br />
and the makefile<br />
<br />
all: client server<br />
<br />
client: cli.c<br />
&nbsp; &nbsp; &nbsp; &nbsp; cc -o client cli.c<br />
<br />
server: serv.c<br />
&nbsp; &nbsp; &nbsp; &nbsp; cc -o server serv.c<br />
<br />
clean:<br />
&nbsp; &nbsp; &nbsp; &nbsp; rm client server</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>ROTC89</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238031.html</guid>
		</item>
		<item>
			<title>I need a Programm In C hex to decimal</title>
			<link>http://www.daniweb.com/forums/thread238016.html</link>
			<pubDate>Thu, 12 Nov 2009 12:06:36 GMT</pubDate>
			<description>hello 
I need a programm In C how convert Hexadecimal to decimal plz</description>
			<content:encoded><![CDATA[<div>hello<br />
I need a programm In C how convert Hexadecimal to decimal plz</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>hapyharra</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238016.html</guid>
		</item>
		<item>
			<title>C prog DFT</title>
			<link>http://www.daniweb.com/forums/thread237995.html</link>
			<pubDate>Thu, 12 Nov 2009 11:03:24 GMT</pubDate>
			<description><![CDATA[Hi,  
im trying to calculATE DFT through this code, i dnt know what's wrong please enlighten. Thanks 
 
 
  <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"...]]></description>
			<content:encoded><![CDATA[<div>Hi, <br />
im trying to calculATE DFT through this code, i dnt know what's wrong please enlighten. Thanks<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;conio.h&gt;<br />
#include &lt;math.h&gt;<br />
#include &lt;complex.h&gt;<br />
main()<br />
{<br />
int m,n,r,N,j;<br />
float l,o;<br />
float complex x[1000];<br />
float real, imag;<br />
{<br />
for (m=1;m&lt;=10;m++)<br />
{<br />
for (n=1;n&lt;=10;n++)<br />
{<br />
for (j=1; j&lt;=10;j++)<br />
N=1000;<br />
r=1/N;<br />
l=sin(3*j);<br />
printf(&quot;the value of sin is %f&quot;,l);<br />
<br />
o=exp(6.28*m*n*r);<br />
x[m]=0.0+I*o*l;<br />
//real=creal(x[m]);<br />
//imag=cimag(x[m]);<br />
printf(&quot;the val of x[m] is %f&quot;, x[m]);<br />
<br />
}<br />
}<br />
}<br />
getch();<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>GagandeepKaur</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237995.html</guid>
		</item>
		<item>
			<title>Need Help with backtracking</title>
			<link>http://www.daniweb.com/forums/thread237941.html</link>
			<pubDate>Thu, 12 Nov 2009 07:08:44 GMT</pubDate>
			<description><![CDATA[hi, Im coding a sodoku program base on backtracking, but somehow it did not work as what I expected, can help me figure out what's the problem? 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>hi, Im coding a sodoku program base on backtracking, but somehow it did not work as what I expected, can help me figure out what's the problem?<br />
<br />
 <pre style="margin:20px; line-height:13px">sodoku.c<br />
<br />
#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
#define true 1<br />
#define false 0<br />
<br />
void printGrid(int board[]) {<br />
&nbsp; &nbsp; int i,j;<br />
&nbsp; &nbsp; if (board==NULL){<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;No Solution\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; for (i=0;i&lt;9;i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (j=0;j&lt;9;j++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf (&quot;%d&quot;,board[i*9+j]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (j%3==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf (&quot; &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf (&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (i%3==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf (&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp;  <br />
}<br />
<br />
int checkDigit(int board[], int digit, int n) {<br />
<br />
&nbsp; &nbsp; int i,j;<br />
&nbsp; &nbsp; int ROW;<br />
&nbsp; &nbsp; int COL;<br />
<br />
&nbsp; &nbsp; ROW=n/9;<br />
&nbsp; &nbsp; COL=n%9;<br />
<br />
&nbsp; &nbsp; if (ROW&lt;0 || COL&lt;0 || ROW&gt;8 || COL &gt;8 || digit &lt;1 || digit &gt;9 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; return false;<br />
&nbsp; &nbsp; if (board[ROW*9+COL]!=0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; return false;<br />
<br />
//scan horizontally and vertically<br />
&nbsp; &nbsp; for (i=0;i&lt;9;i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (board[i*9+COL]==digit || board[ROW*9+i]==digit)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return false;<br />
&nbsp; &nbsp; }<br />
<br />
//scan within the square<br />
&nbsp; &nbsp; for (j=((ROW/3)*3);j&lt;(((ROW/3)*3)+3);j++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i=((COL/3)*3);i&lt;((COL/3)*3+3);i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (board[j*9+ROW]==digit)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; return true;<br />
}<br />
<br />
int solveGrid(int board[], int n) {<br />
<br />
&nbsp; &nbsp; int i,j,k;<br />
&nbsp; &nbsp; i=n/9;<br />
&nbsp; &nbsp; j=n%9;<br />
&nbsp; &nbsp; int solved=1;<br />
&nbsp; &nbsp; for (n=0;n&lt;81;n++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (board[n]==0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; solved=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; solved=1;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; if (solved)<br />
&nbsp; &nbsp; &nbsp; &nbsp; return;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; for (i=0;i&lt;9;i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (j=0;j&lt;9;j++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (board[i*9+j]==0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (k=1;k&lt;=9;k++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (checkDigit(board,k,i*9+j)){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; board[i*9+j]=k;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; solveGrid(board,i*9+j+1);<br />
&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; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
<br />
main.c<br />
<br />
#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
#define ROW 9<br />
#define COL 9<br />
<br />
int main(int argc, char** argv) {<br />
<br />
&nbsp; &nbsp; /* the sudoku grid is represented by this 1D array */<br />
&nbsp; &nbsp; int board[ROW * COL];<br />
&nbsp; &nbsp; char filename[100];<br />
&nbsp; &nbsp; int i, j, input;<br />
&nbsp; &nbsp; FILE *fp;<br />
<br />
&nbsp; &nbsp; printf(&quot;Enter data file name: &quot;);<br />
&nbsp; &nbsp; scanf(&quot;%s&quot;, filename);<br />
<br />
&nbsp; &nbsp; fp = fopen(filename, &quot;r&quot;);<br />
&nbsp; &nbsp; if (fp == NULL) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Cannot open data file\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; for (i = 0; i &lt; 9; i++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (j = 0; j &lt; 9; j++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fscanf(fp, &quot;%d&quot;, &amp;input);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; board[i * ROW + j] = input;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; fclose(fp);<br />
<br />
&nbsp; &nbsp; // the solver starts from position 0<br />
&nbsp; &nbsp; if (solveGrid(board, 0)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Solved.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printGrid(board);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;No Solution.&quot;);<br />
<br />
&nbsp; &nbsp; return (EXIT_SUCCESS);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Justea</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237941.html</guid>
		</item>
		<item>
			<title>gstreamer code...help me</title>
			<link>http://www.daniweb.com/forums/thread237911.html</link>
			<pubDate>Thu, 12 Nov 2009 03:55:40 GMT</pubDate>
			<description>Hi, 
 
i like to know what are the different systems that have gstreamer built in, or systems which allows gstreamer to be installed. 
 
I also like to know what this below lines specifies: 
I found this in my shell of proc/version file 
Linux Version 2.6.9-5.Elsm gcc version 3.4.3 20041212 (red...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
i like to know what are the different systems that have gstreamer built in, or systems which allows gstreamer to be installed.<br />
<br />
I also like to know what this below lines specifies:<br />
I found this in my shell of proc/version file<br />
Linux Version 2.6.9-5.Elsm gcc version 3.4.3 20041212 (red hat 3.4.3-9.El4) #1 smp wed jan 5 19:30:39 EST 2005.<br />
<br />
can i install gstreamer on my system.<br />
<br />
Thanks.</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/thread237911.html</guid>
		</item>
		<item>
			<title>Small C program error</title>
			<link>http://www.daniweb.com/forums/thread237896.html</link>
			<pubDate>Thu, 12 Nov 2009 02:50:16 GMT</pubDate>
			<description>So I am suppose to write a program that will implementing one method if computing 
checksums for a file containing integers. 
 
I am executing the program by a command line from the following form: 
 
p4a inputfile outputfile 
 
 
I can compile the program in Dev C++ compiler with no errors. But...</description>
			<content:encoded><![CDATA[<div>So I am suppose to write a program that will implementing one method if computing<br />
checksums for a file containing integers.<br />
<br />
I am executing the program by a command line from the following form:<br />
<br />
p4a inputfile outputfile<br />
<br />
<br />
I can compile the program in Dev C++ compiler with no errors. But the problem is that <br />
when compile the program in unix command line by:<br />
<br />
gcc p4a.c<br />
<br />
I get the following errors:<br />
<br />
p4a.c: In function `main':<br />
p4a.c:42: parse error before `*'<br />
p4a.c:43: `fp2' undeclared (first use in this function)<br />
p4a.c:43: (Each undeclared identifier is reported only once<br />
p4a.c:43: for each function it appears in.)<br />
<br />
Can anyone point me in the right direction in fixing these errors so that I can compile correctly by command line<br />
<br />
<br />
Here is the code below:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;stdio.h&gt;<br />
#include&lt;string.h&gt;<br />
<br />
<br />
main(int argc,char* argv[])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; short int a[100][5];<br />
&nbsp; &nbsp; &nbsp; &nbsp; short int res;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; FILE *fp1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(!(fp1=fopen(argv[1],&quot;r&quot;)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Error opening file\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i,j,k,l;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i=j=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(!feof(fp1))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(j=0;j&lt;4;j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fscanf(fp1,&quot;%d&quot;,&amp;a[i][j]); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&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; for(k=0;k&lt;i;k++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unsigned short int musk=!0; //musk=11...111<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; musk=musk|15;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //musk=000..001111<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; musk=musk&lt;&lt;12;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //musk=111100..000<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; res=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(l=0;l&lt;4;l++)<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; short int temp=(a[k][l]&amp;musk);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res=res|temp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; musk=musk&gt;&gt;4;<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; a[k][4]=res;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FILE *fp2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!(fp2=fopen(argv[2],&quot;w&quot;)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Error:cannot open file&quot;);<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; for(k=0;k&lt;i;k++)<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; for(j=0;j&lt;5;j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp2,&quot;%d%s&quot;,a[k][j],&quot;\t&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(fp2,&quot;%s&quot;,&quot;\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; fclose(fp1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fclose(fp2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
}<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>cabosun</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237896.html</guid>
		</item>
		<item>
			<title>Code Snippet Changing the contents of a file</title>
			<link>http://www.daniweb.com/code/snippet237882.html</link>
			<pubDate>Thu, 12 Nov 2009 01:41:01 GMT</pubDate>
			<description><![CDATA[I'm working on a program to score a bowling game.  Right now, my terminal says that my program has a seg fault, but I can't tell where.  Any other insight on how to help my program do what it's supposed to do would be helpful.  I'm still not sure how to weed out all the characters, although I think...]]></description>
			<content:encoded><![CDATA[<div>I'm working on a program to score a bowling game.  Right now, my terminal says that my program has a seg fault, but I can't tell where.  Any other insight on how to help my program do what it's supposed to do would be helpful.  I'm still not sure how to weed out all the characters, although I think my fscanf might do that.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>luke1705</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237882.html</guid>
		</item>
		<item>
			<title>Bubble sort structure array problem</title>
			<link>http://www.daniweb.com/forums/thread237875.html</link>
			<pubDate>Thu, 12 Nov 2009 00:56:48 GMT</pubDate>
			<description><![CDATA[hey guys, i programmed a bubble sort function in C and it doesnt seem to be sorting properly. Ive searched the forums and have seen similar posts and tried them but they dont work. :( 
Hoping someone could look over it to see if the concept/sytax is right. 
 
  <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>hey guys, i programmed a bubble sort function in C and it doesnt seem to be sorting properly. Ive searched the forums and have seen similar posts and tried them but they dont work. :(<br />
Hoping someone could look over it to see if the concept/sytax is right.<br />
<br />
 <pre style="margin:20px; line-height:13px">typedef struct<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char artist[40];<br />
&nbsp; &nbsp; &nbsp; &nbsp; char title[60];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int rating;<br />
} song;<br />
<br />
void song_by_title(song oneSong[99], int size)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; song temp1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i,j = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int s = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; size; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(j = 0; j &lt;= size - 1; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s = strcmp(oneSong[j].title, oneSong[j + 1].title);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(s &lt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp1 = oneSong[j + 1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oneSong[j + 1] = oneSong[j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oneSong[j] = temp1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre><br />
thank you in advanced<br />
spencer</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>matrix0978</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237875.html</guid>
		</item>
		<item>
			<title>Forking</title>
			<link>http://www.daniweb.com/forums/thread237866.html</link>
			<pubDate>Thu, 12 Nov 2009 00:05:13 GMT</pubDate>
			<description><![CDATA[I'm having trouble with a forking program. 
 
One process writes to a file, the other waits for the file to be written, prints something out, then deletes it. They essentially process in order based on whether the file is there or not. 
 
The processes should be outputting more useful information...]]></description>
			<content:encoded><![CDATA[<div>I'm having trouble with a forking program.<br />
<br />
One process writes to a file, the other waits for the file to be written, prints something out, then deletes it. They essentially process in order based on whether the file is there or not.<br />
<br />
The processes should be outputting more useful information than this. As it is, this is the output:<br />
<br />
Waiting for data.txt to appear...<br />
Found it! Splitting now.<br />
Producer initialized!<br />
Waiting for values.txt to disappear...<br />
Consumer initialized!<br />
Waiting for values.txt to appear...<br />
Values.txt found! Processing...<br />
Values.txt is gone: processing...<br />
<br />
Then both seem to terminate, but I can't tell because they don't finish.<br />
<br />
I just need a little push and I should be able to figure the rest out myself.<br />
<br />
 <pre style="margin:20px; line-height:13px">//includes<br />
#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;sys/types.h&gt;<br />
<br />
int main (int argc, char *argv[]) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int prodpid;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int conspid;<br />
&nbsp; &nbsp; &nbsp; &nbsp; FILE *fin;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Waiting for data.txt to appear...\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; do {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin=fopen(&quot;data.txt&quot;, &quot;rt&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }while(fin==NULL);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Found it! Splitting now.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; prodpid=fork();<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(prodpid==0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char *c=(char*)malloc(4);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FILE *fval;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Producer initialized!\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(fgets(c, 4, fin)!=NULL){<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Waiting for values.txt to disappear...\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fval=fopen(&quot;values.txt&quot;, &quot;rt&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while(fval!=NULL);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Values.txt is gone: processing...\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char line[2*i+2];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char buffer[100];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i=atoi(c); i&gt;=0; i--){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sprintf(buffer, &quot;%i&quot;, i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcat(line, buffer);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcat(line, &quot; &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; fwrite(line, 1, sizeof(line), fopen(&quot;values.txt&quot;, &quot;w&quot;));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Done writing %s.\n&quot;, line);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fclose(fval);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }//done with all of the numbers in data.txt<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fclose(fin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conspid=fork();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(conspid==0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int cnt=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char *c=(char*)malloc(1024);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FILE *fval;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Consumer initialized!\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(1){<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Waiting for values.txt to appear...\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fval=fopen(&quot;values.txt&quot;, &quot;rt&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while(fval==NULL);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Values.txt found! Processing...\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cnt++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fgets(c, 1024, fval);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int num=atoi(strtok(c,&quot; &quot;));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Processing VALUES.TXT file number %i with values %s\nIt has %i odd numbers\n&quot;, cnt, c, num/2+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fclose(fval);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; system(&quot;rm values.txt&quot;);<br />
&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; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{wait(conspid);}<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
wait(prodpid);<br />
return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>thure</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237866.html</guid>
		</item>
		<item>
			<title>Code Snippet List Windows Logical Drive Letters</title>
			<link>http://www.daniweb.com/code/snippet237803.html</link>
			<pubDate>Wed, 11 Nov 2009 17:23:27 GMT</pubDate>
			<description><![CDATA[This demonstrates how to get a list of your computer's logical drive letters under the MS-Windows operating system.]]></description>
			<content:encoded><![CDATA[<div>This demonstrates how to get a list of your computer's logical drive letters under the MS-Windows operating system.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Ancient Dragon</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237803.html</guid>
		</item>
		<item>
			<title>System() command</title>
			<link>http://www.daniweb.com/forums/thread237801.html</link>
			<pubDate>Wed, 11 Nov 2009 17:17:35 GMT</pubDate>
			<description><![CDATA[Hey, 
 
I needed to delete a file created by a child process and our prof suggested that I use the system() command to do so. I 'manned' system but cant find anything useful on how to use it to delete an opened file. Can anyone suggest as to how this could be done? 
 
Thanks, 
Kunal.]]></description>
			<content:encoded><![CDATA[<div>Hey,<br />
<br />
I needed to delete a file created by a child process and our prof suggested that I use the system() command to do so. I 'manned' system but cant find anything useful on how to use it to delete an opened file. Can anyone suggest as to how this could be done?<br />
<br />
Thanks,<br />
Kunal.</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/thread237801.html</guid>
		</item>
		<item>
			<title>product of two matrices with undefined number of rows and columns</title>
			<link>http://www.daniweb.com/forums/thread237779.html</link>
			<pubDate>Wed, 11 Nov 2009 15:34:10 GMT</pubDate>
			<description>Hello. Please, i have this little question of finding the product of two matrices in which the user enters the number of rows and columns. i would appreciate it if a solution is given and even more if there are more than one solutions to the question. thanks.</description>
			<content:encoded><![CDATA[<div>Hello. Please, i have this little question of finding the product of two matrices in which the user enters the number of rows and columns. i would appreciate it if a solution is given and even more if there are more than one solutions to the question. 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/thread237779.html</guid>
		</item>
		<item>
			<title>Code Snippet errno - perror vs fprintf + strerror</title>
			<link>http://www.daniweb.com/code/snippet237776.html</link>
			<pubDate>Wed, 11 Nov 2009 15:23:29 GMT</pubDate>
			<description><![CDATA[Hi! 
 
From the manpages I know, that perror evaluates the errno. So 
using perror and fprintf + strerror, as coded in my example below, should result in the same error messages, but they do not.  
The execution of the program leads to the following result: 
 
bash>  ./errno_test blub 
fopen()...]]></description>
			<content:encoded><![CDATA[<div>Hi!<br />
<br />
From the manpages I know, that perror evaluates the errno. So<br />
using perror and fprintf + strerror, as coded in my example below, should result in the same error messages, but they do not. <br />
The execution of the program leads to the following result:<br />
<br />
bash&gt;  ./errno_test blub<br />
fopen() failed: No such file or directory<br />
fopen() failed<br />
fopen() failed: Error code 29<br />
fopen() failed: Error code Illegal seek<br />
<br />
Can someone explain, where this behavior comes from? I think<br />
fopen calls open, and open might invoke something such as a seek function. Is the errno set inappropriately? Or am I wrong about the<br />
assumption, that perror and fprintf + strerror should cause the same output?<br />
<br />
Thanks and Regards!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>Is0r</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237776.html</guid>
		</item>
		<item>
			<title>product of two matrices with undefined number of rows and columns</title>
			<link>http://www.daniweb.com/forums/thread237775.html</link>
			<pubDate>Wed, 11 Nov 2009 15:18:37 GMT</pubDate>
			<description>Hello. Please, i have this little question of finding the product of two matrices in which the user enters the number of rows and columns. i would appreciate it if a solution is given and even more if there are more than one solutions to the question. thanks.</description>
			<content:encoded><![CDATA[<div>Hello. Please, i have this little question of finding the product of two matrices in which the user enters the number of rows and columns. i would appreciate it if a solution is given and even more if there are more than one solutions to the question. 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/thread237775.html</guid>
		</item>
		<item>
			<title>how can I list the drives/folders on pc (C Code)</title>
			<link>http://www.daniweb.com/forums/thread237769.html</link>
			<pubDate>Wed, 11 Nov 2009 15:00:19 GMT</pubDate>
			<description><![CDATA[hi everyone 
 
I'm trying to listing files/drives/folders in pc but I couldnt find anything. 
 
 
please help me .. 
 
--[ cryptacker ]--]]></description>
			<content:encoded><![CDATA[<div>hi everyone<br />
<br />
I'm trying to listing files/drives/folders in pc but I couldnt find anything.<br />
<br />
<br />
please help me ..<br />
<br />
--[ cryptacker ]--</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>cryptacker</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237769.html</guid>
		</item>
		<item>
			<title>Const Int and Points</title>
			<link>http://www.daniweb.com/forums/thread237699.html</link>
			<pubDate>Wed, 11 Nov 2009 08:27:14 GMT</pubDate>
			<description><![CDATA[Hello. 
 
I have a question about Const Int and Points 
 
I have this 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 with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>Hello.<br />
<br />
I have a question about Const Int and Points<br />
<br />
I have this code<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; const int j=18;<br />
&nbsp; &nbsp; int *k= (int)&amp;j;<br />
&nbsp; &nbsp; *k=110;<br />
&nbsp; &nbsp; printf(&quot;Data: %d -&gt; %d; %d : %d-&gt; %d\n&quot;, &amp;j, j, k, &amp;k, *k);</pre>this well return for me <br />
<span style="font-weight:bold">Data: 2280676 -&gt; 18; 2280676 : 2280672-&gt; 110</span><br />
but if i remove &quot;const&quot; well i have <br />
<span style="font-weight:bold">Data: 2280676 -&gt; 110; 2280676 : 2280672-&gt; 110</span> this work.<br />
<br />
But how can same memory address have two int ( 18 and 110 )<br />
Can somebody tell me how this are possible?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>FIG-GHD742</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237699.html</guid>
		</item>
		<item>
			<title>help me</title>
			<link>http://www.daniweb.com/forums/thread237677.html</link>
			<pubDate>Wed, 11 Nov 2009 07:12:22 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"><br />
#include &lt;gst/gst.h&gt;<br />
#include &lt;stdbool.h&gt;<br />
static GMainLoop *loop; <br />
<br />
static gbooleanbus_call (GstBus *bus,GstMessage *msg, gpointer user_data)<br />
{&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; switch (GST_MESSAGE_TYPE (msg))&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; case GST_MESSAGE_EOS:&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; g_message (&quot;End-of-stream&quot;); <br />
&nbsp; &nbsp; &nbsp; &nbsp; g_main_loop_quit (loop); <br />
&nbsp; &nbsp; &nbsp; &nbsp; break;&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  }&nbsp; &nbsp; &nbsp;  <br />
&nbsp;case GST_MESSAGE_ERROR:&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  gchar *debug;&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  GError *err;&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  gst_message_parse_error (msg, &amp;err, &amp;debug);&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  g_free (debug);&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  g_error (&quot;%s&quot;, err-&gt;message);&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  g_error_free (err);&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  g_main_loop_quit (loop);&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  break;&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }&nbsp; &nbsp; &nbsp;  <br />
&nbsp;default:&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; break;&nbsp; <br />
&nbsp; }&nbsp; &nbsp;  <br />
return true;<br />
} <br />
<br />
voidplay_uri (gchar *uri)<br />
{&nbsp;  <br />
&nbsp;GstElement *pipeline;&nbsp;  <br />
&nbsp; loop = g_main_loop_new (NULL, FALSE);&nbsp; <br />
&nbsp;  pipeline = gst_element_factory_make (&quot;playbin&quot;, &quot;player&quot;);&nbsp;  <br />
&nbsp; if (uri)&nbsp;  <br />
&nbsp;{&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  g_object_set (G_OBJECT (pipeline), &quot;uri&quot;, uri, NULL); <br />
&nbsp;}&nbsp; <br />
&nbsp;<br />
&nbsp; {&nbsp; &nbsp;  <br />
&nbsp;  GstBus *bus;&nbsp; &nbsp; <br />
&nbsp; &nbsp;  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));&nbsp; <br />
&nbsp; &nbsp; &nbsp; gst_bus_add_watch (bus, bus_call, NULL);&nbsp; <br />
&nbsp; &nbsp; &nbsp; gst_object_unref (bus);&nbsp; <br />
&nbsp; }&nbsp; <br />
&nbsp; <br />
&nbsp;gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); <br />
&nbsp;g_main_loop_run (loop);&nbsp; <br />
&nbsp;gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);&nbsp; <br />
&nbsp;gst_object_unref (GST_OBJECT (pipeline));<br />
} <br />
int main (int argc,&nbsp; &nbsp; &nbsp; char *argv[])<br />
{&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  gst_init (&amp;argc, &amp;argv);&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  play_uri (argv[1]);&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  return 0;<br />
}</pre><br />
<br />
please some one let me know on which system this can be executed ?<br />
i think its for gstreamer related <br />
i have red hat .<br />
can i install gstreamer on redhat<br />
thanks,</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/thread237677.html</guid>
		</item>
		<item>
			<title>Need Help sorting structures</title>
			<link>http://www.daniweb.com/forums/thread237625.html</link>
			<pubDate>Wed, 11 Nov 2009 02:10:00 GMT</pubDate>
			<description><![CDATA[So I have part of my code done and I'm stuck on how to sort structures.  
This is the code i have until now. 
 
Its supposed to ask the user 3 things title, artist name, rating of song 
 
and im supposed to ask the user to sort them in certain order 
 
so its supposed to look something like this on...]]></description>
			<content:encoded><![CDATA[<div>So I have part of my code done and I'm stuck on how to sort structures. <br />
This is the code i have until now.<br />
<br />
Its supposed to ask the user 3 things title, artist name, rating of song<br />
<br />
and im supposed to ask the user to sort them in certain order<br />
<br />
so its supposed to look something like this on the bottom  <br />
&quot;Select the operation to perform -- (t)itle, (a)rtist, (r)ating, (f)ilter, (q)uit&quot;<br />
<br />
and its supposed to sort however the user prompts it to<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
<br />
struct playlist<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int rating;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char title[80]; <br />
&nbsp; &nbsp; &nbsp; &nbsp; char artist[60];<br />
};<br />
int main (void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; struct playlist list1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int numOfSongs, i;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Enter the # of songs to be entered: &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, &amp;numOfSongs);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Enter song info in this order &lt;Title, Artist, Rating&gt;: &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; numOfSongs; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s%s%d&quot;, &amp;list1.title, &amp;list1.artist, &amp;list1.rating);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i%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 the next song info in this order &lt;Title, Artist, Rating&gt;: &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s%s%d&quot;, &amp;list1.title, &amp;list1.artist, &amp;list1.rating);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre></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/thread237625.html</guid>
		</item>
		<item>
			<title>A whole bunch of Segmentation Faults</title>
			<link>http://www.daniweb.com/forums/thread237610.html</link>
			<pubDate>Wed, 11 Nov 2009 01:07:56 GMT</pubDate>
			<description><![CDATA[Hi there, 
 
This is my first time working with an unsafe language, so naturally my first code would be full of memory-related bugs. I still have no idea how I ought to approach some of the problems I've been getting, and I've been resisting asking for help as much as I could. 
 
The assignment...]]></description>
			<content:encoded><![CDATA[<div>Hi there,<br />
<br />
This is my first time working with an unsafe language, so naturally my first code would be full of memory-related bugs. I still have no idea how I ought to approach some of the problems I've been getting, and I've been resisting asking for help as much as I could.<br />
<br />
The assignment I've been given is a buttload of work, so I'd rather not bog anyone down with too much of it. At the moment, I'm trying to work out how to design a menu() function that gives main() both the function choice the user wants and the arguments for that function. Here's what I've got so far:<br />
<br />
 <pre style="margin:20px; line-height:13px">struct REPLY {<br />
&nbsp; &nbsp; &nbsp; &nbsp; char use&#91;256&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char pass&#91;256&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char type&#91;64&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char nuse&#91;256&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char npass&#91;256&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char ntype&#91;64&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int option;<br />
};<br />
<br />
struct REPLY *reply;<br />
<br />
int menu (void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int o;<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Please type a number corresponding to the following options:\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;1. Add\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;2. Delete\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;3. Edit\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;4. Purge\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;5. Quit\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;Selection: %i\n&quot;, o);<br />
&nbsp; &nbsp; &nbsp; &nbsp; reply-&gt;option=o;<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n\n%i\n\n\n&quot;, reply-&gt;option);<br />
&nbsp; &nbsp; &nbsp; &nbsp; switch(reply-&gt;option){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case '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;Please provide the username.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s\n&quot;, &amp;reply-&gt;use);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Please provide the password.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s\n&quot;, &amp;reply-&gt;pass);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Please provide the user type.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s\n&quot;, &amp;reply-&gt;type);<br />
&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; case '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;Please provide the username.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s\n&quot;,&amp;reply-&gt;use);<br />
&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; case '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;Please provide the username.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s\n&quot;,&amp;reply-&gt;use);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Please provide the password.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s\n&quot;,&amp;reply-&gt;use);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Please provide the new username.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s\n&quot;,&amp;reply-&gt;nuse);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Please provide the new password.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s\n&quot;,&amp;reply-&gt;npass);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Please provide the new user type.\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%s\n&quot;,&amp;reply-&gt;ntype);<br />
&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; case '4':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&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; case '5':<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&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; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre><br />
This code is saved as menu.c, which is included in the inclusion statements of the main function. I'm getting a segmentation fault at  <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; reply-&gt;option=o;</pre> and I haven't been able to find out why. I also get the sense main won't be able to access reply for some reason.<br />
<br />
I just need a push, and it's probably so simple it went over my head, but can someone help me out?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>thure</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237610.html</guid>
		</item>
		<item>
			<title>Runtime error: Amicable Number</title>
			<link>http://www.daniweb.com/forums/thread237581.html</link>
			<pubDate>Tue, 10 Nov 2009 22:29:17 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;stdlib.h&gt;<br />
<br />
struct amicable<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int** amicablePair;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int size;<br />
};<br />
<br />
struct amicable *getAmicablePairs(int startnum, int endnum);<br />
int sumFactors(int number);<br />
<br />
int main(int argc, char** argv) {<br />
&nbsp; &nbsp; int startnum = 220;<br />
&nbsp; &nbsp; int endnum = 284;<br />
&nbsp; &nbsp; struct amicable* ami;<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; ami = getAmicablePairs(startnum, endnum);<br />
&nbsp; &nbsp; if(ami==NULL)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Error: malloc could not allocate&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return (EXIT_SUCCESS);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; printf(&quot;{&quot;);<br />
<br />
&nbsp; &nbsp; for(i = 0; i&lt;ami-&gt;size; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;{%d, %d}&quot;,ami-&gt;amicablePair[i][0], ami-&gt;amicablePair[i][1]);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; printf(&quot;}&quot;);<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; //getch();<br />
&nbsp; &nbsp; //return 0;<br />
&nbsp; &nbsp; return (EXIT_SUCCESS);<br />
}<br />
<br />
int sumFactors(int number){<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; int sum;<br />
&nbsp; &nbsp; sum=1;<br />
<br />
&nbsp; &nbsp; for(i=2;i&lt;=number/2;i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(number%i==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum=sum+i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; return sum;<br />
}<br />
<br />
struct amicable *getAmicablePairs(int startnum, int endnum)<br />
{&nbsp;  <br />
&nbsp; &nbsp; int nrows=(endnum-startnum);<br />
&nbsp; &nbsp; int ncols=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; int i,j,k=0;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; struct amicable* record;<br />
<br />
&nbsp; &nbsp; /*&nbsp; allocate array of pointers&nbsp; */<br />
&nbsp; &nbsp; record-&gt;amicablePair=(int**)malloc(nrows*sizeof(int*));<br />
&nbsp; &nbsp; if(record-&gt;amicablePair==NULL)<br />
&nbsp; {<br />
&nbsp; &nbsp;  printf(&quot;Error: malloc could not allocate %d bytes for a\n&quot;, 2 * sizeof(int *));<br />
&nbsp; &nbsp;  return record;<br />
&nbsp; }<br />
&nbsp; &nbsp; /*&nbsp; allocate each row&nbsp; */<br />
&nbsp; &nbsp;  for(i=0;i&lt;nrows;i++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; record-&gt;amicablePair[i]=(int*)malloc(ncols*sizeof(int));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(record-&gt;amicablePair[i]==NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Error: malloc could not allocate %d bytes for a\n&quot;, 3 * sizeof(int));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return record;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp;  }<br />
<br />
&nbsp; &nbsp;  /* problem solution */<br />
&nbsp; &nbsp; for(i = startnum; i &lt;= endnum; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(j = endnum; j &gt;= startnum; j--)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((sumFactors(i)==j) &amp;&amp; (sumFactors(j)==i) &amp;&amp; (i != j))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; record-&gt;amicablePair[k][0]=i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; record-&gt;amicablePair[k][1]=j;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; k++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp;  <br />
&nbsp; &nbsp; record-&gt;size=k;&nbsp; &nbsp; <br />
&nbsp; &nbsp; return record;<br />
}</pre><br />
I am getting this error while executing (in netbeans 6.7) the above code:<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; 6 [main] asp11d 3400 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION<br />
&nbsp; &nbsp; 908 [main] asp11d 3400 open_stackdumpfile: Dumping stack trace to asp11d.exe.stackdump<br />
<br />
RUN FAILED (exit value 35,584, total time: 421ms)</pre>..............please send me solutions as soon as possible.................<br />
Thanks in advance</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>prabindatta</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237581.html</guid>
		</item>
		<item>
			<title>urgent help needed in c</title>
			<link>http://www.daniweb.com/forums/thread237569.html</link>
			<pubDate>Tue, 10 Nov 2009 21:35:13 GMT</pubDate>
			<description><![CDATA[please can someone tell me the source code of a c program? 
the program is 
"create a c program to print the employee pay revision list using arrays and functions and structure" 
 
please do reply fast as i need help urgently]]></description>
			<content:encoded><![CDATA[<div>please can someone tell me the source code of a c program?<br />
the program is<br />
&quot;create a c program to print the employee pay revision list using arrays and functions and structure&quot;<br />
<br />
please do reply fast as i need help urgently</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>leena_gc</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237569.html</guid>
		</item>
		<item>
			<title>Getline causing SIGSEGV</title>
			<link>http://www.daniweb.com/forums/thread237561.html</link>
			<pubDate>Tue, 10 Nov 2009 20:58:03 GMT</pubDate>
			<description><![CDATA[I'm working on a project for school. Normally I'm a C++ guy, but I have to go through standard C before that, so I'm struggling with certain aspects being different, such as getline. Here's essentially what I'm doing, I have a data file that has a certain about of lines of data. Each set of data is...]]></description>
			<content:encoded><![CDATA[<div>I'm working on a project for school. Normally I'm a C++ guy, but I have to go through standard C before that, so I'm struggling with certain aspects being different, such as getline. Here's essentially what I'm doing, I have a data file that has a certain about of lines of data. Each set of data is organized the same way and contains 19 pieces to it, consisting of floats, characters, and integers, so there is no trouble there. I read the first 18 elements using fscanf, which works fine, but then switch to getline for the last element which is a string that can contain spaces. However, any time I run this, it crashes with a SIGSEGV, citing strcpy and getdelim as the culprit. Here's the lies of code that really matter, I can post the whole function if necessary, it's just a bit big.<br />
<br />
 <pre style="margin:20px; line-height:13px">FILE *inputFile = fopen(&quot;data.txt&quot;, &quot;r&quot;);<br />
int bytes = 100;<br />
char *namestr;<br />
int x = 0;<br />
<br />
// Get the last part, the name, and the terminating character with getline<br />
namestr = (char *) malloc ((bytes + 1));&nbsp; &nbsp; &nbsp; &nbsp; <br />
x = getline(&amp;namestr, &amp;bytes, inputFile); // SIGSEGV</pre><br />
Anyone have any ideas?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>shmeeps</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237561.html</guid>
		</item>
		<item>
			<title>create functions</title>
			<link>http://www.daniweb.com/forums/thread237520.html</link>
			<pubDate>Tue, 10 Nov 2009 17:49:29 GMT</pubDate>
			<description>Drawing Hello 
1. Horizontal Hello 
2. Diagonal Hello 
Enter choice: 1 
 
 
*          *  ******  *            *              **** 
*          *  *            *            *            *        * 
*******  ****      *            *            *        * 
*          *  *            *            *    ...</description>
			<content:encoded><![CDATA[<div>Drawing Hello<br />
1. Horizontal Hello<br />
2. Diagonal Hello<br />
Enter choice: 1<br />
<br />
<br />
*          *  ******  *            *              ****<br />
*          *  *            *            *            *        *<br />
*******  ****      *            *            *        *<br />
*          *  *            *            *            *        *<br />
*          *  ******  ******  ******    ****<br />
<br />
<br />
<br />
<br />
Drawing Hello<br />
1. Horizontal Hello<br />
2. Diagonal Hello<br />
Enter choice: 2<br />
<br />
*          *  <br />
*          *  ******                                <br />
*******  *            *                         <br />
*          *  ****      *            *            <br />
*          *  *            *            *              ****        <br />
                ******  *            *            *        *<br />
                              ******  *            *        *<br />
                                            ******  *        *<br />
                                                            ****</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum118.html">C</category>
			<dc:creator>mo_91</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237520.html</guid>
		</item>
	</channel>
</rss>
