My latest assignment (practice not coursework!) is to write prototype interactive exam/test console application. I've used structs to store the question information (not sure if this was the best way to do it?) and I have the following code that outputs each question and it's possible answers:
We've been told to make the code as modular as possible so I'd like to have the above code in a function but I'm not sure how to pass the question index to it (I think via a pointer but I'm unsure of the mechanics) and whether or not the function will have any visibility of the rest of the structs components... Any pointers (pun intended!) to how I can do this? Or if it can be done...
I'm also using the following code to load data into my struct. Visual C++ gives me warnings about using strcpy, is there a better way of doing this?
Many thanks,
p.
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
e-Quals IT Practitioners Diploma - C++ Programming
Farnborough Tech. UK.
Dr. Usman Abdullahi
---------- Post updated at 06:34 PM ---------- Previous update was at 03:24 PM ----------
Hi All,
Doing some digging around I've found the answer to my problem - on page 168 of Herbert Schildt's "C++ The Complete Reference" I found a section entitled "Passing Entire Structures to Functions".
So I modified my function to look like this:
The call to run the function from main looks like this:
Hi,
I have received an application that stores some properties in a file. The existing struct looks like this:
struct TData
{
UINT uSizeIncludingStrings;
// copy of Telnet data struct
UINT uSize;
// basic properties:
TCHAR szHost; //defined in Sshconfig
UINT iPortNr;
TCHAR... (2 Replies)
In a well-known book on the C language, there is an example of an efficient method for using a struct member as an argument to a function. (I'm a C noob, but I believe the correct terminology might be: use call-by-reference instead of call-by-value.) The function is printf.
Anyway, here's a... (5 Replies)
when i have a function definition and function call in my script , i am unable to run my script in background with nohup..
Help me out please..... (3 Replies)
I am trying to work out the best syntax for a relatively simple operation. The goal is to declare an instance of a struct and pass it around to be populated and have the data manipulated. There is an extra wrinkle in that the functions are in different src files.
The main is simple,
#include... (5 Replies)
Hi, i'm trying to copy a struct into a binary file using the unix instruction write, so i declare and fill the struct "superbloque" in one function "initSB" and then i pass the pointer to another function called bwrite (for block write) which calls write. The problem is that i call the function... (2 Replies)
I have two or more linked lists that have the same names for their "next". For example,
struct server_t {
sockaddr_in * sin;
server_t * next_;
}
struct player_t {
char name;
player_t * next_;
}
How can I get a function to take in either type and manipulate the pointers?
I... (3 Replies)
I am using a structure defined as follows
struct gene_square
{
double *x;
double *y;
};I have class, with a member function which is a pointer of this type:
gene_square* m_Genes;I am allocating memory in the constructors like this:
m_Genes = new gene_square;
for (ii=0;... (1 Reply)
hi all,
i'm looking for a bash or tcsh script that will clone an empty dir tree 'over' another tree ...
specifically, i'd like to:
(1) specify a src directory
(2) list the directory tree/hiearchy beneath that src dir, w/o files -- just the dirs
(3) clone that same, empty dir hierarchy to... (2 Replies)
I'm trying to do a global search and replace in vi. I am trying to replace a string, call it "BOB" with a carriage return and can't seem to find a reference to it.
Command syntax s%/BOB/???/g
What would I substitute the "???" with? (7 Replies)