Question: MY IMPLEMENTATION OF THE CODE LISTED BELOW BUT It's NOT OUTPUTTING CORRECTLY ITS SUPPOSED TO OUTPUT THIS BY READING FROM A FILE CALLED CONFIG.DAT AS

 MY IMPLEMENTATION OF THE CODE LISTED BELOW BUT It's NOT OUTPUTTING

CORRECTLY ITS SUPPOSED TO OUTPUT THIS BY READING FROM A FILE CALLED

MY IMPLEMENTATION OF THE CODE LISTED BELOW BUT It's NOT OUTPUTTING CORRECTLY

ITS SUPPOSED TO OUTPUT THIS BY READING FROM A FILE CALLED CONFIG.DAT AS STATED BY THE GUIDLINe:

int 12 1 9 1 8 6 3 4 3 9 7 0 float 2 5.30 56.31 char 6 h a y K o z float 3 5.55 22.41 10.11

BUT FOR SOME REASON THIS IS MY OUTPUT

CONFIG.DAT AS STATED BY THE GUIDLINe: int 12 1 9 1 8

//////HERE IS MY CODE/////////////////////

//DataStorage.cpp//////////////////////////////// #include #include #include #include #include

using namespace std;

void readFile( char* fileName) { ofstream file; file.open("reverse.dat", std::ios_base::app); ifstream inFile (fileName); // inFile.open("config.dat"); // exit program if ifstream could not open file if (!inFile) { cout

try{ while (!inFile.eof()) { char dataType[10] = {"\0"}; int dSize=0; inFile >> dataType; inFile >> dSize; if(inFile.eof()) break; file

if (strcmp(dataType, "int") == 0) { int *iPtr = new int[dSize+1]; iPtr[0] = dSize; for (int i = 1; i > iPtr[i]; } for (int i=dSize ; i > 0 ; i--) { file > fPtr[i]; } for (int i=dSize ;i>0 ; i--) { file > cPtr[i]; } for (int i=dSize ;i>0 ; i--) { file

int main(int argc, char *argv[]) { char* fileName = "/Users/fatema/Desktop/config.dat" ; readFile(fileName); // return 0; system("pause");

}

////config.dat///////////////////

int 12 1 9 1 8 6 3 4 3 9 7 0 float 2 5.30 56.31 char 6 h a y K o z float 3 5.55 22.41 10.11

////reverse.dat///

0 7 9 3 4 3 6 8 1 9 1 12 int 56.31 5.30 2 float z o K y a h 6 char 10.11 22.41 5.55 3 float

COEN 244 (Winter 2017) Assignment 4: lo Deadline: Monday April 10 23:59pm, individual assignment Note: The assignment must be submitted on Moodle. Submission format: Create only ONE zip file (.gz, tar, .zip are acceptable. rar file is NOT acceptable) that contains all the header files, cpp files and test files. The name of the file must follow the template below: student id A4.zip; student id A4.tar or student id A4.gz. Submissions do not follow about format should be responsible for the consequences. Problem: Write a function that reads from a sequential file and writes to another sequential file. The file path and name are passed through arguments of the main function. int main int argc, char *argv0) For example, the file name is config dat, and the path is the current directory The schema of the file is shown below Field I Field II Field III int 12 1 1 81 6 3 4 3 9 70 Record I float 2 Record II 5.30 56.31 Record char (6 h a y K o z Record IV float 3 5.55 22.41 10.11

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!