// MajorProJectMB.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include<cstring>
#include<fstream>
#include<iostream>
#include<string>
#include <iomanip>
#include <cstdlib>
#include <string>
using std::ifstream;
using std::ofstream;
using std::ios;
using namespace std;
struct project
{
char comma[10];
double NumFields[10];
string lastfieldName;
string firstfieldName;
double Toltal = 0;
};
void getfile(project Fields[8]);
void bubbleSort(project Fields[8], double NumFields[10]);
void swap(double *xp, double *yp);
void outputfile(project Fields[8]);
int main()
{
project Fields[8];
getfile(Fields);
outputfile(Fields);
system("PAUSE");
return 0;
}
void getfile(project Fields[8])
{
ifstream inStream;
ofstream outStream;
int count = 0;
inStream.open("Project-Input.dat");
if (inStream.fail())
{
cerr << "File not located!";
system("PAUSE");
exit(1);//ifstream Fieldin;;
}
else
{
while (inStream.good())
{
for (int loop = 0; loop < 8; loop++)
{
inStream >> Fields[loop].lastfieldName >> Fields[loop].firstfieldName >> Fields[loop].comma[0] >> Fields[loop].NumFields[0] >> Fields[loop].comma[1] >> Fields[loop].NumFields[1] >> Fields[loop].comma[2] >> Fields[loop].NumFields[2] >> Fields[loop].comma[3] >> Fields[loop].NumFields[3] >> Fields[loop].comma[4] >> Fields[loop].NumFields[4] >> Fields[loop].comma[5] >> Fields[loop].NumFields[5] >> Fields[loop].comma[6] >> Fields[loop].NumFields[6] >> Fields[loop].comma[7] >> Fields[loop].NumFields[7] >> Fields[loop].comma[8] >> Fields[loop].NumFields[8] >> Fields[loop].comma[9] >> Fields[loop].NumFields[9];
}
}
/*for (int loop = 0; loop < 8; loop++)
{
for (int count=0; count<10; count++)
{
Fields[loop].Toltal = Fields[loop].Toltal + Fields[loop].NumFields[count];
}
}*/
//inStream.close();
//outStream.close();
//bubbleSort(Fields, NumFields);
//outputfile(completeField);
}
}
void outputfile(project Fields[8])
{
ifstream inStream;
ofstream outStream;
string Oline;
int loop = 0;
outStream.open("Project-Output.csv");
if (outStream.fail())
{
cerr << "File not located!";
system("PAUSE");
exit(1);//ifstream Fieldin;
}
else
{
while (loop<8)
{
outStream << Fields[loop].lastfieldName << " " << Fields[loop].firstfieldName << Fields[loop].comma[0] << Fields[loop].NumFields[0] << Fields[loop].comma[1] << Fields[loop].NumFields[1] << Fields[loop].comma[2] << Fields[loop].NumFields[2] << Fields[loop].comma[3] << Fields[loop].NumFields[3] << Fields[loop].comma[4] << Fields[loop].NumFields[4] << Fields[loop].comma[5] << Fields[loop].NumFields[5] << Fields[loop].comma[6] << Fields[loop].NumFields[6] << Fields[loop].comma[7] << Fields[loop].NumFields[7] << Fields[loop].comma[8] << Fields[loop].NumFields[8] << Fields[loop].comma[9] << Fields[loop].NumFields[9] << endl;
loop++;
}
inStream.close();
outStream.close();
}
}
so it iterates through the first line and prints it to the file but then i get this:
Doe Suzie,100,95,85,100,70,65,100,95,70,96S-9.25596e+61Ì-9.25596e+61Ì-9.25596e+61Ì-9.25596e+61Ì-9.25596e+61Ì-9.25596e+61Ì-9.25596e+61Ì-9.25596e+61Ì-9.25596e+61Ì-9.25596e+61
and the garbage continues for the rest of the 8 lines, im using c++ what am i doing wrong?