<?xml version="1.0" encoding="ISO-8859-1"?>

<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>C Board - C Programming</title>
		<link>http://cboard.cprogramming.com</link>
		<description>Questions specific to C Programming</description>
		<language>en</language>
		<lastBuildDate>Fri, 20 Nov 2009 22:58:53 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://cboard.cprogramming.com/images/misc/rss.jpg</url>
			<title>C Board - C Programming</title>
			<link>http://cboard.cprogramming.com</link>
		</image>
		<item>
			<title>Question about reading in strings and integers</title>
			<link>http://cboard.cprogramming.com/c-programming/121811-question-about-reading-strings-integers.html</link>
			<pubDate>Fri, 20 Nov 2009 20:56:34 GMT</pubDate>
			<description>Hi, 
 
I am reading in strings and integers and I am wondering, am I doing this correctly where I will prevent overflow problems and also not have a bunch of issues with my strings? Since I started messing with C, I have had tremendous problems getting this stuff to work and I think I got it now. I...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am reading in strings and integers and I am wondering, am I doing this correctly where I will prevent overflow problems and also not have a bunch of issues with my strings? Since I started messing with C, I have had tremendous problems getting this stuff to work and I think I got it now. I am just wondering how to improve the code I wrote.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;limits.h&gt;<br />
<br />
void read(char *out, const int size);<br />
int readint(int *out);<br />
void readdouble(double *out);<br />
<br />
int main(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char buffer[17] = {0};<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double d = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;read string[16]: &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; read(buffer, 17);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;read integer: &quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(!readint(&amp;i)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;the number you entered is beyond the range allowable, please try again.&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(!readint(&amp;i)) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;the number you entered is beyond the range allowable, please try again.&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;read: %s\t\t%d\n\n&quot;, buffer, strlen(buffer));<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;readint: %d\n\n&quot;, i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;readint: %5.2f\n\n&quot;, d);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;PAUSE&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; function:&nbsp; &nbsp; &nbsp;  read<br />
&nbsp; &nbsp; &nbsp; &nbsp; purpose:&nbsp; &nbsp; &nbsp; &nbsp; reads in a string and assigns it to out. Requires a length of <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string parameter of n+1 (+1 allows for null terminator).<br />
&nbsp; &nbsp; &nbsp; &nbsp; args:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  char *out, const int strlen<br />
&nbsp; &nbsp; &nbsp; &nbsp; returns:&nbsp; &nbsp; &nbsp; &nbsp; void<br />
*/<br />
void read(char *out, const int strlen)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char ch;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int char_count = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Read in the keyboard input until enter is pressed or<br />
&nbsp; &nbsp; &nbsp; &nbsp; // we exceed the buffer. We will not allow the buffer<br />
&nbsp; &nbsp; &nbsp; &nbsp; // to overflow by restricting what actually gets written<br />
&nbsp; &nbsp; &nbsp; &nbsp; // to the pointer.<br />
&nbsp; &nbsp; &nbsp; &nbsp; ch = getchar();<br />
&nbsp; &nbsp; &nbsp; &nbsp; *(out)++ = ch;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(ch != '\n' &amp;&amp; ++char_count &lt; strlen-1) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ch = getchar();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(char_count &lt; strlen-1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *(out)++ = ch;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Null terminate the pointer so it is a proper string<br />
&nbsp; &nbsp; &nbsp; &nbsp; *out = '\0';<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Flush the remaining keyboard input<br />
&nbsp; &nbsp; &nbsp; &nbsp; fflush(stdin);<br />
}<br />
<br />
/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; function:&nbsp; &nbsp; &nbsp;  readint<br />
&nbsp; &nbsp; &nbsp; &nbsp; purpose:&nbsp; &nbsp; &nbsp; &nbsp; reads an integer and assigns it to the out pointer parameter.<br />
&nbsp; &nbsp; &nbsp; &nbsp; defines:&nbsp; &nbsp; &nbsp; &nbsp; INT_LEN<br />
&nbsp; &nbsp; &nbsp; &nbsp; args:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int *out<br />
&nbsp; &nbsp; &nbsp; &nbsp; returns:&nbsp; &nbsp; &nbsp; &nbsp; int (1 success, -1 error)<br />
*/<br />
#define INT_LEN 100<br />
int readint(int *out)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char buf[INT_LEN];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* buffer for retriving an int */<br />
&nbsp; &nbsp; &nbsp; &nbsp; char tmpbuf[INT_LEN];&nbsp;  /* temporary buffer for reconverting the int to a string to check for integer overflow */<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i, tmpbuflen, buflen;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; read(buf, INT_LEN);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  /* read input from the user as a string */<br />
&nbsp; &nbsp; &nbsp; &nbsp; i = atoi(buf);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* convert the string to an int */<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Reconvert to a string to ensure that the conversion didn't cause an integer overflow<br />
&nbsp; &nbsp; &nbsp; &nbsp; itoa(i, tmpbuf, 10);<br />
&nbsp; &nbsp; &nbsp; &nbsp; tmpbuflen = strlen(tmpbuf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; buflen = strlen(buf) - 1; /* subtract 1 for the null terminator, otherwise comparison will fail */<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(tmpbuflen != buflen || INT_MIN &lt; i &amp;&amp; i &gt; INT_MAX) // check if they are the same and within signed integer ranges<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; *out = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>sgalland</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121811-question-about-reading-strings-integers.html</guid>
		</item>
		<item>
			<title>Array size set by variable</title>
			<link>http://cboard.cprogramming.com/c-programming/121810-array-size-set-variable.html</link>
			<pubDate>Fri, 20 Nov 2009 20:49:25 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I am having issues compiling a program with cc on a fairly old unix system, I understand that I need to follow C standards strictly but I can find no way around this. 
 
Code: 
--------- 
array(int n) 
{ 
int i; 
int array[n];]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am having issues compiling a program with cc on a fairly old unix system, I understand that I need to follow C standards strictly but I can find no way around this.<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">array(int n)<br />
{<br />
int i;<br />
int array[n];<br />
<br />
for(i=0;i&lt;=n-1;i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; array[i]=i+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
}</code><hr />
</div>It is a simple function to setup an array to size n which is collected and passed in from the main function. The compiler is freaking at the array declaration, saying that I have declared an array of 0 and that the expression is not constant, as it compiles line by line and this is the last function I am happy with the rest of my code.<br />
Does anyone have any ideas how I can get around this?<br />
<br />
Thanks</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>Drainy</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121810-array-size-set-variable.html</guid>
		</item>
		<item>
			<title>Problem with shared memory</title>
			<link>http://cboard.cprogramming.com/c-programming/121809-problem-shared-memory.html</link>
			<pubDate>Fri, 20 Nov 2009 20:40:44 GMT</pubDate>
			<description>Hi everyone, 
 
I have this problem. 
 
 
Code: 
--------- 
......... 
......... 
open shared memory.....</description>
			<content:encoded><![CDATA[<div>Hi everyone,<br />
<br />
I have this problem.<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">.........<br />
.........<br />
open shared memory.....<br />
.........&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; sem_init(&amp;mutex, 0, 1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; sem_trywait(&amp;mutex);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (i&lt;n) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int f = fork();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (f==0) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RSA *rsa;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rsa = RSA_generate_key(1024 , 65537, NULL, NULL);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr[i].a=BN_bn2hex(rsa-&gt;d);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr[i].b=BN_bn2hex(rsa-&gt;n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
sem_post(&amp;mutex);<br />
<br />
<br />
sem_wait(&amp;mutex);<br />
<br />
int z=0;<br />
while(z&lt;n)<br />
{<br />
printf(&quot;%s\n&quot;,ptr[z].a);<br />
printf(&quot;%s\n&quot;,ptr[z].b);<br />
z++;<br />
}<br />
.........<br />
close shared memory......<br />
.........<br />
.........</code><hr />
</div>when i do printf(ptr[z].a) or printf(ptr[z].b) i don't receive the BN_bn2hex(rsa-&gt;d), but Segmentation Fault.<br />
<br />
Any sugestion to solve this......<br />
Thanks.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>dimaneg</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121809-problem-shared-memory.html</guid>
		</item>
		<item>
			<title>String testing</title>
			<link>http://cboard.cprogramming.com/c-programming/121808-string-testing.html</link>
			<pubDate>Fri, 20 Nov 2009 20:32:26 GMT</pubDate>
			<description><![CDATA[Hello, im trying to design a function that takes in a string, and test it for having 
 
" The first 1/3 (rounding down) of the word's letters is repeated elsewhere in the word. e.g. abracadabra" 
 
I understand the logic of looping through the array, and finding matches, but have been un-able to...]]></description>
			<content:encoded><![CDATA[<div>Hello, im trying to design a function that takes in a string, and test it for having<br />
<br />
&quot; The first 1/3 (rounding down) of the word's letters is repeated elsewhere in the word. e.g. abracadabra&quot;<br />
<br />
I understand the logic of looping through the array, and finding matches, but have been un-able to create a working test that does the above task correctly.<br />
<br />
and help would be greatly appreciated.<br />
<br />
thanks<br />
nailz</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>Nailz</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121808-string-testing.html</guid>
		</item>
		<item>
			<title>Counting Pixels In A Blob</title>
			<link>http://cboard.cprogramming.com/c-programming/121805-counting-pixels-blob.html</link>
			<pubDate>Fri, 20 Nov 2009 19:44:17 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. If I ask it to count the number of pixels in the blob for (0,0) it gives a 4 instead of a 5. Please help!<br />
<br />
<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;stdlib.h&gt;<br />
#include &lt;stdio.h&gt;<br />
<br />
#define N 5<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 />
}<br />
<br />
int main()<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;y, &amp;x);&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 />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>cokacola</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121805-counting-pixels-blob.html</guid>
		</item>
		<item>
			<title>String with two words: 1)String, 2)  $double</title>
			<link>http://cboard.cprogramming.com/c-programming/121804-string-two-words-1-string-2-%24double.html</link>
			<pubDate>Fri, 20 Nov 2009 19:10:05 GMT</pubDate>
			<description><![CDATA[I have a string saved in memory with exactly one space in the middle and two substrings; the string is formatted like this: 
 
"Mike $120.00" 
 
The first word will be saved as a string, the second needs to be converted to a float.  Please, how can I do separate this string at the space and convert...]]></description>
			<content:encoded><![CDATA[<div>I have a string saved in memory with exactly one space in the middle and two substrings; the string is formatted like this:<br />
<br />
&quot;Mike $120.00&quot;<br />
<br />
The first word will be saved as a string, the second needs to be converted to a float.  Please, how can I do separate this string at the space and convert the 2nd string into a float?<br />
<br />
Thanks in advance.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>Roger</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121804-string-two-words-1-string-2-%24double.html</guid>
		</item>
		<item>
			<title>C Escape sequences</title>
			<link>http://cboard.cprogramming.com/c-programming/121799-c-escape-sequences.html</link>
			<pubDate>Fri, 20 Nov 2009 15:06:47 GMT</pubDate>
			<description><![CDATA[Apart from \n and \t escape sequnces, which escape sequences can be written into code and be "invisible" to the user? 
 
For example; 
char a=' 
' 
 
In between the ' ' is a \n when the program reads it. How about other Escapes? Can i find them on the keyboard? 
 
For example \r, \v etc...]]></description>
			<content:encoded><![CDATA[<div>Apart from \n and \t escape sequnces, which escape sequences can be written into code and be &quot;invisible&quot; to the user?<br />
<br />
For example;<br />
char a='<br />
'<br />
<br />
In between the ' ' is a \n when the program reads it. How about other Escapes? Can i find them on the keyboard?<br />
<br />
For example \r, \v etc...<br />
<br />
The reason im asking this is because im writing a syntax checker in C and i want to know which escape sequences count more then 1 blank, and are they all writtable by keyboard.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>Tool</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121799-c-escape-sequences.html</guid>
		</item>
		<item>
			<title>slight code peoblem</title>
			<link>http://cboard.cprogramming.com/c-programming/121797-slight-code-peoblem.html</link>
			<pubDate>Fri, 20 Nov 2009 13:44:29 GMT</pubDate>
			<description><![CDATA[i am attempting to enter a max and min value for a factorial table but the application will only let me enter the first number and i cant see where i have gone wrong. any help would be apreciated 
 
 
Code: 
--------- 
#include <stdio.h> 
 
void main() 
{ 
	int maxfactorial=0, minfactorial=0;]]></description>
			<content:encoded><![CDATA[<div>i am attempting to enter a max and min value for a factorial table but the application will only let me enter the first number and i cant see where i have gone wrong. any help would be apreciated<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;stdio.h&gt;<br />
<br />
void main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int maxfactorial=0, minfactorial=0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;enter max factorial\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot; maxfactorial);<br />
&nbsp; &nbsp; &nbsp; &nbsp; getchar();<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;enter min factorial\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot; minfactorial);&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; getchar();<br />
<br />
}</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>Ciaran789</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121797-slight-code-peoblem.html</guid>
		</item>
		<item>
			<title>automatic creation of structures and deleting them</title>
			<link>http://cboard.cprogramming.com/c-programming/121794-automatic-creation-structures-deleting-them.html</link>
			<pubDate>Fri, 20 Nov 2009 13:37:19 GMT</pubDate>
			<description><![CDATA[Hi all! 
 
How to automatically create structures (the aliens in this code are capable to muliply) and delete them? Is the only way to change the value of "number" in this code and re-define the struct part? What if Alien[55] is killed and at the same time Alien[56] and Alien[57] are multiplying? 
...]]></description>
			<content:encoded><![CDATA[<div>Hi all!<br />
<br />
How to automatically create structures (the aliens in this code are capable to muliply) and delete them? Is the only way to change the value of &quot;number&quot; in this code and re-define the struct part? What if Alien[55] is killed and at the same time Alien[56] and Alien[57] are multiplying?<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">some headers....<br />
<br />
int number;<br />
number = 100;<br />
<br />
struct alien{<br />
&nbsp;int energy;<br />
&nbsp;int health;<br />
}Alien[number]<br />
<br />
int main(void){<br />
<br />
...game...<br />
<br />
}</code><hr />
</div>Thanks in advance for ideas!</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>sababa.sababa</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121794-automatic-creation-structures-deleting-them.html</guid>
		</item>
		<item>
			<title>a tiny problem with a  function</title>
			<link>http://cboard.cprogramming.com/c-programming/121793-tiny-problem-function.html</link>
			<pubDate>Fri, 20 Nov 2009 12:26:38 GMT</pubDate>
			<description><![CDATA[hello, 
 
I'm new  with c programming and... 
 
I'm  trying to program  a function which  should perform  the mathematical  ditstance formula 
 
but I 'm getting this error: found '{' at file scope (missing function header? 
 
this is the code that I wrote]]></description>
			<content:encoded><![CDATA[<div>hello,<br />
<br />
I'm new  with c programming and...<br />
<br />
I'm  trying to program  a function which  should perform  the mathematical  ditstance formula<br />
<br />
but I 'm getting this error: found '{' at file scope (missing function header?<br />
<br />
this is the code that I wrote<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><font color="Blue">#include </font>&lt;stdio.h&gt;<br />
<font color="Blue">#include</font> &lt;math.h&gt;<br />
<br />
<font color="Blue">float</font> distance(<font color="Blue">float </font>x1,<font color="Blue"> float</font> x2, <font color="Blue">float</font> y1, <font color="Blue">float </font>y2);<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; <font color="Blue">float </font>a=0 ,b=0 ,c=0, d=0 e=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; a= x2 -x1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; b= y2 -y1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; c = pow(a,2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; d = pow(b,2);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; c+d=e<br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <font color="Blue">return </font>sqrt(e);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
}<br />
<br />
<font color="Blue">int </font>main()<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; x1=2; x2=4; y1=3; y2=6;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%lf\n&quot;,distance(x1,x2,y1,y2);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <font color="Blue">return</font> 0;<br />
}</code><hr />
</div>what do I do wrong?<br />
<br />
thenks for helping.. :)</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>sing0</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121793-tiny-problem-function.html</guid>
		</item>
		<item>
			<title>Image comparison - How to read an image so you can compare pixels?</title>
			<link>http://cboard.cprogramming.com/c-programming/121790-image-comparison-how-read-image-so-you-can-compare-pixels.html</link>
			<pubDate>Fri, 20 Nov 2009 06:13:01 GMT</pubDate>
			<description>I am writing a program in C that compares two images taken by a camera to see if they are different. I have an idea of how to do this, by putting the images into 2 dimensional arrays and comparing the RGB value at corresponding array positions, however I cannot figure out how to get the image into...</description>
			<content:encoded><![CDATA[<div>I am writing a program in C that compares two images taken by a camera to see if they are different. I have an idea of how to do this, by putting the images into 2 dimensional arrays and comparing the RGB value at corresponding array positions, however I cannot figure out how to get the image into an array. <br />
<br />
I've found a ton of example of how to do this in C#, but that's not so helpful. The only bit of C code I've been able to find uses fread() to read the images but that doesn't seem to work.<br />
<br />
I've also heard some suggestions that converting the images to greyscale is helpful in comparing the pixels. Agree? Disagree?<br />
<br />
Thanks in advance.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>dearbear</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121790-image-comparison-how-read-image-so-you-can-compare-pixels.html</guid>
		</item>
		<item>
			<title>C to y86</title>
			<link>http://cboard.cprogramming.com/c-programming/121786-c-y86.html</link>
			<pubDate>Fri, 20 Nov 2009 03:31:36 GMT</pubDate>
			<description><![CDATA[I don't know if this is the correct place to post this, but here goes... 
 
I am trying to get this program: 
 
Code: 
--------- 
#include <stdio.h> 
 
int main() {]]></description>
			<content:encoded><![CDATA[<div>I don't know if this is the correct place to post this, but here goes...<br />
<br />
I am trying to get this program:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;stdio.h&gt;<br />
<br />
int main() {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int A[4]={1,2,3,4};<br />
&nbsp; &nbsp; &nbsp; &nbsp; int B[4]={4,3,2,1};<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int dot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; dot=A[0]*B[0]+A[1]*B[1]+A[2]*B[2]+A[3]*B[3];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d&quot;, dot);<br />
<br />
}</code><hr />
</div>to y86.  This is what I have:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">&nbsp; &nbsp; &nbsp; &nbsp; .pos 0<br />
<br />
<br />
.LC0:<br />
&nbsp; &nbsp; &nbsp; &nbsp; .string&nbsp; &nbsp; &nbsp; &nbsp; &quot;%d\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; .text<br />
.globl main<br />
&nbsp; &nbsp; &nbsp; &nbsp; .type&nbsp; &nbsp; &nbsp; &nbsp; main, @function<br />
main:<br />
&nbsp; &nbsp; &nbsp; &nbsp; pushl&nbsp; &nbsp; &nbsp; &nbsp; %ebp<br />
&nbsp; &nbsp; &nbsp; &nbsp; rrmovl&nbsp; &nbsp; &nbsp; &nbsp; %esp, %ebp<br />
&nbsp; &nbsp; &nbsp; &nbsp; andl&nbsp; &nbsp; &nbsp; &nbsp; $-16, %esp<br />
&nbsp; &nbsp; &nbsp; &nbsp; pushl&nbsp; &nbsp; &nbsp; &nbsp; %ebx<br />
&nbsp; &nbsp; &nbsp; &nbsp; subl&nbsp; &nbsp; &nbsp; &nbsp; $76, %esp<br />
&nbsp; &nbsp; &nbsp; &nbsp; irmovl&nbsp; &nbsp; &nbsp; &nbsp; $1, 44(%esp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; irmovl&nbsp; &nbsp; &nbsp; &nbsp; $2, 48(%esp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; irmovl&nbsp; &nbsp; &nbsp; &nbsp; $3, 52(%esp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; irmovl&nbsp; &nbsp; &nbsp; &nbsp; $4, 56(%esp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; irmovl&nbsp; &nbsp; &nbsp; &nbsp; $4, 28(%esp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; irmovl&nbsp; &nbsp; &nbsp; &nbsp; $3, 32(%esp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; irmovl&nbsp; &nbsp; &nbsp; &nbsp; $2, 36(%esp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; irmovl&nbsp; &nbsp; &nbsp; &nbsp; $1, 40(%esp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; mrmovl&nbsp; &nbsp; &nbsp; &nbsp; 44(%esp), %edx<br />
&nbsp; &nbsp; &nbsp; &nbsp; mrmovl&nbsp; &nbsp; &nbsp; &nbsp; 28(%esp), %eax<br />
&nbsp; &nbsp; &nbsp; &nbsp; imull&nbsp; &nbsp; &nbsp; &nbsp; %eax, %edx<br />
&nbsp; &nbsp; &nbsp; &nbsp; mrmovl&nbsp; &nbsp; &nbsp; &nbsp; 48(%esp), %ecx<br />
&nbsp; &nbsp; &nbsp; &nbsp; mrmovl&nbsp; &nbsp; &nbsp; &nbsp; 32(%esp), %eax<br />
&nbsp; &nbsp; &nbsp; &nbsp; imull&nbsp; &nbsp; &nbsp; &nbsp; %ecx, %eax<br />
&nbsp; &nbsp; &nbsp; &nbsp; leal&nbsp; &nbsp; &nbsp; &nbsp; (%edx,%eax), %ebx<br />
&nbsp; &nbsp; &nbsp; &nbsp; mrmovl&nbsp; &nbsp; &nbsp; &nbsp; 56(%esp), %edx<br />
&nbsp; &nbsp; &nbsp; &nbsp; mrmovl&nbsp; &nbsp; &nbsp; &nbsp; 40(%esp), %eax<br />
&nbsp; &nbsp; &nbsp; &nbsp; imull&nbsp; &nbsp; &nbsp; &nbsp; %eax, %edx<br />
&nbsp; &nbsp; &nbsp; &nbsp; mrmovl&nbsp; &nbsp; &nbsp; &nbsp; 52(%esp), %ecx<br />
&nbsp; &nbsp; &nbsp; &nbsp; mrmovl&nbsp; &nbsp; &nbsp; &nbsp; 36(%esp), %eax<br />
&nbsp; &nbsp; &nbsp; &nbsp; imull&nbsp; &nbsp; &nbsp; &nbsp; %ecx, %eax<br />
&nbsp; &nbsp; &nbsp; &nbsp; leal&nbsp; &nbsp; &nbsp; &nbsp; (%edx,%eax), %eax<br />
&nbsp; &nbsp; &nbsp; &nbsp; leal&nbsp; &nbsp; &nbsp; &nbsp; (%ebx,%eax), %eax<br />
&nbsp; &nbsp; &nbsp; &nbsp; rmmovl&nbsp; &nbsp; &nbsp; &nbsp; %eax, 60(%esp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; irmovl&nbsp; &nbsp; &nbsp; &nbsp; $.LC0, %eax<br />
&nbsp; &nbsp; &nbsp; &nbsp; mrmovl&nbsp; &nbsp; &nbsp; &nbsp; 60(%esp), %edx<br />
&nbsp; &nbsp; &nbsp; &nbsp; rmmovl&nbsp; &nbsp; &nbsp; &nbsp; %edx, 4(%esp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; rmmovl&nbsp; &nbsp; &nbsp; &nbsp; %eax, (%esp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; call&nbsp; &nbsp; &nbsp; &nbsp; printf<br />
&nbsp; &nbsp; &nbsp; &nbsp; addl&nbsp; &nbsp; &nbsp; &nbsp; $76, %esp<br />
&nbsp; &nbsp; &nbsp; &nbsp; popl&nbsp; &nbsp; &nbsp; &nbsp; %ebx<br />
&nbsp; &nbsp; &nbsp; &nbsp; rrmovl&nbsp; &nbsp; &nbsp; &nbsp; %ebp, %esp<br />
&nbsp; &nbsp; &nbsp; &nbsp; popl&nbsp; &nbsp; &nbsp; &nbsp; %ebp<br />
&nbsp; &nbsp; &nbsp; &nbsp; ret<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; .pos 0x100<br />
Stack:</code><hr />
</div>But I am getting missing colon errors on my simulator.  There aren't colons in y86 other than the loops, any suggestions?</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>TIMBERings</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121786-c-y86.html</guid>
		</item>
		<item>
			<title>Passing arrays</title>
			<link>http://cboard.cprogramming.com/c-programming/121783-passing-arrays.html</link>
			<pubDate>Thu, 19 Nov 2009 23:48:15 GMT</pubDate>
			<description><![CDATA[Hey all, I'm at the part of my course where I am being taught arrays, and passing them to functions. I have been asked to produce a program that has 2 arrays that the user enters 10 numbers in and then gives the total for each array.  
 
So far i've come up with this : 
Code: 
--------- 
#include...]]></description>
			<content:encoded><![CDATA[<div>Hey all, I'm at the part of my course where I am being taught arrays, and passing them to functions. I have been asked to produce a program that has 2 arrays that the user enters 10 numbers in and then gives the total for each array. <br />
<br />
So far i've come up with this :<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">#include &lt;stdlib.h&gt;<br />
#include &lt;stdio.h&gt;<br />
<br />
#define NUMBER_ELEMENTS 10<br />
<br />
void f_enter ();<br />
void f_display ();<br />
<br />
void main () <br />
{<br />
<br />
float number[NUMBER_ELEMENTS];<br />
<br />
f_enter (number, NUMBER_ELEMENTS);<br />
f_display (number, NUMBER_ELEMENTS) ;<br />
<br />
exit(0);<br />
}<br />
<br />
void f_enter (int input[], int size)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i = 0 ;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; 10; i ++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Enter number %d for first array: &quot;, i + 1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf(&quot;%d&quot;, &amp;input[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fflush(stdin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
void f_display (int display[], int number_elements)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i = 0, total = 0 ;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; 10; i ++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; total = total + display[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;total is %d &quot;, total);<br />
}</code><hr />
</div>This does it for one array, but I really just copied some other code from a book that did something similar and it somehow works. I really don't see how the array is being passed and used in the display function, or how I would do this for a second array. <br />
<br />
Is there anyone who can help explain whats going on in the code and how its being passed between f_enter and f_display.</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>renvaar</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121783-passing-arrays.html</guid>
		</item>
		<item>
			<title>Help with pointer to structure</title>
			<link>http://cboard.cprogramming.com/c-programming/121780-help-pointer-structure.html</link>
			<pubDate>Thu, 19 Nov 2009 21:20:54 GMT</pubDate>
			<description><![CDATA[Hi, I'm just getting started with structures on C and they don't seem to bad but my main question is about pointers to structures. 
 
Basically I have a structure containing a vector array and length and 'vs' has to be a pointer to a structure of this sort. So I defined 'vs' as such: 
 
 
Code:...]]></description>
			<content:encoded><![CDATA[<div>Hi, I'm just getting started with structures on C and they don't seem to bad but my main question is about pointers to structures.<br />
<br />
Basically I have a structure containing a vector array and length and 'vs' has to be a pointer to a structure of this sort. So I defined 'vs' as such:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">typedef struct<br />
{<br />
&nbsp; &nbsp; vector arr[100];<br />
&nbsp; &nbsp; int length;<br />
}ps, *vs;</code><hr />
</div>where vector is:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">typedef struct<br />
{<br />
&nbsp; &nbsp; int x;<br />
&nbsp; &nbsp; int y;<br />
}vector;</code><hr />
</div>I have a function that makes pointers of structures of type 'vs' but I'm not sure on how to set it up. The way only way I could think of it was to make a structure of the same type as '*vs' called 'ps' and initialize 'ps' thus making 'vs' = the address of the initialized 'ps' like so:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">vs *make_vs ()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; ps strt = {{0,0},0}; // initializing instance of structure 'ps'<br />
&nbsp; &nbsp; &nbsp; &nbsp; vs *ptr;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // declaring instance of '*vs'<br />
&nbsp; &nbsp; &nbsp; &nbsp; ptr = &amp;strt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // setting ptr to the address of 'strt'<br />
&nbsp; &nbsp; &nbsp; &nbsp; return ptr;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // returning pointer of type 'vs'<br />
}</code><hr />
</div>I'm really not sure if I'm going about this the correct way. I basically just want to created a new instance of the structure defined above and return a pointer to that structure.<br />
<br />
Such that I can utilize it like so:<br />
<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">vs a = *make_vs (); // or however I am supposed to create a new instance</code><hr />
</div>The ultimate goal is to create these 'vs' pointers and be able to add/remove/get vectors from the array the structure holds. If that made any sense to anyone, could you please enlighten me or point me in the right direction? <br />
<br />
Thank you</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>dp2452</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121780-help-pointer-structure.html</guid>
		</item>
		<item>
			<title>Window sized 2-d array!</title>
			<link>http://cboard.cprogramming.com/c-programming/121778-window-sized-2-d-array.html</link>
			<pubDate>Thu, 19 Nov 2009 19:41:23 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I'm still getting used to C and I've come across something I'm slightly stuck on: 
 
I need to make a 2-d array of characters array[i][J] that matches the width and the height of the output window i.e. (I-1)x(J). 
 
Any ideas of how I can work out the size for varying output screen sizes? 
...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I'm still getting used to C and I've come across something I'm slightly stuck on:<br />
<br />
I need to make a 2-d array of characters array[i][J] that matches the width and the height of the output window i.e. (I-1)x(J).<br />
<br />
Any ideas of how I can work out the size for varying output screen sizes?<br />
<br />
Thanks</div>

]]></content:encoded>
			<category domain="http://cboard.cprogramming.com/c-programming/">C Programming</category>
			<dc:creator>Chrisboggis</dc:creator>
			<guid isPermaLink="true">http://cboard.cprogramming.com/c-programming/121778-window-sized-2-d-array.html</guid>
		</item>
	</channel>
</rss>
