Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help compling this program. Here's the codes for: cs1713p1.h ********************************************************************** cs1713p1.h Purpose: Defines typedefs for Team - includes team ID, team name, number

image text in transcribed

image text in transcribed

image text in transcribed

I need help compling this program.

Here's the codes for: cs1713p1.h

********************************************************************** cs1713p1.h Purpose: Defines typedefs for Team - includes team ID, team name, number of wins, number of losses, email address, phone, contact full name, fee amount, and amount paid. Defines constants for boolean values error messages program return codes Prototypes Notes: **********************************************************************/ /**** typedefs ****/ // Team information typedef struct { char szTeamId[7]; // 6 character Team ID char szEmailAddr[31]; // Team's email address char szTeamName[13]; // Team full name char szPhone[14]; // Team contact phone number (999)999-9999 char szContactname[21]; // Team contact first and last name int iWins; // Number of wins int iLosses; // Number of losses double dFeeAmount; // Amount of fees double dPaidAmount; // Amount this team has paid } Team; /**** constants ****/ // Maximum sizes #define MAX_LINE_SIZE 100 // boolean #define FALSE 0 #define TRUE 1 /* Error Messages */ #define ERR_MISSING_SWITCH "missing switch " #define ERR_EXPECTED_SWITCH "expected switch, found " #define ERR_MISSING_ARGUMENT "missing argument for " #define ERR_TEAM_FILENAME "invalid Team file name " #define ERR_TEAM_ID_DATA "invalid Team id data " #define ERR_TEAM_CONTACT_DATA "invalid Team contact data " /* program return codes */ #define ERR_COMMAND_LINE_SYNTAX -1 // invalid command line syntax #define USAGE_ONLY -2 // show usage only #define ERROR_PROCESSING -3 /* prototypes */ /* functions you must code */ void getTeams(); void exitError(char *pszMessage, char *pszDiagnosticInfo); void exitUsage(int iArg, char *pszMessage, char *pszDiagnosticInfo); 

And for p1abc123:

