Question
Create CodeBlocks project (C++ console application) 2. Download the binary database file to project folder 3. Copy the skeleton code to the project source file
Create CodeBlocks project (C++ console application)
2. Download the binary database file to project folder
3. Copy the skeleton code to the project source file (main.cpp)
4. Fill in and complete the blanks for the source code
5. Compile and build the 'plumbing' program
6. Run the program: use the database as the input file (pipes.bin) and output to a text file
The database (input file) is located at http://web.eng.fiu.edu/watsonh/EEL2880/pipesDatabase.html
This is the code so far (in C++):
#include
#include
#include
// set string lengths
#define STRSHORT = 15 chars
#define STRMED = 30 chars
#define STRLONG = 80 chars
usingnamespacestd;
typedefstructcompany
{
charname [STRLONG];
charstreet [STRLONG];
charcity [STRMED];
charstate [STRMED];
charzip [STRSHORT];
charphone [STRSHORT];
charcell [STRSHORT];
intrating;
charcontact [STRLONG];
}
company;
voidprintInfo(company* info, FILE* fp);
intmain()
{
intBlockNumber;
charinput* [STRLONG]; //create an input file name (think up a name)
charoutput* [STRLONG]; //create an output file name
company* info =newcompany;
printf(\"Enter input file name :\");
scanf(\"%s\", input file name );
fflush(stdin); /* flush keyboard buffer */
// open binary data file
if((file pointer = fopen (calling arguments)) ==NULL)
{
fprintf(stderr, \"Error opening input file.\");
exit(1);
}
printf(\"Enter output file name :\");
scanf(\"%s\", output file name );
fflush(stdin); /* flush keyboard buffer */
// open output text file
if( fill in the fopen expression to open the output text file page 2 )
{
fprintf(stderr, \"Error opening output file.\");
exit(1);
}
for(BlockNumber=0; BlockNumber10;>
{
/* Move the position indicator to the specified element. */
if( fill in the fseek expression to position to BlockNumber page 3 )
{
fprintf(stderr, \" Error using fseek().\");
exit(1);
}
/* Read in a single info. */
fread(output*,sizeof(information structure), 1, input*)
fprintf(op,\" Block %d \",BlockNumber); /add header text
printInfo (fill in correct calling arguments);
}
return0;
}
voidprintInfo(fill in calling arguments companyandoutput file pointe)
{
// print all the info values
fprintf (fp,\"Name: %s \",info->name);
fprintf ( fill in correct arguments );
fprintf ( fill in correct arguments );
fprintf ( fill in correct arguments );
fprintf ( fill in correct arguments );
fprintf ( fill in correct arguments );
fprintf ( fill in correct arguments );
fprintf ( fill in correct arguments );
fprintf ( fill in correct arguments );
return;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started