Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "headers.h"
- int main(void) {
- struct sentence *firstSentence = NULL;
- struct sentence *currSentence = NULL;
- struct sentence *prevSentence = NULL;
- int keepGathering = 1;
- int sentenceCount = 1;
- for (int i = 0; i < keepGathering; i++) {
- char *read = calloc(1000, sizeof(char));
- read = gatherInput("Enter some text or enter nothing to get print and begin search");
- fflush(stdin);
- if (read[0] == NULL) {
- keepGathering = 0;
- }
- else {
- keepGathering++;
- currSentence = processInput(read,sentenceCount);
- if (sentenceCount == 1) {
- firstSentence = currSentence;
- }
- if (prevSentence != NULL) {
- prevSentence->nextSent = currSentence;
- }
- prevSentence = currSentence;
- sentenceCount++;
- }
- }
- printOut(firstSentence);
- int keepSearching = 1;
- char *searchTerm = NULL;
- searchTerm = calloc(1000, sizeof(char));
- for (int i = 0; i < keepSearching; i++) {
- searchTerm = gatherInput("Enter a search term\n");
- fflush(stdin);
- if (searchTerm[0] == NULL) {
- keepSearching = 0;
- }
- else {
- keepSearching++;
- searchFunction(firstSentence, searchTerm);
- }
- }
- printf("finished searching, Switching to line removal\n");
- fflush(stdout);
- // int *lineNumber = NULL;
- // lineNumber = gatherNum("Please enter line number to remove\n");
- // removeLine(lineNumber, firstSentence, sentenceCount);
- int keepRemoving = 1;
- int *lineNumber = NULL;
- lineNumber = calloc(1000, sizeof(int));
- for (int i = 0; i < keepRemoving; i++) {
- if (sentenceCount == 0) {
- printf("all text removed, program closing\n");
- fflush(stdout);
- break;
- }
- lineNumber = gatherNum("Enter line number to remove\n");
- fflush(stdin);
- if (*lineNumber == 0 || *lineNumber == NULL) {
- printf("removal finished\n");
- fflush(stdout);
- break;
- }
- if (sentenceCount == 0) {
- printf("finished removing, Ending Program\n");
- fflush(stdout);
- break;
- }
- if (*lineNumber != NULL && sentenceCount > 0) {
- keepRemoving++;
- if (sentenceCount == 0) {
- printf("finished removing, Ending Program\n");
- fflush(stdout);
- break;
- }
- if (*lineNumber == 1) {
- if (sentenceCount != 1){
- firstSentence = firstSentence->nextSent;
- sentenceCount--;
- removeLine(lineNumber, firstSentence, sentenceCount);
- } else {
- break;
- }
- }
- else {
- removeLine(lineNumber, firstSentence, sentenceCount);
- sentenceCount--;
- }
- }
- }
- printf("finished removing, Ending Program\n");
- fflush(stdout);
- return 0;
- }
Add Comment
Please, Sign In to add comment