/********************************************************************** p1abc123.c by LastName, FirstName (change the previous line for your abc123 ID and your name) Purpose: This program reads team data to show current rankings. Command Line Arguments: p1 -t teamFileName Input: Stream input file which contains many teams. There are two different kinds of lines of data for each team: - Team Identification Information: o One line per team (separated by spaces) szTeamId iWins iLosses dFeeAmount dPaidAmount 6s d d lf lf - Team Contact Information: o One line per team (separated by commas) szTeamNm szEmail szPhone szContactName 12s 30s 13s 20s o Although szTeamNm is a maximum of 12 characters, it may contain spaces; therefore, you cannot simply use %13s. For szFullName, you will have to use a bracket format code using %[^,]. The next two values are also terminated by commas. o For szContactName, it contains spaces and is terminated by a new line character. You will have to use a bracket format code using %[^ ] Results: Print the list of teams as shown below. Examples: Id Team Name Wins Loss Fee Amt Paid Amt Contact Name Phone Email UTSA01 Armadillos 8 0 150.00 80.00 Jean E Us (210)555-1111 utsa*xyz.com COM001 Comm Eagles 7 1 150.00 75.00 Mae King (210)555-2222 maeking*xyz.com SOUTH1 Slam Dunk 5 3 120.00 75.00 Jerry Tall (210)555-3333 slamdunk*xyz.com ALHGHT Cake Eaters 4 4 175.00 100.00 E Z Street (210)555-6666 sliverspoon*xyz.com UNKN01 Org New Blk 1 7 150.00 50.00 Bob Wire (210)555-1234 bobwire*xyz.com NEWB01 River Rats 0 8 120.00 75.00 Rock D Boat (210)555-4444 riverrat*xyz.com UNKN02 Hackers 3 5 150.00 75.00 Tom E Gunn (210)555-5555 cyber*xyz.com Returns: 0 normal -1 invalid command line syntax -2 show usage only -3 error during processing, see stderr for more information Notes: p1 -? will provide the usage information. In some shells, you will have to type reserve -\? **********************************************************************/ // If compiling using visual studio, tell the compiler not to give its warnings // about the safety of scanf and printf #define _CRT_SECURE_NO_WARNINGS 1 #include  #include  #include  #include "cs1713p1.h" FILE *pFileTeam; // stream Input for Team data void processCommandSwitches(int argc, char *argv[], char **ppszTeamFileName); int main(int argc, char *argv[]) { char *pszTeamFileName = NULL; // Process the command switches processCommandSwitches(argc, argv, &pszTeamFileName); // open the Team stream data file if (pszTeamFileName == NULL) exitError(ERR_MISSING_SWITCH, "-t"); pFileTeam = fopen(pszTeamFileName, "r"); if (pFileTeam == NULL) exitError(ERR_TEAM_FILENAME, pszTeamFileName); // get the Teams Data getTeams(); fclose(pFileTeam); printf(" "); // included so that you can put a breakpoint on this line return 0; } /****** you need to document and code this function *****/ void getTeams() { } /******************** processCommandSwitches ***************************** void processCommandSwitches(int argc, char *argv[], char **ppszTeamFileName) Purpose: Checks the syntax of command line arguments and returns the filenames. If any switches are unknown, it exits with an error. Parameters: I int argc Count of command line arguments I char *argv[] Array of command line arguments O char **ppszTeamFileName Team file name Notes: If a -? switch is passed, the usage is printed and the program exits with USAGE_ONLY. If a syntax error is encountered (e.g., unknown switch), the program prints a message to stderr and exits with ERR_COMMAND_LINE_SYNTAX. **************************************************************************/ void processCommandSwitches(int argc, char *argv[], char **ppszTeamFileName) { int i; // Examine each command argument (except argument 0 which is the executable name) for (i = 1; i = argc) exitUsage(i, ERR_MISSING_ARGUMENT, argv[i - 1]); else *ppszTeamFileName = argv[i]; break; case '?': exitUsage(USAGE_ONLY, "", ""); break; default: exitUsage(i, ERR_EXPECTED_SWITCH, argv[i]); } } } /******************** exitError ***************************** void exitError(char *pszMessage, char *pszDiagnosticInfo) Purpose: Prints an error message and diagnostic to stderr. Exits with ERROR_PROCESSING. Parameters: I char *pszMessage error message to print I char *pszDiagnosticInfo supplemental diagnostic information Notes: This routine causes the program to exit. **************************************************************************/ void exitError(char *pszMessage, char *pszDiagnosticInfo) { fprintf(stderr, "Error: %s %s " , pszMessage , pszDiagnosticInfo); exit(ERROR_PROCESSING); } /******************** exitUsage ***************************** void exitUsage(int iArg, char *pszMessage, char *pszDiagnosticInfo) Purpose: If this is an argument error (iArg >= 0), it prints a formatted message showing which argument was in error, the specified message, and supplemental diagnostic information. It also shows the usage. It exits with ERR_COMMAND_LINE_SYNTAX. If this is just asking for usage (iArg will be -1), the usage is shown. It exits with USAGE_ONLY. Parameters: I int iArg command argument subscript I char *pszMessage error message to print I char *pszDiagnosticInfo supplemental diagnostic information Notes: This routine causes the program to exit. **************************************************************************/ void exitUsage(int iArg, char *pszMessage, char *pszDiagnosticInfo) { if (iArg >= 0) fprintf(stderr, "Error: bad argument #%d. %s %s " , iArg , pszMessage , pszDiagnosticInfo); fprintf(stderr, "p1 -t TeamFileName "); if (iArg >= 0) exit(-1); else exit(-2); } 
Assignment #1 : Formatted I/O (20 points) program reads team data to Input Stream input file which contains many teams. There are two different kinds of lines of data for each team - Team Identification Information: e One line per tean (separated by spaces) 6s lf lf - Team Contact Infornation: Q One line per tean (separated by commas) 12s 13s 20s Q. eh .es contain spaces; therefore, you cannot simply use x13s. For szEullsane, you will have to use a bracket format code using %[^,]. The next two values are also terminated by e For szcontactiamc, it contains spaces and is terminated by a new line character. You will have to use a bracket format code using %[Nn] ket format code Files provided 51713p1.h include file which you must use plabs123.5: program file which you must rename using your abc123 id and modify with your changes it will be easier for the grader if your file names that you submit to BlackBoard include your abc123 id piTeam.txt- this data file is used by your program for the output that you will upload into BlackBoard Multiple additional data files to check your error handling, but you don't need to turn in the output for these plTeamBad1.txt piTeamBad2.txt Process While not at EOF, read a data line containing a team's identification information For each of those teams Read a data line containing the contact information Print all the team information Assignment #1 : Formatted I/O (20 points) program reads team data to Input Stream input file which contains many teams. There are two different kinds of lines of data for each team - Team Identification Information: e One line per tean (separated by spaces) 6s lf lf - Team Contact Infornation: Q One line per tean (separated by commas) 12s 13s 20s Q. eh .es contain spaces; therefore, you cannot simply use x13s. For szEullsane, you will have to use a bracket format code using %[^,]. The next two values are also terminated by e For szcontactiamc, it contains spaces and is terminated by a new line character. You will have to use a bracket format code using %[Nn] ket format code Files provided 51713p1.h include file which you must use plabs123.5: program file which you must rename using your abc123 id and modify with your changes it will be easier for the grader if your file names that you submit to BlackBoard include your abc123 id piTeam.txt- this data file is used by your program for the output that you will upload into BlackBoard Multiple additional data files to check your error handling, but you don't need to turn in the output for these plTeamBad1.txt piTeamBad2.txt Process While not at EOF, read a data line containing a team's identification information For each of those teams Read a data line containing the contact information Print all the team information

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions