how will it work? Please help :)?
environment canada issues : /************************************************************************************************
Program: Lab 5
Author: SAHIL SHAH
Date: Dec.1, 2009
Reads text data from Environment Canada and extracts temperature data to display it on the screen.
************************************************************************************************/
//************************************************************************************************
// Include Statements
#include
#include
using namespace std;
//************************************************************************************************
// Preprocessor Define Directives
#define INPUT_FILE_NAME “33 eng-hourly-11011988-11301988.csv”
#define ARRAY_SIZE
//************************************************************************************************
// Function Prototypes
void ClearArray (char achArray[], int nSize);
int main()
{
charachFileText[ARRAY_SIZE]= {0};
charachFindString[ARRAY_SIZE]= {0};
charchTemp[2]= {0xc2,0×00};
intnLine= 0;
ifstreamm_ifsInputFile;
intnFieldCount;
inttemp= 0;
cout << “nBased on Environment Canada data.n”;
strcat_s (achFindString, “Temp (“);//construct comparison string
strcat_s (achFindString,chTemp);
strcat_s (achFindString,”°C)”");
m_ifsInputFile.open(INPUT_FILE_NAME);//open file
if (!m_ifsInputFile)//error handler
{
cout << “Unable to open file ” << INPUT_FILE_NAME;
cout << “nReturning: ” << EXIT_FAILURE;
return EXIT_FAILURE;//value defined in stdlib.h
}
//parse until Temperature Column Heading is found…
while (!m_ifsInputFile.eof() && (strcmp(achFileText, achFindString) != 0) )
{//read text file until EOF or Column Title is found
m_ifsInputFile.getline(achFileText, ARRAY_SIZE,’,');//get a field from the array
m_ifsInputFile.ignore(1);//clear the new line char from the stream
}
ClearArray(achFileText,ARRAY_SIZE);//clear the array for easy debugging
if (strcmp(achFileText, achFindString) == 0)//display column heading
cout << “n” << “Temp (C)” << “n”;
m_ifsInputFile.getline(achFileText, ARRAY_SIZE);//move file pointer to the start of the next line
//by reading the entire first line
???//clear the new line char from the stream buffer
nFieldCount = 0;//initialize field counter to zero
ClearArray(achFileText,ARRAY_SIZE);//clear the array to make debugging easy
while (!m_ifsInputFile.eof())//repeat this loop until end of file
{
???//get a field from the array
???//clear the new line char from the stream
nFieldCount++;//increment the field count
???//when the sixth field is enountered…
???//display the value of this field
???//at the 23rd field…
{
???//use the new line char as delimiter instead of comma
nFieldCount = 0;//set the field count back to zero
}
ClearArray(achFileText,ARRAY_SIZE);//clear the array to make debugging easy
}
return EXIT_SUCCESS;//value defined in stdlib.h
}
//************************************************************************************************
// Function: ClearArray
// Parameters:
//- A character array that is to be cleared, which is passed by reference
//- An integer, which is the size of the array (number of char elements)
// Returns: Nothing.
//************************************************************************************************
void ClearArray (char achArray[], int nSize)
{
intnIndex;//local variable used in for loop
for (nIndex = 0; nIndex < nSize; nIndex++)//access each element in the array and…
achArray[nIndex] = 0;//set it to zero
}
The answer about: how will it work? Please help
?
Answer by thekillerkat
This code is incomplete..
But it looks like it’ll read data from a file. This file should contain data in CSV(comma seperated value) format..
You read the data, do the conversion and put the result..
Not rocket science, can very easily be coded by a newbie ..
KK
Tags: display, extracts, Statements, temperature, Work
Related how will it work? Please help :)? Post :
Other how will it work? Please help :)? Post :
- How do I find and see a psychiatrist with United Health Care Choice Plus?
- gas engine cars and canada?
- How much for a Budget Home?
- What can you do for fun on a low/ non-existent budget?
- Can anyone help me rework a sentence of an objective essay for a Harvard medical program application?
Add a Comment Trackback
