Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Rabindra Yadav 1001733634
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include "DrawTool.h"
- int main (void)
- {
- char array [Max_Size][Max_Size] = {};
- int test = 1;
- int user_size, i, token2, token3, token4, horizontal_limit, vertical_limit;
- char input[Max_Size] = {};
- char *location = NULL, *token1_Ptr = NULL, *token2_Ptr = NULL, *token3_Ptr = NULL, *token4_Ptr = NULL, *token5_Ptr = NULL;
- char token1 = '0', token5 = '0', try;
- initializeMap(array, &user_size);
- printInstructions();
- while (input[0] != 'q' && input[0] != 'Q')
- {
- printf("\n");
- printMap(array, &user_size);
- printf("Enter draw command (enter Q to quit) ");
- location = fgets(input, Max_Size - 1, stdin);
- if (input[0] != 'q' && input[0] != 'Q')
- {
- token1_Ptr = strtok(input, "(,)");
- token2_Ptr = strtok(NULL, "(,)");
- token3_Ptr = strtok(NULL, "(,)");
- token4_Ptr = strtok(NULL, "(,)");
- token5_Ptr = strtok(NULL, "(,)");
- token1 = *token1_Ptr, token5 = *token5_Ptr;
- token2 = atoi(token2_Ptr);
- token3 = atoi(token3_Ptr);
- token4 = atoi(token4_Ptr);
- if (token5 == '0' || token5 == '\0')
- {
- token5 = 'X';
- }
- if (token2 < 0 || token2 >= user_size)
- {
- printf("That draw command is out of range\n\n");
- test = 0;
- }
- else if (token3 < 0 || token3 >= user_size)
- {
- printf("That draw command is out of range\n\n");
- test = 0;
- }
- else if (token1 != 'P' && token1 != 'p')
- {
- if (token4 < 0 || token4 >= user_size)
- {
- printf("That draw command is out of range\n\n");
- test = 0;
- }
- else if (token1 == 'H' || token1 == 'h')
- {
- horizontal_limit = user_size - token3;
- if (token4 > horizontal_limit)
- {
- printf("That draw command is out of range\n\n");
- test = 0;
- }
- }
- else if (token1 == 'V' || token1 == 'v')
- {
- vertical_limit = user_size - token2;
- if (token4 > vertical_limit)
- {
- printf("That draw command is out of range\n\n");
- test = 0;
- }
- }
- }
- if (test == 1)
- {
- if (token1 == 'P' || token1 == 'p')
- {
- *(*(array + token2) + token3) = token5;
- }
- else if (token1 == 'V' || token1 == 'v')
- {
- drawLines(array, token2, token3, token1, token4, token5);
- }
- else if (token1 == 'H' || token1 == 'h')
- {
- drawLines(array, token2, token3, token1, token4, token5);
- }
- else
- {
- printf("That draw command is unkown");
- }
- }
- }
- }
- printf("\n\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement