Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct node *head = NULL;
- struct node *current = NULL;
- //structure for the linked list
- typedef struct node
- {
- int data;
- struct node * next;
- }NODE_T;
- void insertStates(char data)
- {
- struct node *connect = (struct node*)malloc(sizeof(struct node));
- connect->data = data;
- connect->next = head;
- head = connect;
- }
- void viewList()
- {
- struct node *pointer;
- printf("n[head] =>");
- while(pointer != NULL)
- {
- printf("%c =>", pointer->data);
- pointer = pointer->next;
- }
- printf(" [null]n");
- };
- int main ()
- {
- int answerStepOne;
- char answerStepTwo;
- char userContinue;
- int i;
- int statesTot;
- printf("***Pick an option.*** n1. Create a new DFA. n2. Load DFA from file.");
- scanf("%d", &answerStepOne);
- if (answerStepOne == 1)
- {
- //Create new DFA
- printf("Enter single alphabetical states excluding 'z'. (Max states 25)(z to quit)n");
- i=1;
- while(answerStepTwo != 'z')
- {
- printf("Enter State[%d]: ",i);
- scanf("%s", &answerStepTwo);
- if(answerStepTwo == 'z')
- {
- break;
- }
- else
- {
- printf("Should have been insertedn");
- insertStates(answerStepTwo);
- i++;
- }
- }
- }
- if(answerStepOne == 2)
- {
- //Load DFA from file
- }
- viewList();
- system ("PAUSE");
- return 0;
Add Comment
Please, Sign In to add comment