Hey guys I need to copy multiple string arrays into one array to use to display output. I need to copy the name, addr, telephone, carinfo, payment array to the output array. How would I go about doing that.
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
void dissectCustLine( char *, char *, char *, char *, char *, char * );
void fixName( char * );
void fixAddress( char * );
void fixPhone ( char * );
int main()
{
ifstream inFile;
char input[80];
char name[15];
char addr[18];
char telephone[12];
char carinfo[21];
char payment[16];
char output[80];
inFile.open( "custfile.txt" );
if ( inFile.fail() )
{
cout << "input file did not open";
exit(0);
}
inFile.getline( input, 80 );
while ( inFile )
{
dissectCustLine( input, name, addr, telephone, carinfo, payment );
fixName( name );
fixAddress ( addr );
fixPhone ( telephone );
cout << addr << endl;
inFile.getline( input, 80 );
}
system ("pause");
return 0;
}
/*********************************************************/
void dissectCustLine ( char *i, char *n, char *a, char *t, char *c, char *p )
{
strncpy(n, i, 15);
n[15] = '\0';
strncpy(a, i+15, 18);
a[18] = '\0';
strncpy(t, i+33, 12);
t[12] = '\0';
strncpy(c, i+45, 21);
c[21] = '\0';
strncpy(p, i+67, 8);
p[8] = '\0';
}
/*********************************************************/
void fixName ( char *n )
{
char temp[80];
char *spacePtr;
spacePtr = strchr(n, ',');
if ( spacePtr != 0 )
{
strcpy(temp,spacePtr+1);
strcat(temp, ",");
*spacePtr = '\0';
strcat(temp, n);
strcpy(n, temp);
}
}
/******************************************/
void fixAddress ( char *a )
{
while(*a != NULL)
{
if(isalpha(*a)) break;
a++;
}
*a = toupper(*a);
a++;
while(*a != NULL)
{
*a = tolower(*a);
a++;
}
a++;
}
/********************************************************/
void fixPhone ( char *t)
{
}