hi, i have this assignment to complete but i'm a beginner in c++. i would really appreciate some form of advice/direction to how i could tackle this problem.
the basic objective of this assignment is to Develop further understanding of data structures used in programming;
aims-
1:Create a project and use the main.cpp, unlimited.h, and stringfileread.cpp files in order to build a suitable executable. Test the executable at the command line by using the data files supplied FuelEconomy_short.
// main.cpp : Defines the entry point for the console application.
//
// A program to bring in binary data from a file and assign that data to an
// array for the purpose of program development.
//
// Usage: unlimited 'file'.txt 'file'.bin
//
#include "unlimited.h"
int main(int argc, char* argv[])
{
if(argc == 1)
{
cout << "Usage: " << argv[0] << "<data file>" << endl;
exit(0);
}
if(argc > 2)
{
cout << "Too many input parameters" << endl;
cout << "Usage: " << argv[0] << " <textfile> <data file>" << endl;
exit(0);
}
// argc[2] is for the binarray array
//binfileread(argv[1]);
// argc[2] is for the chararray array
stringfileread(argv[1]);
// Code to be added here
return 0;
}3 // End of main()
// Function stringfileread
// A function that reads in a text data file
//
// Inputs: pointer to a char
// Outputs: none
//
#include "unlimited.h"
CharArrayPtr cmemblock;
bool cmemallocated;
void stringfileread(char *stringfile)
{
ifstream textarray(stringfile, ios::in|ios::ate);
if(textarray.is_open())
{
int filesize = textarray.tellg();
cout << "Text File size is: " << filesize << endl;
int numberofvalues = filesize / sizeof(char);
cout << "The number of values from the text file is: " << numberofvalues << endl;
cmemblock = newchar [filesize];
cmemallocated = true;
textarray.seekg (0, ios::beg);
textarray.read(cmemblock, filesize);
for(int i = 0; i < numberofvalues ; i++)
{
cout << cmemblock[i];
}
textarray.close();
cout << endl;
cout << "The complete text file content is in memory" << endl;
cout << endl;
// For billbryson.txt, Fs = 8kHz and a 'dit' is about 75ms in duration
// A'dah' will be three times longer than a 'dit'
// Choosing a 10ms window (80 samples) should give enough resolution
//
// ... Add your Code here .....
//
}
else
{
cout << "Unable to open file";
}
if(cmemallocated)
{
free(cmemblock);
}
} // End of stringfileread()
FuelEconomy_short data text file contains this type of data (literary thousands of these.)
am i right on the right path believing that i have to write some form of input/output file stream, namely "output" as input already exists in the stringfileread function. or am i completely wrong.