Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: previous de...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 13 of 13 Topic 26048 of 26972
Post > Topic >>

Re: previous declaration of Table was here / conflicting types for

by "Michael.Zhang" <zhangqiuyuan@[EMAIL PROTECTED] > May 10, 2008 at 08:11 PM

[snip:
On May 9, 10:43=A0pm, Chris Torek <nos...@[EMAIL PROTECTED]
> wrote:
> In article
<0f2fcd7d-9fd0-47cd-8458-d517e7def...@[EMAIL PROTECTED]
>Michael.Zhang <zhangqiuy...@[EMAIL PROTECTED]
> wrote:
>
> [in a reply to Ben Bacarisse]
>
> >I just want to make sure I got you right.You are suggesting:
> >typedef struct Table{ ...} Table;
> >Table * makeTable( void* size, void * data);
>
> I can only speak for myself, not for Ben Bacarisse, but I rather
> doubt that is what he is suggesting.
>
> In the absence of additional details, here is how *I* might do
> this. =A0Note that I prefer not to use "typedef" -- which does not
> actually define types -- at all, but there are some "pro-typedef"
> reasons. =A0See <http://web.torek.net/torek/c/types2.html>
for
> details on this.
>
> In this particular case, I might have a "table.h" file. =A0In table.h,
> one would find, e.g., the following (assuming the table is indexed
> by simple "row,column" integer-pairs):
>
> =A0 =A0 struct table;
>
> =A0 =A0 struct table *table_create(void);
> =A0 =A0 void *table_lookup(struct table *table, int row, int col);
> =A0 =A0 int table_insert(struct table *table, int row, int col, void
*data=
);
> =A0 =A0 void *table_delete(struct table *table, int row, int col);
> =A0 =A0 void table_iterate(struct table *table, void *aux,
> =A0 =A0 =A0 =A0 void (*iter)(struct table *table, void *aux,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int row, int col, void
*data));=

> =A0 =A0 void table_destroy(struct table *table, int free_all_data);
>
> Note that there is no "{" after "struct table". =A0This means that
> the entire contents of a "struct table" are hidden. =A0So where are
> they? =A0The answer is: in table.c (or perhaps in table-impl.h, which
> is then #include-ed by table1.c and table2.c, if for some reason
> "table.c" is not suitable to be used as a single file).
>
> "Table clients", as it were, now have no idea what is *inside* a
> table. =A0They only know that they can "create" one, do "lookup"
> operations, do "insert" operations, do "delete" operations, ask to
> "iterate" a function (of their choosing) over all table entries,
> and "destroy" a table (with, in this case, optional automatic calls
> to free() on each table item, so that they need not write a "freeing
> iterator").
>
> There is still quite a bit exposed here. =A0For instance, this makes
> it clear that tables are indexed exclusively by integral (row,column)
> pairs. =A0We must also decide whether "iterate" is called for "empty"
> entries (e.g., if there is a row 7, but only a column 3 in row 7
> -- even though other rows have columns 0 through 5 -- does the
> user's iterator get called with NULL entries for columns 0, 1, 2,
> 4, and 5 on row 7?). =A0Nonetheless, the actual details of how the
> tables are implemented are safely tucked away: clients know only
> as much about tables as you choose to expose, while the "table
> server" code (in table.c) sees all the details.
>
> (Also, rather than "table", the above should probably called a
> "sparse matrix" anyway. =A0"Tables" might actually instead be hash
> tables that implement what one uses associative arrays for in
> languages like awk, for instance.)
> --
> In-Real-Life: Chris Torek, Wind River Systems
> Salt Lake City, UT, USA (40=B039.22'N, 111=B050.29'W) =A0+1 801 277 2603
> email: gmail (figure it out) =A0 =A0
=A0http://web.torek.net/torek/index.h=
tml

]


OFF TOPIC to previous discussion,reason being don't know where I
should post this question.

Thanks very much for all your replies. Seems most of you have a lot of
experiences in computer science. I might just ask you some questions
that I couldn't get advice from.

my problem is that I love computer science,i know how do study,but I
dont understand the material well enough, I am terrible computer
science student, I don't know what's gonna happen to person like me
after graduating with a GPA around C in CS.

I love computer science, cos I like programming, I enjoy debugging,
tracing down the logic and fix the bug. I am fancinated by the
algorithms being tought and problem solving skills I gained.
but, I am not doing well at all in my courses. My peer can finish a
programming assignment within 3 or 4 hours without help from TA at
all; while I can't progress much without help from others,  it might
take me well over 20 hours even with help from others. I am not
efficient at programming at all.

Right now, I am taking a data structure and an algorithm course(Graph
theory,divide and conquer,danamic programming). I might barely pass my
data structure course, but fail the algorithm.

Before adding CS as another major, I studied some business courses
from accoutning and information systems,I did pretty well in thoese
courses,I believe I have a good study habbit.Lately, I have to admit
that I have to be a lot smarter to study Computer Science and I am not
at that level. I am sitting on the fence and don't know if I should
continue with CS(have taken 8 CS courses) or drop out of this major.

Any advice or opinion would be greatly appreciated.
 




 13 Posts in Topic:
previous declaration of Table was here / conflicting types for
"Michael.Z" <  2008-05-03 00:22:21 
Re: previous declaration of Table was here / conflicting types
ade ishs <no-spam@[EMA  2008-05-03 19:34:39 
Re: previous declaration of Table was here / conflicting types
Flash Gordon <spam@[EM  2008-05-03 10:32:51 
Re: previous declaration of Table was here / conflicting types f
"Michael.Z" <  2008-05-05 19:33:26 
Re: previous declaration of Table was here / conflicting types f
Nick Keighley <nick_ke  2008-05-06 02:21:25 
Re: previous declaration of Table was here / conflicting types f
Ben Bacarisse <ben.use  2008-05-06 12:32:13 
Re: previous declaration of Table was here / conflicting types f
"Michael.Z" <  2008-05-07 01:05:08 
Re: previous declaration of Table was here / conflicting types f
Flash Gordon <spam@[EM  2008-05-07 19:14:36 
Re: previous declaration of Table was here / conflicting types f
CBFalconer <cbfalconer  2008-05-07 12:01:43 
Re: previous declaration of Table was here / conflicting types f
"Michael.Zhang"  2008-05-09 02:40:34 
Re: previous declaration of Table was here / conflicting types f
Chris Torek <nospam@[E  2008-05-10 05:43:46 
Re: previous declaration of Table was here / conflicting types f
Ben Bacarisse <ben.use  2008-05-10 01:19:38 
Re: previous declaration of Table was here / conflicting types f
"Michael.Zhang"  2008-05-10 20:11:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 21:47:03 CDT 2008.