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
BIN
PA02-0913/PA02_Main
Executable file
BIN
PA02-0913/PA02_Main
Executable file
Binary file not shown.
|
|
@ -51,7 +51,7 @@ int main()
|
||||||
|
|
||||||
// display original list
|
// display original list
|
||||||
displayData( wkgArray, wkgNumStates, "Original data after upload" );
|
displayData( wkgArray, wkgNumStates, "Original data after upload" );
|
||||||
|
/*
|
||||||
// find state
|
// find state
|
||||||
printf( "\nFinding state: %s\n", searchData.name );
|
printf( "\nFinding state: %s\n", searchData.name );
|
||||||
findStateByName( &resultData, wkgArray, wkgNumStates, searchData );
|
findStateByName( &resultData, wkgArray, wkgNumStates, searchData );
|
||||||
|
|
@ -96,6 +96,7 @@ int main()
|
||||||
// display insertion-sorted list
|
// display insertion-sorted list
|
||||||
displayData( sortingArray, sortingNumStates,
|
displayData( sortingArray, sortingNumStates,
|
||||||
"Full list sorted by growth using selection sort" );
|
"Full list sorted by growth using selection sort" );
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,9 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
|
||||||
// iterate through array to size, check if zero.
|
// iterate through array to size, check if zero.
|
||||||
if(size != 0)
|
if(size != 0)
|
||||||
{
|
{
|
||||||
|
printEndline();
|
||||||
|
printString(subTitle);
|
||||||
|
printEndline();
|
||||||
// create a table
|
// create a table
|
||||||
// print PIPE character
|
// print PIPE character
|
||||||
printCharacter(PIPE);
|
printCharacter(PIPE);
|
||||||
|
|
@ -223,7 +226,7 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
|
||||||
printCharacter(PIPE);
|
printCharacter(PIPE);
|
||||||
// print new line
|
// print new line
|
||||||
printEndline();
|
printEndline();
|
||||||
for(countStates = 0; countStates < size; countStates++)
|
for(countStates = 0; countStates <= size; countStates++)
|
||||||
{
|
{
|
||||||
// use the constants to format the table
|
// use the constants to format the table
|
||||||
// print PIPE character
|
// print PIPE character
|
||||||
|
|
@ -248,6 +251,7 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
|
||||||
printCharacter(PIPE);
|
printCharacter(PIPE);
|
||||||
// print majority justified center, also requires some math trickery to make work
|
// print majority justified center, also requires some math trickery to make work
|
||||||
printCharacters((MAJORITY_BLOCK_SIZE - 1) / 2, SPACE);
|
printCharacters((MAJORITY_BLOCK_SIZE - 1) / 2, SPACE);
|
||||||
|
printCharacter(SPACE);
|
||||||
printCharacter(array[countStates].majority);
|
printCharacter(array[countStates].majority);
|
||||||
printCharacters((MAJORITY_BLOCK_SIZE - 1) / 2, SPACE);
|
printCharacters((MAJORITY_BLOCK_SIZE - 1) / 2, SPACE);
|
||||||
// print PIPE character
|
// print PIPE character
|
||||||
|
|
@ -277,11 +281,16 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
|
||||||
printCharacters(MAJORITY_BLOCK_SIZE, DASH);
|
printCharacters(MAJORITY_BLOCK_SIZE, DASH);
|
||||||
// print PIPE character
|
// print PIPE character
|
||||||
printCharacter(PIPE);
|
printCharacter(PIPE);
|
||||||
|
/* testing
|
||||||
|
*/
|
||||||
|
printf("Iteration: %d", countStates);
|
||||||
|
// print endline
|
||||||
|
printEndline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//print out "Data no found - Display aborted".
|
//print out "Data not found - Display aborted".
|
||||||
printString("Data not found - Display aborted");
|
printString("Data not found - Display aborted");
|
||||||
printEndline();
|
printEndline();
|
||||||
}
|
}
|
||||||
|
|
@ -430,6 +439,8 @@ void showTitle()
|
||||||
{
|
{
|
||||||
// use console io utilities to display the string
|
// use console io utilities to display the string
|
||||||
printString("Data Management with N-Squared Sorting");
|
printString("Data Management with N-Squared Sorting");
|
||||||
|
// print endline
|
||||||
|
printEndline();
|
||||||
// use console io utilities to display 38 '='
|
// use console io utilities to display 38 '='
|
||||||
printCharacters(38, '=');
|
printCharacters(38, '=');
|
||||||
// print an endline
|
// print an endline
|
||||||
|
|
@ -476,28 +487,39 @@ Dependencies: as needed
|
||||||
int uploadStateData( StateDataType *StateDataArray,
|
int uploadStateData( StateDataType *StateDataArray,
|
||||||
int capacity, const char *fileName )
|
int capacity, const char *fileName )
|
||||||
{
|
{
|
||||||
|
//printf("\nUploading Data?\n");
|
||||||
// setup a counter and other variables
|
// setup a counter and other variables
|
||||||
int stateCount = 0;
|
int stateCount = 0;
|
||||||
StateDataType *stateUpload;
|
StateDataType *stateUpload;
|
||||||
bool fileOpenCheck;
|
bool fileOpenCheck;
|
||||||
char *currentString;
|
char currentString[STD_STR_LEN];
|
||||||
int populationUpload;
|
int populationUpload;
|
||||||
double growthUpload;
|
double growthUpload;
|
||||||
char majorityUpload;
|
char majorityUpload;
|
||||||
// initialize the stateUpload with empty data
|
setEmptyElementData(&stateUpload);
|
||||||
setEmptyElementData(stateUpload);
|
|
||||||
// open file
|
// open file
|
||||||
fileOpenCheck = openInputFile(fileName);
|
fileOpenCheck = openInputFile(fileName);
|
||||||
|
//printf("\nOPENS FILE\n");
|
||||||
if(fileOpenCheck)
|
if(fileOpenCheck)
|
||||||
{
|
{
|
||||||
|
//printf("\nCHECKED FILE\n");
|
||||||
// read in the four strings/starting line (use readStringToLineEndFromFile)
|
// read in the four strings/starting line (use readStringToLineEndFromFile)
|
||||||
readStringToLineEndFromFile(currentString);
|
readStringToLineEndFromFile(currentString);
|
||||||
|
// readStringToDelimiterFromFile(COMMA, currentString);
|
||||||
|
// readStringToDelimiterFromFile(COMMA, currentString);
|
||||||
|
// readStringToDelimiterFromFile(COMMA, currentString);
|
||||||
|
// readStringToDelimiterFromFile(COMMA, currentString);
|
||||||
while(!checkForEndOfInputFile())
|
while(!checkForEndOfInputFile())
|
||||||
{
|
{
|
||||||
|
//printf("\nIN WHILE\n");
|
||||||
// repeat these steps: (use readStringToDelimiterFromFile)
|
// repeat these steps: (use readStringToDelimiterFromFile)
|
||||||
// read in the state name, store
|
// read in the state name, store
|
||||||
|
//printf("\nReadingString\n");
|
||||||
readStringToDelimiterFromFile(COMMA, currentString);
|
readStringToDelimiterFromFile(COMMA, currentString);
|
||||||
|
//printf("\nReadString\n");
|
||||||
|
//printf("\nCopy String\n");
|
||||||
strcpy(stateUpload->name, currentString);
|
strcpy(stateUpload->name, currentString);
|
||||||
|
//printf("\nCopied String\n");
|
||||||
// read in the population, store (cast from string to int)
|
// read in the population, store (cast from string to int)
|
||||||
readStringToDelimiterFromFile(COMMA, currentString);
|
readStringToDelimiterFromFile(COMMA, currentString);
|
||||||
// find a way to cast string to int, sscanf might work best.
|
// find a way to cast string to int, sscanf might work best.
|
||||||
|
|
@ -507,7 +529,7 @@ int uploadStateData( StateDataType *StateDataArray,
|
||||||
readStringToDelimiterFromFile(COMMA, currentString);
|
readStringToDelimiterFromFile(COMMA, currentString);
|
||||||
// find a way to cast string to double, using sscanf.
|
// find a way to cast string to double, using sscanf.
|
||||||
sscanf(currentString, "%lf", &growthUpload);
|
sscanf(currentString, "%lf", &growthUpload);
|
||||||
stateUpload->growth = growthUpload;
|
stateUpload->growth = growthUpload * 100;
|
||||||
// read in the majority, store
|
// read in the majority, store
|
||||||
readStringToDelimiterFromFile(COMMA, currentString);
|
readStringToDelimiterFromFile(COMMA, currentString);
|
||||||
// get the first character of currentString
|
// get the first character of currentString
|
||||||
|
|
@ -515,8 +537,6 @@ int uploadStateData( StateDataType *StateDataArray,
|
||||||
stateUpload->majority = majorityUpload;
|
stateUpload->majority = majorityUpload;
|
||||||
// use the addElementFromData function to add the data to array
|
// use the addElementFromData function to add the data to array
|
||||||
addElementFromData(StateDataArray, &stateCount, capacity, stateUpload->name, stateUpload->population, stateUpload->growth, stateUpload->majority);
|
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.
|
// do until end of the file is reached.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue