#include #include #include #include using namespace std; void dissectCustLine(char *a[], char *b[], char *c[], char *d[], char *e[], char *f[]); void fixName(char *a[]); //void fixAddress(char *a[]); void fixPhone(char *a[]); //void fixCarInfo(char *a[]); int main () { char entireInput [80], custName [16], custAdd [19], custPhone [13], carInfo [23], carPay [9], editInput [80]; int i = 0; ifstream inFile; inFile.open("custfile.txt" ); if ( inFile.fail() ) { cout << "input file did not open"; exit(0); } ofstream outFile; outFile.open("newfile.txt" ); if ( inFile.fail() ) { cout << "input file did not open"; exit(0); } dissectCustLine(&entireInput, &custName, &custAdd, &custPhone, &carInfo, &carPay); fixPhone(&entireInput); /*while(!inFile.eof()) { //all functions go in here i++; } */ inFile.close(); return 0; } /********************************************************************************** Function: dissectCustLine Use: This function should separate the entire line of input into five individual fields. Arguments: 1. entireInput 2. custName 3. custAdd 4. custPhone 5. carInfo 6. carPay Returns: nothing **********************************************************************************/ void dissectCustLine(char *entireInput, char *custName, char *custAdd, char *custPhone, char *carInfo, char *carPay) { strncpy(custName, entireInput, 15); *(custName + 15) = '\0'; strncpy(custAdd, entireInput + 16, 18); *(custName + 18) = '\0'; strncpy(custPhone, entireInput + 34, 12); *(custName + 12) = '\0'; strncpy(carInfo, entireInput + 46, 22); *(custName + 22) = '\0'; strcpy(carPay, entireInput + 68); } /********************************************************************************** Function: fixName Use: This function will change the customer name to the format firstname lastname. Arguments: 1. Returns: nothing **********************************************************************************/ void fixName(char *custName) { char *spacePtr; *custName = toupper(*custName); spacePtr = strchr(custName, ' '); spacePtr ++; *spacePtr = toupper (*spacePtr); for(ptr = custName + 1; ptr < spacePtr; ptr++) *ptr = tolower (*ptr); fore(ptr = spacePtr + 1; *ptr != '\0'; ptr++) *ptr = tolower (*ptr); } /********************************************************************************** Function: fixAddress Use: This function should edit the street name and suffix by making sure that each begins with an upper case letter, and that the rest are lower case. Arguments: 1. Returns: nothing **********************************************************************************/ /*void fixAddress( char *) { } */ /********************************************************************************** Function: fixPhone Use: This function should edit the phone number string by inserting two hyphens into the appropriate spots. Arguments: 1. Returns: nothing **********************************************************************************/ void fixPhone( char *custPhone) { char temp[13]; strncpy(temp, custPhone + 34, 3); *(temp + 3) = '-'; strncpy(temp, custPhone + 38, 3); *(temp + 7) = '-'; strncpy(temp, custPhone + 42, 4); *(temp + 12) = '-'; strcpy(custPhone, temp); } /********************************************************************************** Function: fixCarInfo Use: This function should edit the car information string by making sure that the car make field is all upper case letters, the first letter of car model is an upper case letter, and that the remaining letters of car model are all lower case. Arguments: 1. Returns: nothing **********************************************************************************/ /*void fixCarInfo( char *) { } */