structs



 DEVELOP > c-Plus-Plus > structs

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: ""
Date: 12 Sep 2006 06:42:39 AM
Object: structs
hi
i have an assignment on structs. i'am facing some difficulties in that
there is function that requires to read from a binary, i know hw to do
that but another part of it says that it return the number of entries
read from the file. how do we do that.
and another part of it says that we have to add struct details from the
user into an array. i have the code that asks the user for input but
dunno how to add it to a array
hope u can help me
thanz
Deepak
.

User: "osmium"

Title: Re: structs 12 Sep 2006 08:27:03 AM
<07deep@gmail.com> wrote:

i have an assignment on structs. i'am facing some difficulties in that

there is function that requires to read from a binary, i know hw to do
that but another part of it says that it return the number of entries
read from the file. how do we do that.

I read your question as:
"... but another part of the assignment says that the function I write
should return the aggregate number of records that the function has read
from the file".
Is that a valid rendition? If so, you may want a static variable in the
fuinction to contain a count of records and update it on each call to the
function. You could add a parameter to the argument list to tell the
function to return the accumulated value, rather than doing it's ordinary
thing.

and another part of it says that we have to add struct details from the
user into an array. i have the code that asks the user for input but
dunno how to add it to a array

We know nothing about this array or this structure. I read it as " I dunno
how to do x with y even though I have z".
.

User: "Thomas Matthews"

Title: Re: structs 12 Sep 2006 11:50:45 PM
wrote:

hi

i have an assignment on structs. i'am facing some difficulties in that

there is function that requires to read from a binary, i know hw to do
that but another part of it says that it return the number of entries
read from the file. how do we do that.

and another part of it says that we have to add struct details from the
user into an array. i have the code that asks the user for input but
dunno how to add it to a array

hope u can help me

thanz
Deepak

I suggest that you add "Binary_Read" methods to your structure.
Have code that creates instances, reads them, puts them into a
container, then increments a counter. If the container is smart, you
can query it to find the number of items.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
.

User: "Victor Bazarov"

Title: Re: structs 12 Sep 2006 07:38:37 AM
wrote:

i have an assignment on structs. i'am facing some difficulties in that

there is function that requires to read from a binary, i know hw to do
that but another part of it says that it return the number of entries
read from the file. how do we do that.

Wrap them in a struct. Return that struct.

and another part of it says that we have to add struct details from
the user into an array. i have the code that asks the user for input
but dunno how to add it to a array

Use indexing operator, you know, "[]". If your array has enough room
in it to store the input, use assignment to an element of the array and
then increment the index to prepare to store to the next element.

hope u can help me

Not sure how. You only explained what you know and what you don't know.
Ask a particular question. Put your code on the table, let's see what
you have done so far (since you know enough to have written something).
And read the FAQ. All of it. And I mean *all of it*. You may not be
able to understand some of it, but you need to read it all to see if it
answers some of the questions you have.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER