I'm working on a program which requires me to read in a file of input and organize it by calling a few functions. The first function I'm writing breaks up the input and assigns it to the appropriate array. For some reason what I keep getting back is random values. Any help would be appreciated here is my code and directions given to us if needed. Thank You in advance.
http://www.cs.niu.edu/~abyrnes/csci240/pgms/240pgm10.htm
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
void dissectCustLine( char *, char *, char *, char *, char *, char * );
int main()
{
ifstream inFile;
char input[80];
char name[16];
char addr[16];
char telephone[16];
char carinfo[16];
char payment[16];
inFile.open( "custfile.txt" );
if ( inFile.fail() )
{
cout << "input file did not open";
exit(0);
}
inFile.getline( input, 80 );
while ( inFile )
{
dissectCustLine( &input[80], &name[16], &addr[16], &telephone[16], &carinfo[16], &payment[16] );
cout << name << endl;
inFile.getline( input, 80 );
}
system ("pause");
return 0;
}
/*********************************************************/
void dissectCustLine ( char *i, char *n, char *a, char *t, char *c, char *p )
{
n = strncpy(n, i, 15);
*(n+15) = '\0';
}