quote:
Pointers and arrays are virtually the same thing.
You could simply use the sizeof operator to prove it wrong.
quote:
Pointers and arrays are virtually the same thing.
struct stuff { int a; char b; };// only needs one elementvoid funct1(struct stuff *elem){ printf("a=%d ",elem.a); printf("b=%d\n",elem.b);}// needs multiple elementsvoid funct2(struct stuff *elem){ int i; for (i=0; i< 5; i++) { printf("a=%d ",elem->a); printf("b=%d\n",elem->b);<br> }<br>}<br><br>// combination of the two (dosent work)<br>void funct2(struct stuff *elem)<br>{<br> int i;<br> for (i=0; i< 5; i++) {<br> funct1(&test); <br> }<br>}<br><br>int main()<br>{<br> struct stuff test[5];<br> funct1(&test[0]);<br> funct2(test);<br> funct3(test);<br> return 0;<br>}<br> </pre> <br><br>This was just typed out of my head wo it *may* caontain an error. If so I appologize.<br><br> </i> <br><br>- Twisted Matrix<br><br><SPAN CLASS=editedby>[edited by - TwistedMatrix on November 21, 2002 9:46:05 AM]</SPAN>
quote: Original post by TwistedMatrix
I have another important question. Why is it that either of the folloing work.
#include <stdio.h>typedef struct STUFF // use typedef to enter stuff into the symbol table{ int a; char b;} stuff;void funct1(stuff *elem){ printf("a=%d ",elem->a); printf("b=%d\n",elem->b);}void funct2(stuff *elem){ int i; for (i=0; i< 5; i++) { printf("a=%d ",elem[i].a); printf("b=%d\n",elem[i].b); }}void funct3(stuff *elem){ int i; for (i=0; i< 5; i++) { funct1(&elem[i]); }}int main(){ stuff test[5]; funct1(&test[0]); funct2(test); funct3(test);}
quote:
whats the difference?
quote:
And why can you not nest the routines?
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse