473,322 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

Sep 12 '06 #1
3 2029
07****@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.
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
Sep 12 '06 #2
<07****@gmail.comwrote:
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".
Sep 12 '06 #3
07****@gmail.com 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

Sep 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: news.microsoft.com | last post by:
Hi, I am using structs and am also using property accessors to access those private member fields... TO me this is a good way of handling them, but I find alot of people using direct access to...
6
by: James Pascoe | last post by:
Dear All, Apologies if this is OT. I have a C program which processes an arbitrary number of structs that are stored in a hash table. (The nature of the processing and the layout of the...
5
by: Paminu | last post by:
Why make an array of pointers to structs, when it is possible to just make an array of structs? I have this struct: struct test { int a; int b;
10
by: Angel | last post by:
I'm using several C functions (in a dll) that receive a struct as parameter. Since I'm doing it in C#, I assume I need to recreate the struct in C# in order to call the function with the required...
5
by: Bidule | last post by:
Hi, I'm trying to sort structs defined as follows: struct combinationRec { float score; char* name; }; The number of structs and the length of the "name" field are not known
5
by: Bilgehan.Balban | last post by:
Hi, I am currently brushing up my c++ knowledge and I would like to ask you about the differences between classes and C structs, in the function/method perspective. 1) Is it correct to say...
61
by: Marty | last post by:
I am new to C# and to structs so this could be easy or just not possible. I have a struct defined called Branch If I use Branch myBranch = new Branch(i); // everything works If I use Branch...
11
by: Cliff Martin | last post by:
Hi, I am reading a fairly large file a line at a time, doing some processing, and filtering out bits of the line. I am storing the interesting information in a struct and then printing it out....
29
by: Dom | last post by:
I'm really confused by the difference between a Struct and a Class? Sometimes, I want just a group of fields to go together. A Class without methods seems wrong, in that it carries too much...
43
by: JohnQ | last post by:
Are a default constructor, destructor, copy constructor and assignment operator generated by the compiler for a struct if they are not explicitely defined? I think the answer is yes, because...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.