Saving Changes to Remote before restart
++ PA02_Main +- PA02_Main.c +- StateUtilities.c +- outDebug
This commit is contained in:
parent
81a7297581
commit
9eed1d98d3
4 changed files with 30 additions and 9 deletions
|
|
@ -173,6 +173,9 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
|
|||
// iterate through array to size, check if zero.
|
||||
if(size != 0)
|
||||
{
|
||||
printEndline();
|
||||
printString(subTitle);
|
||||
printEndline();
|
||||
// create a table
|
||||
// print PIPE character
|
||||
printCharacter(PIPE);
|
||||
|
|
@ -223,7 +226,7 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
|
|||
printCharacter(PIPE);
|
||||
// print new line
|
||||
printEndline();
|
||||
for(countStates = 0; countStates < size; countStates++)
|
||||
for(countStates = 0; countStates <= size; countStates++)
|
||||
{
|
||||
// use the constants to format the table
|
||||
// print PIPE character
|
||||
|
|
@ -248,6 +251,7 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
|
|||
printCharacter(PIPE);
|
||||
// print majority justified center, also requires some math trickery to make work
|
||||
printCharacters((MAJORITY_BLOCK_SIZE - 1) / 2, SPACE);
|
||||
printCharacter(SPACE);
|
||||
printCharacter(array[countStates].majority);
|
||||
printCharacters((MAJORITY_BLOCK_SIZE - 1) / 2, SPACE);
|
||||
// print PIPE character
|
||||
|
|
@ -277,11 +281,16 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
|
|||
printCharacters(MAJORITY_BLOCK_SIZE, DASH);
|
||||
// print PIPE character
|
||||
printCharacter(PIPE);
|
||||
/* testing
|
||||
*/
|
||||
printf("Iteration: %d", countStates);
|
||||
// print endline
|
||||
printEndline();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//print out "Data no found - Display aborted".
|
||||
//print out "Data not found - Display aborted".
|
||||
printString("Data not found - Display aborted");
|
||||
printEndline();
|
||||
}
|
||||
|
|
@ -430,6 +439,8 @@ void showTitle()
|
|||
{
|
||||
// use console io utilities to display the string
|
||||
printString("Data Management with N-Squared Sorting");
|
||||
// print endline
|
||||
printEndline();
|
||||
// use console io utilities to display 38 '='
|
||||
printCharacters(38, '=');
|
||||
// print an endline
|
||||
|
|
@ -476,28 +487,39 @@ Dependencies: as needed
|
|||
int uploadStateData( StateDataType *StateDataArray,
|
||||
int capacity, const char *fileName )
|
||||
{
|
||||
//printf("\nUploading Data?\n");
|
||||
// setup a counter and other variables
|
||||
int stateCount = 0;
|
||||
StateDataType *stateUpload;
|
||||
bool fileOpenCheck;
|
||||
char *currentString;
|
||||
char currentString[STD_STR_LEN];
|
||||
int populationUpload;
|
||||
double growthUpload;
|
||||
char majorityUpload;
|
||||
// initialize the stateUpload with empty data
|
||||
setEmptyElementData(stateUpload);
|
||||
setEmptyElementData(&stateUpload);
|
||||
// open file
|
||||
fileOpenCheck = openInputFile(fileName);
|
||||
//printf("\nOPENS FILE\n");
|
||||
if(fileOpenCheck)
|
||||
{
|
||||
//printf("\nCHECKED FILE\n");
|
||||
// read in the four strings/starting line (use readStringToLineEndFromFile)
|
||||
readStringToLineEndFromFile(currentString);
|
||||
// readStringToDelimiterFromFile(COMMA, currentString);
|
||||
// readStringToDelimiterFromFile(COMMA, currentString);
|
||||
// readStringToDelimiterFromFile(COMMA, currentString);
|
||||
// readStringToDelimiterFromFile(COMMA, currentString);
|
||||
while(!checkForEndOfInputFile())
|
||||
{
|
||||
//printf("\nIN WHILE\n");
|
||||
// repeat these steps: (use readStringToDelimiterFromFile)
|
||||
// read in the state name, store
|
||||
//printf("\nReadingString\n");
|
||||
readStringToDelimiterFromFile(COMMA, currentString);
|
||||
//printf("\nReadString\n");
|
||||
//printf("\nCopy String\n");
|
||||
strcpy(stateUpload->name, currentString);
|
||||
//printf("\nCopied String\n");
|
||||
// read in the population, store (cast from string to int)
|
||||
readStringToDelimiterFromFile(COMMA, currentString);
|
||||
// find a way to cast string to int, sscanf might work best.
|
||||
|
|
@ -507,7 +529,7 @@ int uploadStateData( StateDataType *StateDataArray,
|
|||
readStringToDelimiterFromFile(COMMA, currentString);
|
||||
// find a way to cast string to double, using sscanf.
|
||||
sscanf(currentString, "%lf", &growthUpload);
|
||||
stateUpload->growth = growthUpload;
|
||||
stateUpload->growth = growthUpload * 100;
|
||||
// read in the majority, store
|
||||
readStringToDelimiterFromFile(COMMA, currentString);
|
||||
// get the first character of currentString
|
||||
|
|
@ -515,8 +537,6 @@ int uploadStateData( StateDataType *StateDataArray,
|
|||
stateUpload->majority = majorityUpload;
|
||||
// use the addElementFromData function to add the data to array
|
||||
addElementFromData(StateDataArray, &stateCount, capacity, stateUpload->name, stateUpload->population, stateUpload->growth, stateUpload->majority);
|
||||
// increment counter
|
||||
stateCount = stateCount + 1;
|
||||
// do until end of the file is reached.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue