Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <float.h>
- #include <limits.h>
- #include <conio.h>
- #include <ctype.h>
- #include <string.h>
- #include <math.h>
- //main()
- //{
- // printf("hello ");
- // printf("world");
- // printf("\n");
- // printf("\f");
- //
- //}
- //main()
- //{
- // float fahr, celcius;
- // int lower, upper, step;
- //
- // lower = 0;
- // upper = 300;
- // step = 20;
- //
- // fahr = lower;
- //
- // printf("Fahrenheit\tCelcius\n");
- // while (fahr <= upper)
- // {
- // celcius = (5.0 / 9.0) * (fahr - 32.0); //5.0 for floating point number arithmetic
- // printf("%10.0f %12.1f\n", fahr, celcius);
- // fahr = fahr + step;
- // }
- // printf("\n\n\n\n\n\n\n\n\n\n\n");
- //}
- //main()
- //{
- // float fahr, celcius;
- // int lower, upper, step;
- //
- // lower = 0;
- // upper = 300;
- // step = 20;
- //
- // celcius = lower;
- //
- // printf("Celcius \tFahrenheit\n");
- // while (celcius <= upper)
- // {
- // fahr = ((9.0 / 5.0) * (celcius)) + 32.0; //5.0 for floating point number arithmetic
- // printf("%7.0f %18.1f\n", celcius, fahr);
- // celcius = celcius + step;
- // }
- // printf("\n\n\n\n\n\n\n\n\n\n\n");
- //}
- //main()
- //{
- // float fahr, celcius;
- // int lower, upper, step;
- //
- // lower = 0;
- // upper = 300;
- // step = 20;
- //
- // celcius = upper;
- //
- // printf("Celcius \tFahrenheit\n");
- // while (celcius >= lower)
- // {
- // fahr = ((9.0 / 5.0) * (celcius)) + 32.0; //5.0 for floating point number arithmetic
- // printf("%7.0f %18.1f\n", celcius, fahr);
- // celcius = celcius - step;
- // }
- // printf("\n\n\n\n\n\n\n\n\n\n\n");
- //}
- //main()
- //{
- // int c;
- // while (c = (getchar() != EOF))
- // {
- // printf("%d\n", c);
- // }
- // printf("%d", c);
- //}
- //#define BUFSIZE 100
- //char buf[BUFSIZE];
- //int bufp = 0;
- //
- //main()
- //{
- // int getch(void);
- // void ungetch(int);
- // int c;
- //
- // Start:
- // while (c = (getch() != EOF))
- // {
- // ungetch(); //c is 1, it returns a 1 to buf.
- // if (c = (getch() != '\n'))
- // {
- // ungetch(c);
- // if (c = (getch() != ' '))
- // {
- // printf("%d\n", c);
- // }
- // else
- // {
- // printf("skipped: <-\n");
- // }
- // }
- // else
- // {
- // printf("skipped: \\n <-\n");
- // }
- // }
- // printf("%d", c);
- // goto Start;
- //}
- //
- //int getch(void)
- //{
- // return (bufp > 0) ? buf[--bufp] : getchar();
- //}
- //void ungetch(int c)
- //{
- // if (bufp >= BUFSIZE) printf("ungetch: too many characters\n");
- // else
- // buf[bufp++] = c;
- //}
- //main()
- //{
- // int c;
- //
- // if (c = (getchar() != EOF))
- // {
- // printf("if loop executed so c was 1 because getchar() was 1.\n");
- // printf("value of getchar(): %d\n\n", c);
- // }
- // else
- // {
- // printf("if loop exited so c was 0 because getchar() was 0.\n");
- // printf("value of getchar(): %d", c);
- // }
- //}
- //main()
- //{
- // int c = EOF;
- // printf("%d\n", c);
- //}
- //main()
- //{
- // int c;
- // int NumberOfNewLines = 0;
- // int NumberOfTabs = 0;
- // int NumberOfSpaces = 0;
- //
- //
- // while ((c = getchar()) != EOF)
- // {
- // if (c == '\n')
- // {
- // NumberOfNewLines++;
- // }
- // else if (c == '\t')
- // {
- // NumberOfTabs++;
- // }
- // else if (c == ' ')
- // {
- // NumberOfSpaces++;
- // }
- // }
- //
- // printf("Number of New Lines: %d\nNumber of Tabs: %d\nNumber of Spaces: %d\n", NumberOfNewLines, NumberOfTabs, NumberOfSpaces);
- //}
- //main()
- //{
- // int c;
- // int OneSpaceRead = 0;
- //
- // while ((c = getchar()) != EOF)
- // {
- // if (c != ' ')
- // {
- // putchar(c);
- // OneSpaceRead = 0;
- // }
- // else if (c == ' ' && OneSpaceRead == 0)
- // {
- // putchar(c);
- // OneSpaceRead = 1;
- // }
- // }
- //}
- //main()
- //{
- // int c;
- //
- // while ((c = getchar()) != EOF)
- // {
- // if (c != '\n' && c != '\b' && c != '\t')
- // putchar(c);
- // else if (c == '\n')
- // {
- // printf("\\n");
- // }
- // else if (c == '\t')
- // {
- // printf("\\t");
- // }
- // else if (c == '\\')
- // {
- // printf("\\");
- // }
- // else if (c == '\b')
- // {
- // printf("backspace");
- // }
- // }
- //}
- //main()
- //{
- // int c;
- // int InAWord = 0;
- //
- // printf("This program prints out every word and spacebar on an individual line.");
- //
- // while ((c = getchar()) != EOF)
- // {
- // if (c != ' ' && c != '\n')
- // {
- // putchar(c);
- // InAWord = 1;
- // }
- // if (c == ' ')
- // {
- // if (InAWord == 1)
- // {
- // printf("\n");
- // putchar(c);
- // printf("\n");
- // InAWord = 0;
- // }
- // else if (InAWord == 0)
- // {
- // putchar(c);
- // printf("\n");
- // }
- // }
- // if (c == '\n')
- // {
- // putchar(c);
- // }
- // }
- //}
- //main()
- //{
- // #define parameter 100
- // int c;
- // int NumberOfLetters[parameter];
- // int NumberOfLettersIndex = 0;
- //
- // int i = 0;
- // int indexForNumberOfLettersArray = 0;
- //
- // for (i = 0; i < parameter; i++)
- // {
- // NumberOfLetters[i] = 0;
- // }
- //
- // while ((c = getchar()) != EOF && c != '\n')
- // {
- // if (c != ' ' && c != '\n')
- // {
- // NumberOfLetters[NumberOfLettersIndex]++;
- // }
- // if (c == ' ')
- // {
- // NumberOfLettersIndex++;
- // NumberOfLetters[NumberOfLettersIndex]++;
- // NumberOfLettersIndex++;
- // }
- // }
- //
- // for (i = 0; i < parameter; i = i + 1)
- // {
- // if ((NumberOfLetters[i]) > 0)
- // {
- // while ((NumberOfLetters[i]) > 0)
- // {
- // printf("*");
- // NumberOfLetters[i]--;
- // }
- // printf("\n");
- // }
- // else if ((NumberOfLetters[i]) == 0)
- // break;
- // }
- //}
- //#define MAXSIZE 100
- //#define IN 1
- //#define OUT 0
- //
- //main()
- //{
- // int c;
- // int MAXLETTERCOUNT = 0;
- // int WORDCOUNT = 0;
- // int i = 0;
- // int j;
- // int Array[MAXSIZE];
- // int State = OUT; //flag for whether in word or not
- // int Max[MAXSIZE];
- //
- // for (i = 0; i < MAXSIZE; i++) //i < MAXSIZE
- // {
- // Array[i] = 0;
- // Max[i] = 1;
- // }
- //
- // i = 0;//
- //
- // while ((c = getchar()) != EOF)
- // {
- // if (isalpha(c)) //isalphanumerical
- // {
- // State = IN;
- // Array[i]++;
- // Max[i]++;
- // if (Array[i] >= MAXLETTERCOUNT)
- // {
- // MAXLETTERCOUNT = Array[i];
- // }
- // }
- // else if (State == IN && (c == ' ' || c == '\t' || c == '\n'))
- // {
- // WORDCOUNT++;
- // i++;
- // State = OUT;
- // }
- // else
- // continue;
- // }
- //
- // for (i = MAXLETTERCOUNT + 1; i > 0; i--)
- // {
- // for (j = 0; j < WORDCOUNT; j++)
- // {
- // if (Max[j] == i)
- // {
- // printf("%5d", Max[j] - 1);
- // }
- // else if (Array[j] == i)
- // {
- // printf(" *");
- // Array[j]--;
- // }
- // else
- // {
- // printf(" ");
- // }
- // }
- // printf("\n");
- // }
- //
- // for (i = 1; i <= WORDCOUNT; i++)
- // printf("%5d", i);
- //
- // printf("\n");
- //}
- //#define MAXSIZE 100
- //#define IN 1
- //#define OUT 0
- //
- //main()
- //{
- // int c;
- // int MAXLETTERCOUNT = 0;
- // int i = 0;
- // int j;
- // int nl = 0;
- // int Array[MAXSIZE];
- // int State = OUT; //flag for whether in word or not
- //
- // for (i = 0; i < MAXSIZE; i++) //i < MAXSIZE
- // {
- // Array[i] = 0;
- // }
- //
- // i = 0;//
- //
- // while ((c = getchar()) != EOF)
- // {
- // if (isalpha(c)) //isalphanumerical
- // {
- // State = IN;
- // nl++;
- // if (nl >= MAXLETTERCOUNT)
- // {
- // MAXLETTERCOUNT = nl;
- // }
- // }
- // else if (State == IN && (c == ' ' || c == '\t' || c == '\n'))
- // {
- // Array[nl]++;
- // nl = 0;
- // State = OUT;
- // }
- // else
- // continue;
- // }
- //
- // for (i = 1; i <= MAXLETTERCOUNT; i++)
- // printf("%5d", Array[i]);
- //
- // printf("\n");
- //
- // for (i = 1; i <= MAXLETTERCOUNT; i++)
- // printf("%5d", i);
- //
- // printf("\n");
- //}
- //double toCelcius(double);
- //
- ////main()
- ////{
- //// int c;
- //// while ((c = getchar()) != EOF)
- //// {
- ////
- //// }
- ////
- ////}
- //
- //main()
- //{
- // int i = 0;
- // while (i <= 212)
- // {
- // printf("%9.4f\n", toCelcius(i));
- // i++;
- // }
- //
- //}
- //
- //double toCelcius(double F)
- //{
- // double C;
- // C = (5.0 / 9.0) * (F - 32);
- // return C;
- //}
- //#define MAXLINE 1000
- //int getline(char line[], int maxline);
- //void copy(char from[], char to[]);
- //
- //main()
- //{
- // int len;
- // int max = 0;
- // char line[MAXLINE];
- // char longest[MAXLINE];
- //
- // while ((len = getline(line, MAXLINE)) > 0)
- // {
- // if (len > max)
- // {
- // max = len;
- // copy(line, longest);
- // }
- // }
- // if (max > 0)
- // printf("%s", longest);
- // return 0;
- //}
- //
- //int getline(char s[], int limit)
- //{
- // int i;
- // int c;
- //
- // for (i = 0; i < limit - 1 && (c = getchar()) != EOF && c != '\n'; i++)
- // {
- // s[i] = c;
- // }
- // if (c == '\n')
- // {
- // s[i] = c;
- // i++;
- // }
- // s[i] = '\0';
- // return i;
- //}
- //
- //void copy(char from[], char to[])
- //{
- // int i = 0;
- // while ((to[i] = from[i]) != '\0')
- // {
- // i++;
- // }
- //}
- //main()
- //{
- // int i = 0;
- // int nc = 0;
- // int limit = 0;
- // int c;
- // char array[MAXLINE];
- // for (limit = 0; limit < 100; limit++)
- // {
- // i = 0;
- // while ((c = getchar()) != EOF && c != '\n' && i < MAXLINE - 1)
- // {
- // array[i] = c;
- // i++;
- // nc++;
- // }
- // array[i] = '\0';
- // //i = 0;
- // printf("%s %d\n", array, nc);
- // nc = 0;
- // }
- //}
- //main()
- //{
- // int i = 0; D
- // int nc = 0; O
- // int limit = 0; E
- // int c; S
- // int array[MAXLINE];
- // while ((c = getchar()) != EOF && c != '\n' && limit < 100) N
- // { O
- // array[i] = c; T
- // i++;
- // nc++; W
- // } O
- // array[i] = '\0'; R
- // i = 0; K
- // printf("%s %d\n", array, nc);
- //}
- //main()
- //{
- // int i = 0;
- // int nc = 0;
- // int limit = 0;
- // int max = 0;
- // int c;
- // char array[MAXLINE];
- // char longest[MAXLINE];
- // for (limit = 0; limit < 100; limit++)
- // {
- // i = 0;
- // while ((c = getchar()) != EOF && c != '\n' && i < MAXLINE - 1)
- // {
- // array[i] = c;
- // i++;
- // nc++;
- // }
- // array[i] = '\0';
- // i = 0;
- // if (nc > max)
- // {
- // max = nc;
- // while ((longest[i] = array[i]) != '\0')
- // i++;
- // }
- // //i = 0;
- // if (c == EOF)
- // printf("%s %d\n", longest, max);
- // nc = 0;
- // }
- //}
- //main()
- //{
- // int i = 0;
- // int nc = 0;
- // int limit = 0;
- // int c;
- // char array[MAXLINE];
- // for (limit = 0; limit < 100; limit++)
- // {
- // i = 0;
- // while ((c = getchar()) != EOF && c != '\n' && i < MAXLINE - 1)
- // {
- // array[i] = c;
- // i++;
- // nc++;
- // }
- // array[i] = '\0';
- // //i = 0;
- // if (nc > 80)
- // printf("%s %d\n", array, nc);
- // nc = 0;
- // }
- //}
- #define YES 1
- #define NO 0
- //main()
- //{
- // int c;
- // char array[MAXLINE];
- // int INALINE = NO;
- // int TRAILING = NO;
- // int i = 0;
- // int index = 0;
- // int limit = 0;
- // int linesskipped = 0;
- // for (limit = 0; limit < 100; limit++)
- // {
- // while ((c = getchar()) != EOF && i < MAXLINE - 1)
- // {
- // if (c != '\n' && c != ' ' && c != '\t')
- // {
- // array[i] = c;
- // INALINE = YES;
- // TRAILING = NO;
- // i++;
- // }
- // if ((c == ' ' || c == '\t') && TRAILING == NO)
- // {
- // array[i] = c;
- // index = i;
- // TRAILING = YES;
- // i++;
- // }
- // else if ((c == ' ' || c == '\t') && TRAILING == YES)
- // {
- // array[i] = c;
- // i++;
- // }
- // if (c == '\n' && TRAILING == YES && INALINE == YES)
- // {
- // INALINE = NO;
- // TRAILING = NO;
- // array[index] = '\0';
- // array[index] = 'x';
- // array[index+1] = '\n';
- // i = index + 2;
- // }
- // else if (c == '\n' && TRAILING == NO && INALINE == YES)
- // {
- // INALINE = NO;
- // TRAILING = NO;
- // array[i] = 'x';
- // array[i+1] = '\n';
- // i = i + 2;
- // }
- // else if (c == '\n' && TRAILING == YES && INALINE == NO)
- // {
- // TRAILING = NO;
- // array[index] = '\0';
- // array[index] = 'x';
- // array[index + 1] = '\n';
- // i = index + 2;
- // }
- // }
- // if (c == EOF)
- // {
- // array[i] = '\0';
- // printf("%s", array);
- // array[0] = '\0';
- // i = 0;
- // }
- // }
- //}
- //#define MAXLENGTH 10000
- //
- //void reverse(char[], char[], int length); //new reverse(s) on line 5295
- //
- //main()
- //{
- // int c;
- // int i = 0;
- // int SOMETHINGWASREVERSED = NO;
- // char array[MAXLENGTH];
- // char reversearray[MAXLENGTH];
- //
- // while ((c = getchar()) != '!' && i < MAXLENGTH - 1)
- // {
- // if (c == '\n' && SOMETHINGWASREVERSED == YES)
- // {
- // printf("\n");
- // SOMETHINGWASREVERSED = NO;
- // }
- // else if (c == '?')
- // {
- // SOMETHINGWASREVERSED = YES;
- // array[i] = '\0';
- // reverse(array, reversearray, i);
- // printf("%s", reversearray);
- // array[0] = '\0';
- // reversearray[0] = '\0';
- // i = 0;
- // }
- //
- // else
- // {
- // array[i] = c;
- // i++;
- // }
- // }
- // array[i] = '\0';
- // reverse(array, reversearray, i);
- // printf("%s\n", reversearray);
- //}
- //
- //void reverse(char from[], char to[], int length)
- //{
- // int i = 0;
- // while (length - 1 >= 0)
- // {
- // to[i] = from[length - 1];
- // length--;
- // i++;
- // }
- // to[i] = '\0';
- //}
- //#define MAXSIZE 1000
- //
- //main()
- //{
- // int c;
- // int tabspaces = 0;
- // int spaces = 0;
- // int i = 0;
- // int nc = 0;
- // char array[MAXSIZE];
- //
- // printf("How many tab spaces? Type in the number of tab spaces and then press enter\n");
- //
- // while ((tabspaces = getchar()) == '\n')
- // ;
- //
- // while (tabspaces < '0' || tabspaces > '9')
- // {
- // printf("Not a number between 0 and 9.\nType in the number of tab spaces and then press enter\n");
- // while ((tabspaces = getchar()) == '\n')
- // ;
- // }
- // printf("Ok replacing text now. Press ^Z to print out replacement text. The number of tabspaces you selected is %d. Anything after %d has been stored in your replacement text.\n", tabspaces - '0', tabspaces - '0');
- // while ((c = getchar()) != EOF && i < MAXSIZE)
- // {
- // if (c != '\t' && c != '\n')
- // {
- // array[i] = c;
- // i++;
- // nc++;
- // }
- // else if (c == '\n')
- // {
- // array[i] = c;
- // i++;
- // nc = 0;
- // }
- // else if (c == '\t')
- // {
- // spaces = (tabspaces - '0') - (nc % (tabspaces - '0')); //tabspaces - '0'. The '8' stored in tabspaces from getchar is the integer/NUMERICAL value of the '8' in the ASCII chart/character code.
- // while (spaces > 0)
- // {
- // array[i] = 'x';
- // i++;
- // spaces--;
- // nc = 0; //NOTICED AND FIXED THIS PROGRAM WITH THIS EXPRESSION AFTER MOVING ON TO THE NEXT PROGRAM AND REALIZING THAT TWO CONTINUOUS INPUTS OF A TEST CONDITION WAS NOT TAKEN CARE OF! This resets the tab spaces logic.
- // }
- // }
- // }
- // array[i] = '\0';
- // printf("%s\n", array);
- //}
- //inastringofspace
- //beginning of text
- //#define MAXSIZE 1000
- //main()
- //{
- // int c;
- // int i = 0;
- // int nc = 0;
- // int nfl = 0;
- // int Firsttab = 0;
- // int spacesfromtab = 0;
- // int stringspaces = 0;
- // int STRINGOFSPACES = NO;
- // char array[MAXSIZE];
- // while ((c = getchar()) != EOF && i < MAXSIZE - 1)
- // {
- // if (c != '\t' && c != ' ' && c != '\n')
- // {
- // if (STRINGOFSPACES == YES)
- // {
- // if (8 - (nfl % 8) <= stringspaces)
- // {
- // stringspaces = stringspaces - (8 - (nfl % 8));
- // array[i] = '\t';
- // i++;
- // nc = 0;
- // nfl = 0;
- // while (stringspaces / 8 > 0)
- // {
- // array[i] = '\t';
- // i++;
- // stringspaces = stringspaces - 8;
- // }
- // }
- // while (stringspaces > 0)
- // {
- // array[i] = 'y';
- // i++;
- // nc++;
- // stringspaces--;
- // nfl = 0;
- // }
- // }
- // STRINGOFSPACES = NO;
- // array[i] = c;
- // i++;
- // nc++;
- // nfl++;
- // }
- // else if (c == '\t')
- // {
- // STRINGOFSPACES = YES;
- // spacesfromtab = 8 - (nc % 8);
- // nc = 0;
- // stringspaces = stringspaces + spacesfromtab;
- // }
- // else if (c == ' ')
- // {
- // STRINGOFSPACES = YES;
- // stringspaces++;
- // nc++;
- // }
- // else if (c == '\n')
- // {
- // if (STRINGOFSPACES == YES)
- // {
- // if (8 - (nfl % 8) <= stringspaces)
- // {
- // stringspaces = stringspaces - (8 - (nfl % 8));
- // array[i] = '\t';
- // i++;
- // nc = 0;
- // nfl = 0;
- // while (stringspaces / 8 > 0)
- // {
- // array[i] = '\t';
- // i++;
- // stringspaces = stringspaces - 8;
- // }
- // }
- // while (stringspaces > 0)
- // {
- // array[i] = 'y';
- // i++;
- // nc++;
- // stringspaces--;
- // nfl = 0;
- // }
- // }
- // nc = 0;
- // nfl = 0;
- // STRINGOFSPACES = NO;
- // array[i] = c;
- // i++;
- // }
- // }
- //
- // if (STRINGOFSPACES == YES)
- // {
- // if (8 - (nfl % 8) <= stringspaces)
- // {
- // stringspaces = stringspaces - (8 - (nfl % 8));
- // array[i] = '\t';
- // i++;
- // nc = 0;
- // nfl = 0;
- // while (stringspaces / 8 > 0)
- // {
- // array[i] = '\t';
- // i++;
- // stringspaces = stringspaces - 8;
- // }
- // }
- // while (stringspaces > 0)
- // {
- // array[i] = 'y';
- // i++;
- // nc++;
- // stringspaces--;
- // nfl = 0;
- // }
- //
- // array[i] = '\0';
- // printf("%s\n", array);a
- //}
- //#define MAXCHARACTERS 1000
- //main()
- //{
- // int c;
- // int i = 0;
- // int j = 0;
- // int nc = 0;
- // char array[MAXCHARACTERS];
- // char output[MAXCHARACTERS];
- // while ((c = getchar()) != EOF)
- // {
- // array[i++] = c;
- // }
- // array[i] = '\0';
- // i = 0;
- // while (array[i] != '\0')
- // {
- // while (nc < 9 && array[i] != '\0')
- // {
- // if (array[i] == '\t')
- // {
- // nc = nc + 8 - (nc % 8);
- // if (nc > 9)
- // {
- // output[j++] = '\n';
- // output[j++] = '\t';
- // nc = 8;
- // }
- // }
- // else if (array[i] != '\t')
- // nc++;
- // output[j] = array[i];
- // i++;
- // j++;
- // }
- //
- // if (nc == 9)
- // {
- // if (array[i] != ' ' && array[i] != '\t' && array[i] != '\n')
- // {
- // output[j++] = '-';
- // output[j++] = '\n';
- // nc = 0;
- // }
- // else
- // {
- // output[j++] = '\n';
- // nc = 0;
- // }
- // }
- // }
- // output[j] = '\0';
- // printf("%s\n", output);
- //}
- //#define MAXCHARACTERS 1000
- //main()
- //{
- // int c;
- // int i = 0;
- // int j = 0;
- // int k = 0;
- // int nc = 1;
- // int counter = 1;
- // char array[MAXCHARACTERS];
- // char output[MAXCHARACTERS];
- // while ((c = getchar()) != EOF)
- // {
- // array[i++] = c;
- // }
- // array[i] = '\0';
- // i = 0;
- //
- // while (array[i] != '\0')
- // {
- // while (counter < 9 && array[i] != '\0')
- // {
- // if (array[i] == '\t')
- // {
- // k = 8 - nc % 8;
- // while (k >= 0)
- // {
- // output[j++] = ' ';
- // k--;
- // counter++;
- // nc++;
- // }
- // i++;
- // }
- // else if (array[i] != '\t' && array[i] != '\n')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // nc++;
- // counter++;
- // }
- // else if (array[i] == '\n')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // nc = 1;
- // counter = 1;
- // }
- // }
- // if (counter >= 9)
- // {
- // if (array[i] != ' ' && array[i] != '\t' && array[i] != '\n' && array[i+1] != ' ' && array[i+1] != '\t' && array[i+1] != '\n')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // output[j++] = '-';
- // output[j++] = '\n';
- // nc++;
- // counter = 1;
- // }
- // else if (array[i] == '\t')
- // {
- // output[j++] = '\n';
- // output[j++] = '\t';
- // i++;
- // nc++;
- // counter = 8;
- // }
- // else if (array[i] == ' ')
- // {
- // output[j++] = ' ';
- // output[j++] = '\n';
- // i++;
- // nc++;
- // counter = 1;
- //
- // }
- // else if (array[i] == '\n')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // nc = 1;
- // counter = 1;
- // }
- // else
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // output[j++] = '\n';
- // nc++;
- // counter = 1;
- // }
- // }
- // }
- //
- // output[j] = '\0';
- // printf("%s\n", output);
- //}
- //#define MAXARRAYSIZE 1000
- //#define ON 1
- //#define OFF 0
- //main()
- //{
- // int c;
- // char array[MAXARRAYSIZE];
- // int i = 0;
- // int j = 0;
- // char output[MAXARRAYSIZE];
- // int DONE = NO;
- // int STAR = NO;
- // int COMMENTCHECKING = ON;
- //
- // while ((c = getchar()) != EOF && i < MAXARRAYSIZE - 1)
- // {
- // array[i] = c;
- // i++;
- // }
- // array[i] = '\0';
- // i = 0;
- // while (array[i] != '\0')
- // {
- // while (COMMENTCHECKING == ON && array[i] != '\0')
- // {
- // output[j] = array[i];
- // if (array[i] == '/' && COMMENTCHECKING == YES)
- // {
- // if (array[i + 1] == '/')
- // {
- // i++;
- // while (array[i] != '\n')
- // {
- // i++;
- // }
- // output[j] = array[i];
- // }
- // else if (array[i + 1] == '*' && COMMENTCHECKING == YES)
- // {
- // i++;
- // while (DONE == NO)
- // {
- // if (array[i] == '*')
- // {
- // STAR = YES;
- // i++;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // DONE = YES;
- // i++;
- // }
- // else
- // {
- // STAR = NO;
- // i++;
- // }
- // output[j] = array[i];
- // }
- // }
- // }
- // else if (array[i] == '"')
- // {
- // COMMENTCHECKING = OFF;
- // }
- // i++;
- // j++;
- // }
- // while (COMMENTCHECKING == OFF && array[i] != '\0')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // if (array[i] == '"')
- // {
- // COMMENTCHECKING = ON;
- // }
- // }
- // }
- // output[j] = array[i];
- // printf("%s\n", output);
- //}
- //#define MAXARRAYSIZE 10000
- //#define ON 1
- //#define OFF 0
- //main()
- //{ //test
- // int c;
- // char array[MAXARRAYSIZE]; /*test*/
- // int i = 0;
- // int j = 0;
- // char output[MAXARRAYSIZE];
- // int COMMENT = NO;
- // int STAR = NO;
- // int SQCOMMENTCHECKING = ON;
- // int DQCOMMENTCHECKING = ON;
- // /*test
- // a
- // b
- // c*/
- // while ((c = getchar()) != EOF && i < MAXARRAYSIZE - 1)
- // {
- // array[i] = c;
- // i++;
- // }
- // array[i] = '\0';
- // i = 0; //test
- // while (array[i] != '\0') /*test
- // a
- // b
- // c*/
- // {
- // while (SQCOMMENTCHECKING == ON && DQCOMMENTCHECKING == ON && array[i] != '\0')
- // {
- // output[j] = array[i];
- // if (array[i] == '/' && SQCOMMENTCHECKING == ON && DQCOMMENTCHECKING == ON)
- // {
- // if (array[i + 1] == '/')
- // {
- // i++;
- // while (array[i] != '\n')
- // {
- // i++;
- // }
- // output[j] = array[i];//test
- // }
- // else if (array[i + 1] == '*' && SQCOMMENTCHECKING == ON && DQCOMMENTCHECKING == ON)
- // {
- // i++;
- // i++;
- // COMMENT = YES;
- // while (COMMENT == YES)
- // {//test
- // if (array[i] == '*')
- // {
- // STAR = YES;
- // i++;//test
- // } /*test
- // a
- // b
- // c*/
- // else if (array[i] == '/' && STAR == YES)
- // {
- // COMMENT = NO;
- // i++;
- // }
- // else
- // {
- // STAR = NO;//test
- // i++;
- // }
- // }
- // //output[j] = array[i];
- // }
- // }
- // /*else if (array[i] == '"' && array[i-1] != '\'')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // COMMENTCHECKING = OFF;
- // }*/
- // else if (array[i] == '\'' && array[i - 1] != '\\')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // SQCOMMENTCHECKING = OFF;
- // }
- // else if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // DQCOMMENTCHECKING = OFF;
- // }
- // else
- // {
- // i++;
- // j++;
- // }
- // }
- // while ((SQCOMMENTCHECKING == OFF || DQCOMMENTCHECKING == OFF) && array[i] != '\0')
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // SQCOMMENTCHECKING = ON;
- // }
- // else if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // DQCOMMENTCHECKING = ON;
- // }
- // else
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // }
- // // if (array[i] == '"')
- // // { /*test
- // //a
- // //b
- // //c*//*test*///
- // // COMMENTCHECKING = ON;
- // // }
- // }
- // }
- // output[j] = array[i];
- // printf("%s\n", output);
- //}
- #define MAXARRAYSIZE 10000
- //main()
- //{
- // int c;
- // char array[MAXARRAYSIZE];
- // int i = 0;
- // char output[MAXARRAYSIZE];
- // int j = 0;
- // int MAXLParenthesis = 0;
- // int MAXLBraces = 0;
- // int MAXLBrackets = 0;
- // int RParenthesis = 0;
- // int RBraces = 0;
- // int RBrackets = 0;
- // int COMMENT = NO;
- // int STAR = NO;
- // int COMMENTDONE = NO;
- // int COMMENTBEGANON = 0;
- // int COMMENTBEGANON_REGISTERED = NO;
- // int LINE = 0;
- // int UNEVENCOMMENT = NO;
- // int INACOMMENT = NO;
- // while ((c = getchar()) != EOF)
- // {
- // array[i] = c;
- // i++;
- // }
- // array[i] = '\0';
- // i = 0;
- // while (array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // } //THE NEWLINE IS SAVED IN THE NEXT EXPRESSION AND THEN IT DOES NOT FIT ANY OTHER CONDITIONAL STATEMENTS SO IT WILL BE INCREMENTED BY AN ELSE 1
- //
- // output[j] = array[i]; //STORES EVERY CHARACTER FROM array
- //
- // if (array[i] == ';') //THIS CHECKS FOR COMMENTS AFTER ;
- // {
- // i++;
- // j++;
- // output[j] = array[i]; //CHECKS EITHER // OR /* OR / OR WHITE SPACE OR NEWLINE . FIVE DIFFERENT CASES.
- //
- // while (array[i] != '\n') //WHILE THE CHARACTER WE JUST SAVED IS NOT THE NEW LINE \n CHECK THE SIX CASES
- // {
- // i++;
- // j++;
- // output[j] = array[i];
- // if (INACOMMENT == NO && array[i] != '/' && array[i] != '*' && array[i] != ' ' && array[i] != '\t')
- // {
- // while (array[i] != '\n')
- // {
- // i++;
- // j++;
- // output[j] = array[i]; // //CASE 6 TEXT NOT IN A COMMENT
- // }
- // printf("Error: Syntax error. Text not in a comment on line %d.", LINE);
- // }
- //
- // if (array[i] == '/') //CHECKS CASE 1 2 3 4 5
- // {
- // UNEVENCOMMENT = YES; //CASE 1 UNEVEN COMMENT
- // INACOMMENT == YES;
- // COMMENTBEGANON = LINE;
- // if (array[i + 1] == '/')
- // {
- // UNEVENCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n')
- // {
- // i++;
- // j++;
- // output[j] = array[i]; //CASE 4 SINGLE LINE COMMENT //
- // }
- // }
- //
- // else if (array[i + 1] == '*') //CASE 5 MULTI LINE COMMENT /*
- // {
- // UNEVENCOMMENT = NO;
- // INACOMMENT = YES;
- // while (INACOMMENT == YES && array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // if (COMMENTBEGANON_REGISTERED == NO)
- // {
- // COMMENTBEGANON = LINE;
- // COMMENTBEGANON_REGISTERED == YES;
- // }
- // LINE++; //LINE COUNTER
- // }
- // if (array[i] == '*')
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // INACOMMENT = NO;
- // COMMENTBEGANON_REGISTERED == NO;
- // }
- // else
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // STAR = NO;
- // }
- // }
- // printf(" End of multi line comment. New line will be printed v \n");
- // }
- // }
- // }
- // if (UNEVENCOMMENT == YES)
- // {
- // printf("Error: Unbalanced comment on line. Missing / or *.");
- // output[j] = array[i];
- // i++;
- // j++;
- // }
- // else if (UNEVENCOMMENT == NO) //CASE 2 WHITESPACE //CASE 3 NEWLINE
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // }
- // }
- // if (array[i] == '/')
- // {
- // if (array[i + 1] == '/')
- // {
- // output[j] == 'C';
- // j++;
- // output[j] == 'O';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'E';
- // j++;
- // output[j] == 'N';
- // j++;
- // output[j] == 'T';
- // j++;
- // output[j] == ':';
- // j++;
- // output[j] = array[i]; // /
- // i++;
- // j++;
- // output[j] = array[i]; // //
- // i++;
- // j++;
- // COMMENT = YES;
- // while (c != '\n')
- // {
- // output[j] = array[i];//comment text
- // i++;
- // j++;
- // }
- // //output[j] = array[i]; //\n
- // //i++;
- // //j++;
- // }
- // else if (array[i + 1] == '*')
- // {
- // output[j] == 'C';
- // j++;
- // output[j] == 'O';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'E';
- // j++;
- // output[j] == 'N';
- // j++;
- // output[j] == 'T';
- // j++;
- // output[j] == ':';
- // j++;
- // output[j] = array[i]; // /
- // i++;
- // j++;
- // output[j] = array[i]; // //
- // i++;
- // j++;
- // COMMENT = YES;
- // COMMENTBEGANON = LINE; //comment that began on Line 1 never terminated.
- // while (COMMENTDONE == NO && array[i] != '\0')
- // {
- // if (array[i] == '*')
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // COMMENTDONE = YES;
- // }
- // else
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // STAR = NO;
- // }
- // }
- // if (array[i] == '\0' && COMMENTDONE == NO)
- // {
- // printf("Error: Unbalanced cooment. The comment that started on Line %d never finished.", COMMENTBEGANON);
- // }
- // COMMENT = NO;
- // }
- // else
- // ;
- // }
- // else
- // {
- // j++;
- // i++;
- // }
- //
- // }
- // output[j] = '\0';
- // printf("%s\n", output);
- //}
- //#define MAXARRAYSIZE 10000
- //
- //
- //main()
- //{
- // int c;
- // char array[MAXARRAYSIZE];
- // int i = 0;
- // char output[MAXARRAYSIZE];
- // int j = 0;
- // int MAXLParenthesis = 0;
- // int MAXLBraces = 0;
- // int MAXLBrackets = 0;
- // int RParenthesis = 0;
- // int RBraces = 0;
- // int RBrackets = 0;
- // int COMMENT = NO;
- // int STAR = NO;
- // int COMMENTDONE = NO;
- // int COMMENTBEGANON = 0;
- // int COMMENTBEGANON_REGISTERED = NO;
- // int LINE = 0;
- // int UNEVENCOMMENT = NO;
- // int INACOMMENT = NO;
- // while ((c = getchar()) != EOF)
- // {
- // array[i] = c;
- // i++;
- // }
- // array[i] = '\0';
- // i = 0;
- // while (array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // }
- //
- // output[j] = array[i]; //STORES EVERY CHARACTER FROM array to output
- //
- // if (array[i] == ';') //THIS CHECKS FOR COMMENTS AND TEXT OUTSIDE OF COMMENTS AFTER ;
- // {
- // i++;
- // j++;
- //
- // output[j] = array[i]; //CHECKS EITHER // OR /* OR / OR WHITE SPACE OR NEWLINE OR TEXT. SIX DIFFERENT CASES.
- //
- // while (array[i] != '\n') //CHECK THE SIX CASES
- // {
- // i++;
- // j++;
- //
- // output[j] = array[i]; //BEGIINNING OF TEXT THAT HAS TO BE ANALYZED. SAVED AND NOT NEXT.
- //
- // if (INACOMMENT == NO && array[i] != '/' && array[i] != '*' && array[i] != ' ' && array[i] != '\t') //CASE 6
- // {
- // while (array[i] != '\n')
- // {
- // i++;
- // j++;
- //
- // output[j] = array[i];
- // }
- // printf("Error: Syntax error. Text not in a comment on line %d.", LINE);
- // }
- //
- // if (array[i] == '/') //CHECKS CASE 1 2 3 4 5
- // {
- // UNEVENCOMMENT = YES; //CASE 1 UNEVEN COMMENT
- // INACOMMENT == YES;
- // COMMENTBEGANON = LINE;
- // if (array[i + 1] == '/')
- // {
- // UNEVENCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n')
- // {
- // i++;
- // j++;
- // output[j] = array[i]; //CASE 4 SINGLE LINE COMMENT //
- // }
- // }
- //
- // else if (array[i + 1] == '*') //CASE 5 MULTI LINE COMMENT /*
- // {
- // UNEVENCOMMENT = NO;
- // INACOMMENT = YES;
- // while (INACOMMENT == YES && array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // if (COMMENTBEGANON_REGISTERED == NO)
- // {
- // COMMENTBEGANON = LINE;
- // COMMENTBEGANON_REGISTERED == YES;
- // }
- // LINE++; //LINE COUNTER
- // }
- // if (array[i] == '*')
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // INACOMMENT = NO;
- // COMMENTBEGANON_REGISTERED == NO;
- // }
- // else
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // STAR = NO;
- // }
- // }
- // printf(" End of multi line comment. New line will be printed v \n");
- // }
- // }
- // }
- // if (UNEVENCOMMENT == YES)
- // {
- // printf("Error: Unbalanced comment on line. Missing / or *.");
- // output[j] = array[i];
- // i++;
- // j++;
- // }
- // else if (UNEVENCOMMENT == NO) //CASE 2 WHITESPACE //CASE 3 NEWLINE
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // }
- // }
- // if (array[i] == '/')
- // {
- // if (array[i + 1] == '/')
- // {
- // output[j] == 'C';
- // j++;
- // output[j] == 'O';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'E';
- // j++;
- // output[j] == 'N';
- // j++;
- // output[j] == 'T';
- // j++;
- // output[j] == ':';
- // j++;
- // output[j] = array[i]; // /
- // i++;
- // j++;
- // output[j] = array[i]; // //
- // i++;
- // j++;
- // COMMENT = YES;
- // while (c != '\n')
- // {
- // output[j] = array[i];//comment text
- // i++;
- // j++;
- // }
- // //output[j] = array[i]; //\n
- // //i++;
- // //j++;
- // }
- // else if (array[i + 1] == '*')
- // {
- // output[j] == 'C';
- // j++;
- // output[j] == 'O';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'E';
- // j++;
- // output[j] == 'N';
- // j++;
- // output[j] == 'T';
- // j++;
- // output[j] == ':';
- // j++;
- // output[j] = array[i]; // /
- // i++;
- // j++;
- // output[j] = array[i]; // //
- // i++;
- // j++;
- // COMMENT = YES;
- // COMMENTBEGANON = LINE; //comment that began on Line 1 never terminated.
- // while (COMMENTDONE == NO && array[i] != '\0')
- // {
- // if (array[i] == '*')
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // COMMENTDONE = YES;
- // }
- // else
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // STAR = NO;
- // }
- // }
- // if (array[i] == '\0' && COMMENTDONE == NO)
- // {
- // printf("Error: Unbalanced cooment. The comment that started on Line %d never finished.", COMMENTBEGANON);
- // }
- // COMMENT = NO;
- // }
- // else
- // ;
- // }
- // else
- // {
- // j++;
- // i++;
- // }
- //
- // }
- // output[j] = '\0';
- // printf("%s\n", output);
- //}
- //
- //
- //if (array[i] == '/')
- //{
- // if (array[i + 1] == '/')
- // {
- // output[j] == 'C';
- // j++;
- // output[j] == 'O';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'E';
- // j++;
- // output[j] == 'N';
- // j++;
- // output[j] == 'T';
- // j++;
- // output[j] == ':';
- // j++;
- // output[j] = array[i]; // /
- // i++;
- // j++;
- // output[j] = array[i]; // //
- // i++;
- // j++;
- // COMMENT = YES;
- // while (c != '\n')
- // {
- // output[j] = array[i];//comment text
- // i++;
- // j++;
- // }
- // //output[j] = array[i]; //\n
- // //i++;
- // //j++;
- // }
- // else if (array[i + 1] == '*')
- // {
- // output[j] == 'C';
- // j++;
- // output[j] == 'O';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'M';
- // j++;
- // output[j] == 'E';
- // j++;
- // output[j] == 'N';
- // j++;
- // output[j] == 'T';
- // j++;
- // output[j] == ':';
- // j++;
- // output[j] = array[i]; // /
- // i++;
- // j++;
- // output[j] = array[i]; // //
- // i++;
- // j++;
- // COMMENT = YES;
- // COMMENTBEGANON = LINE; //comment that began on Line 1 never terminated.
- // while (COMMENTDONE == NO && array[i] != '\0')
- // {
- // if (array[i] == '*')
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // COMMENTDONE = YES;
- // }
- // else
- // {
- // output[j] == array[i];
- // j++;
- // i++;
- // STAR = NO;
- // }
- // }
- // if (array[i] == '\0' && COMMENTDONE == NO)
- // {
- // printf("Error: Unbalanced cooment. The comment that started on Line %d never finished.", COMMENTBEGANON);
- // }
- // COMMENT = NO;
- // }
- // else
- // ;
- //}
- //else
- //{
- // j++;
- // i++;
- //}
- //
- //collects everything, line counts, all errors after ; prototype done, comment prototyp done, single quote and double quote prototype done, bracket prototype done, parenthesis prototype done, braces prototype,
- //#define MAXARRAYSIZE 10000
- //main()
- //{
- // int c;
- // char array[MAXARRAYSIZE];
- // int i = 0;
- // char output[MAXARRAYSIZE];
- // int j = 0;
- // char syntaxerror[MAXARRAYSIZE];
- // int k = 0;
- // int LeftBrackets = 0;
- // int RightBrackets = 0;
- // int EXTRABRACKETONLINE = 0;
- // int RightParenthesis = 0;
- // int LeftParanthesis = 0;
- // int EXTRAPARENTHESISONLINE = 0;
- // int RightBraces = 0;
- // int LeftBraces = 0;
- // int EXTRABRACESONLINE = 0;
- // int STAR = NO;
- // int UNBALANCEDCOMMENT = NO;
- // int INACOMMENT = NO;
- // int COMMENTDONE = NO;
- // int COMMENTBEGANON = 0;
- // int COMMENTENDEDON = 0;
- // int LINE = 1;
- // int SYNTAXERROR = NO;
- // int SYNTAXERRORONLINE = 0;
- // int INASINGLEQUOTE = NO;
- // int INADOUBLEQUOTE = NO;
- // int SINGLEQUOTEBEGANON = 0;
- // int DOUBLEQUOTEBEGANON = 0;
- // while ((c = getchar()) != EOF)
- // {
- // array[i] = c;
- // i++;
- // }
- // array[i] = '\0';
- // i = 0;
- // while (array[i] != '\0' && array[i] != EOF)
- // {
- //
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // if (LeftParanthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d. \t", EXTRAPARENTHESISONLINE);
- // }
- // RightBrackets = 0;
- // LeftBrackets = 0;
- // }
- //
- // output[j] = array[i]; //STORES EVERY CHARACTER FROM array
- //
- // if (array[i] == ';') //THIS CHECKS FOR COMMENTS AFTER ;
- // {
- // i++;
- // j++;
- //
- // output[j] = array[i]; //CHECKS EITHER // OR /* OR / OR WHITE SPACE OR NEWLINE . SIX DIFFERENT CASES.
- // if (LeftParanthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d. \n", EXTRAPARENTHESISONLINE);
- // }
- // RightBrackets = 0;
- // LeftBrackets = 0;
- //
- // while (array[i] != '\n' && array[i] != '\0') //WHILE THE CHARACTER WE JUST SAVED IS NOT THE NEW LINE \n CHECK THE SIX CASES
- // {
- // if (INACOMMENT == NO && array[i] != '/' && array[i] != '*' && array[i] != ' ' && array[i] != '\t') //CASE 6
- // {
- // while (array[i] != '/' && array[i] != '\n' && array[i] != '\0')
- // {
- // output[j] = array[i];
- // syntaxerror[k] = array[i];
- // SYNTAXERRORONLINE = LINE;
- // k++;
- // i++;
- // j++;
- // }
- // SYNTAXERROR = YES; //CASE 6 DONE
- // }
- //
- // else if (array[i] == '/') //CASE 1 2 3 4 5
- // {
- // output[j] = array[i];
- //
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // COMMENTBEGANON = LINE;
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n')
- // {
- // i++;
- // j++;
- // output[j] = array[i]; //CASE 4 DONE
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 5
- // {
- // UNBALANCEDCOMMENT = YES;
- // INACOMMENT = YES;
- // COMMENTBEGANON = LINE;
- // i++;
- // j++;
- // output[j] = array[i];
- // i++;
- // j++;
- // while (INACOMMENT == YES && array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // }
- // else if (array[i] == '*')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // COMMENTENDEDON = LINE;
- // STAR = NO;
- // }
- // else
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // STAR = NO;
- // }
- // }
- // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
- // {
- // printf("Multi-line comment that started on line %d and ended on %d. New line.\n", COMMENTBEGANON, COMMENTENDEDON); //CASE 5 DONE
- // }
- // }
- //
- // else
- // {
- // while (array[i] != '\n')
- // {
- // syntaxerror[k] = array[i]; // / a b
- // i++;
- // j++;
- // k++;
- // if (array[i] != '\n')
- // {
- // output[j] = array[i]; // a b
- // }
- // SYNTAXERRORONLINE = LINE;
- // }
- // SYNTAXERROR = YES;
- // }
- // }
- // else
- // {
- // i++;
- // j++;
- // }
- // }
- //
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
- // output[j] = array[i];
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- //
- // i++;
- // j++;
- // UNBALANCEDCOMMENT = NO;
- // }
- //
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2 WHITESPACE DONE //CASE 3 NEWLINE DONE //CASE 4 // DONE //CASE 5 /**/ DONE
- // {
- // output[j] = array[i]; //SAVES /n THEN NEXT -- EXITS CHECKING AFTER ;
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- //
- // i++;
- // j++;
- // }
- // if (SYNTAXERROR == YES) //CASE 6 DONE
- // {
- // syntaxerror[k] = '\0';
- // printf("Error: Syntax error. Text not in a comment on line %d. Code: %s\n", SYNTAXERRORONLINE, syntaxerror);
- // syntaxerror[0] = '\0';
- // k = 0;
- // output[j] = array[i];
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- //
- // i++;
- // j++;
- // SYNTAXERROR = NO;
- // }
- // } //; DONE
- //
- //
- // else if (array[i] == '/') //3 CASES
- // {
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // COMMENTBEGANON = LINE;
- //
- // if (array[i + 1] == '/') //CASE 2
- // {
- // UNBALANCEDCOMMENT = NO;
- //
- // INACOMMENT = YES;
- //
- // while (array[i] != '\n')
- // {
- // i++;
- // j++;
- // output[j] = array[i];
- // }
- // INACOMMENT = NO; //CASE 2 DONE
- // }
- //
- // else if (array[i + 1] == '*') //CASE 3
- // {
- // UNBALANCEDCOMMENT = YES;
- //
- // INACOMMENT = YES;
- //
- // COMMENTBEGANON = LINE;
- //
- // while (INACOMMENT == YES && array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // }
- // if (array[i] == '*')
- // {
- // i++;
- // j++;
- // output[j] == array[i];
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // i++;
- // j++;
- // output[j] == array[i];
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // }
- // else
- // {
- // i++;
- // j++;
- // output[j] == array[i];
- // STAR = NO;
- // }
- // }
- // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO && SYNTAXERROR == NO)
- // {
- // printf(" End of multi line comment that started on line %d. New line will be printed in case the next character is not a whitespace \n", COMMENTBEGANON); //CASE 3 DONE
- // }
- // }
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
- // output[j] = array[i];
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- //
- // i++;
- // j++;
- // UNBALANCEDCOMMENT = NO;
- // }
- //
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2
- // {
- // output[j] = array[i]; //SAVES /n THEN NEXT
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- //
- // i++;
- // j++;
- // }
- // }
- //
- // else if (array[i] == '\'' && array[i - 1] != '\\')
- // {
- // INASINGLEQUOTE = YES;
- // SINGLEQUOTEBEGANON = LINE;
- // i++;
- // j++;
- //
- // while (INASINGLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\')
- // {
- // INASINGLEQUOTE = NO;
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // else
- // {
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // }
- // if (INASINGLEQUOTE == YES)
- // {
- // printf("Error: Uneven single quote. The quote that started on line %d is missing a single quote \'.\n", SINGLEQUOTEBEGANON);
- // INASINGLEQUOTE = NO;
- // }
- //
- // }
- //
- // else if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = YES;
- // DOUBLEQUOTEBEGANON = LINE; //could use one variable QUOTEBEGANON
- // i++;
- // j++;
- // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
- // {
- // if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // else
- // {
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // }
- // if (INADOUBLEQUOTE == YES)
- // {
- // printf("Error: Uneven double quote. The double quote that started on line %d is missing a single quote \".\n", DOUBLEQUOTEBEGANON);
- // INADOUBLEQUOTE = NO;
- // }
- // }
- //
- // else if (array[i] == '[')
- // {
- // LeftBrackets++;
- // EXTRABRACKETONLINE = LINE;
- //
- // i++;
- // j++;
- // if (LeftBrackets - RightBrackets > 1)
- // {
- // printf("Error: Uneven brackets. An extra [ was found on line %d.\n", EXTRABRACKETONLINE);
- // }
- // }
- // else if (array[i] == ']')
- // {
- // RightBrackets++;
- // EXTRABRACKETONLINE = LINE;
- //
- // i++;
- // j++;
- // if (RightBrackets - LeftBrackets > 0)
- // {
- // printf("Error: Uneven brackets. An extra ] was found on line %d.\n", EXTRABRACKETONLINE);
- // }
- // }
- //
- // else if (array[i] == '(')
- // {
- // LeftParanthesis++;
- // EXTRAPARENTHESISONLINE = LINE;
- //
- // i++;
- // j++;
- // }
- // else if (array[i] == ')')
- // {
- // RightParenthesis++;
- // EXTRAPARENTHESISONLINE = LINE;
- //
- // i++;
- // j++;
- // if (RightParenthesis > LeftParanthesis)
- // {
- // printf("Error: Uneven Right Parenthesis. An extra ) was found on line %d.\n", EXTRAPARENTHESISONLINE);
- // }
- // }
- //
- // else if (array[i] == '{')
- // {
- // LeftBraces++;
- // EXTRABRACESONLINE = LINE;
- //
- // i++;
- // j++;
- // }
- // else if (array[i] == '}')
- // {
- // RightBraces++;
- // EXTRABRACESONLINE = LINE;
- //
- // i++;
- // j++;
- // if (RightBraces > LeftBraces)
- // {
- // printf("Error: Uneven Right Braces. An extra } was found on line %d.\n", EXTRABRACESONLINE);
- // }
- // }
- // else if (array[i] != '\0' && array[i] != EOF)
- // {
- // i++;
- // j++;
- // }
- // else
- // ;
- // }
- //
- // if (LeftBraces > RightBraces)
- // {
- // printf("Error: Uneven Left Braces. An extra { was found on line %d.\n", EXTRABRACESONLINE);
- // }
- //
- // output[j] = '\0'; //DONE
- // printf("%s\n", output); //PRINT OUTPUT
- //}
- /*
- error
- error; error
- error; / error
- error; //noerror
- error; /*noerror*/
- //error;/*noerror
- //*/
- //error; /*error/
- //error; /*error*8/
- //error:
- //*/
- //#define MAXARRAYSIZE 20000
- //main()
- //{
- // int c;
- // char array[MAXARRAYSIZE];
- // int i = 0;
- // char output[MAXARRAYSIZE];
- // int j = 0;
- // char syntaxerror[MAXARRAYSIZE];
- // int k = 0;
- // int LeftBrackets = 0;
- // int RightBrackets = 0;
- // int EXTRABRACKETONLINE = 0;
- // int RightParenthesis = 0;
- // int LeftParanthesis = 0;
- // int EXTRAPARENTHESISONLINE = 0;
- // int RightBraces = 0;
- // int LeftBraces = 0;
- // int EXTRALEFTBRACEONLINE = 0;
- // int EXTRARIGHTBRACEONLINE = 0;
- // int STAR = NO;
- // int UNBALANCEDCOMMENT = NO;
- // int INACOMMENT = NO;
- // int COMMENTDONE = NO;
- // int COMMENTBEGANON = 0;
- // int COMMENTENDEDON = 0;
- // int LINE = 2362;
- // int SYNTAXERROR = NO;
- // int SYNTAXERRORONLINE = 0;
- // int INASINGLEQUOTE = NO;
- // int INADOUBLEQUOTE = NO;
- // int SINGLEQUOTEBEGANON = 0;
- // int DOUBLEQUOTEBEGANON = 0;
- // int HEXSYNTAXERROR = NO;
- // int HEXSYNTAXERRORBEGANON = 0;
- // //octal (come back)
- // while ((c = getchar()) != EOF)
- // {
- // array[i] = c;
- // i++;
- // }
- // array[i] = '\0';
- // i = 0;
- // printf("\n");//appears after data collection. if this was placed at the beginning of the program after the declarations the newline would be printed before the data collection (the terminal would appear initiate with a newline.
- // while (array[i] != '\0' && array[i] != EOF)
- // {
- //
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // if (LeftParanthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
- // }
- // RightBrackets = 0;
- // LeftBrackets = 0;
- // RightParenthesis = 0;
- // LeftParanthesis = 0;
- // }
- // output[j] = array[i]; //STORES EVERY CHARACTER FROM array
- //
- // if (array[i] == ';') //THIS CHECKS FOR COMMENTS AFTER ;
- // {
- // i++;
- // j++;
- //
- // output[j] = array[i]; //CHECKS EITHER // OR /* OR / OR WHITE SPACE OR NEWLINE . SIX DIFFERENT CASES.
- // if (LeftParanthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d. \n", EXTRAPARENTHESISONLINE);
- // }
- // RightBrackets = 0;
- // LeftBrackets = 0;
- //
- // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //WHILE THE CHARACTER WE JUST SAVED IS NOT THE NEW LINE \n CHECK THE SIX CASES
- // {
- // if (INACOMMENT == NO && array[i] != '/' && array[i] != '*' && array[i] != ' ' && array[i] != '\t') //CASE 6
- // {
- // while (array[i] != '/' && array[i] != '\n' && array[i] != '\0')
- // {
- // output[j] = array[i];
- // syntaxerror[k] = array[i];
- // SYNTAXERRORONLINE = LINE;
- // k++;
- // i++;
- // j++;
- // }
- // syntaxerror[k] = ' ';
- // k++;
- // SYNTAXERROR = YES; //CASE 6 DONE
- // }
- //
- // else if (array[i] == '/') //CASE 1 2 3 4 5
- // {
- // output[j] = array[i];
- //
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // COMMENTBEGANON = LINE;
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n')
- // {
- // i++;
- // j++;
- // output[j] = array[i]; //CASE 4 DONE
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 5
- // {
- // UNBALANCEDCOMMENT = YES;
- // INACOMMENT = YES;
- // COMMENTBEGANON = LINE;
- // i++;
- // j++;
- // output[j] = array[i];
- // i++;
- // j++;
- // while (INACOMMENT == YES && array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // output[j] = array[i];
- // i++;
- // j++;
- // if (LeftParanthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
- // }
- // RightBrackets = 0;
- // LeftBrackets = 0;
- // RightParenthesis = 0;
- // LeftParanthesis = 0;
- // }
- // else if (array[i] == '*')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // COMMENTENDEDON = LINE;
- // STAR = NO;
- // }
- // else
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // STAR = NO;
- // }
- // }
- // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
- // {
- // printf("Multi-line comment started on line %d and ended on %d.\n", COMMENTBEGANON, COMMENTENDEDON); //CASE 5 DONE
- // }
- // }
- //
- // else
- // {
- // syntaxerror[k] = array[i];
- // output[j] = array[i];
- // i++;
- // j++;
- // k++;
- //
- // while (array[i] != '\n' && array[i] != '/' && array[i] != '\0' && array[i] != EOF)
- // {
- // syntaxerror[k] = array[i]; // / a b
- // output[j] = array[i];
- // i++;
- // j++;
- // k++;
- // SYNTAXERRORONLINE = LINE;
- // }
- // SYNTAXERROR = YES;
- // }
- // }
- // else
- // {
- // ; //NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
- // /*i++;
- // j++;*/
- // }
- // }
- //
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
- // output[j] = array[i];
- //
- // if (array[i] == '\0')
- // {
- // printf("\n%s\n", output);
- // }
- // if (array[i] == '\n')
- // {
- // LINE++;
- // if (LeftParanthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
- // }
- // RightBrackets = 0;
- // LeftBrackets = 0;
- // RightParenthesis = 0;
- // LeftParanthesis = 0;
- // }
- //
- // i++;
- // j++;
- // UNBALANCEDCOMMENT = NO;
- // }
- //
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2 WHITESPACE DONE //CASE 3 NEWLINE DONE //CASE 4 // DONE //CASE 5 /**/ DONE
- // {
- // output[j] = array[i]; //SAVES /n THEN NEXT -- EXITS CHECKING AFTER ;
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // if (LeftParanthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
- // }
- // RightBrackets = 0;
- // LeftBrackets = 0;
- // RightParenthesis = 0;
- // LeftParanthesis = 0;
- // }
- //
- // i++;
- // j++;
- // }
- // if (SYNTAXERROR == YES) //CASE 6 DONE
- // {
- // syntaxerror[k] = '\0';
- // printf("Error: Syntax error. Text not in a comment on line %d. Code: %s\n", SYNTAXERRORONLINE, syntaxerror);
- // syntaxerror[0] = '\0';
- // k = 0;
- // output[j] = array[i];
- //
- // if (array[i] == '\n')
- // {
- // if (LeftParanthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
- // }
- // LINE++;
- // RightBrackets = 0;
- // LeftBrackets = 0;
- // RightParenthesis = 0;
- // LeftParanthesis = 0;
- // }
- //
- // i++;
- // j++;
- // SYNTAXERROR = NO;
- // }
- // } //; DONE
- // else if (array[i] == '/') //3 CASES
- // {
- // output[j] = array[i];
- //
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // COMMENTBEGANON = LINE;
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n')
- // {
- // i++;
- // j++;
- // output[j] = array[i]; //CASE 4 DONE
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 3
- // {
- // UNBALANCEDCOMMENT = YES;
- //
- // INACOMMENT = YES;
- //
- // COMMENTBEGANON = LINE;
- // i++;
- // j++;
- // output[j] = array[i];
- // i++;
- // j++;
- // while (INACOMMENT == YES && array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // output[j] = array[i];
- // i++;
- // j++;
- // if (LeftParanthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
- // }
- // RightBrackets = 0;
- // LeftBrackets = 0;
- // RightParenthesis = 0;
- // LeftParanthesis = 0;
- // }
- // else if (array[i] == '*')
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // COMMENTENDEDON = LINE;
- // STAR = NO;
- // }
- // else
- // {
- // output[j] = array[i];
- // i++;
- // j++;
- // STAR = NO;
- // }
- // }
- // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
- // {
- // printf("Multi-line comment started on line %d and ended on %d.\n", COMMENTBEGANON, COMMENTENDEDON);
- // }
- // }
- // else
- // ; //NEXT CHARACTER HANDLED IN THE UNBALANCED CODE BLOCK
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
- // output[j] = array[i];
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // if (LeftParanthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
- // }
- // RightBrackets = 0;
- // LeftBrackets = 0;
- // RightParenthesis = 0;
- // LeftParanthesis = 0;
- // }
- //
- // i++;
- // j++;
- // UNBALANCEDCOMMENT = NO;
- // }
- //
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2
- // {
- // output[j] = array[i]; //SAVES /n THEN NEXT
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // if (LeftParanthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
- // }
- // RightBrackets = 0;
- // LeftBrackets = 0;
- // RightParenthesis = 0;
- // LeftParanthesis = 0;
- // }
- //
- // i++;
- // j++;
- // }
- // }
- //
- // else if (array[i] == '\'' && array[i - 1] != '\\') //wow '\\' is reading \' wow SO THE CODE READS ' and before that the last two characters are \\. cases like \"' work as expected before this fix. LATEST DEBUG 5:02 PM 11/20/2019
- // {
- // INASINGLEQUOTE = YES;
- // SINGLEQUOTEBEGANON = LINE;
- // i++;
- // j++;
- //
- // while (INASINGLEQUOTE == YES && array[i] != '\n') //if hex number must be 0-9 A-F until a space is read.
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
- // {
- // INASINGLEQUOTE = NO;
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INASINGLEQUOTE = NO;
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // else if (array[i] == 'x' && array[i - 1] == '\\' && array[i-2] != '\\')
- // {
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // while (array[i] != ' ' && array[i] != '\'' && array[i] != '\n')
- // {
- // if (array[i] != '0' && array[i] != '1' && array[i] != '2' && array[i] != '3' && array[i] != '4' && array[i] != '5' && array[i] != '6' && array[i] != '7' && array[i] != '8' && array[i] != '9' && array[i] != 'A' && array[i] != 'B' && array[i] != 'C' && array[i] != 'D' && array[i] != 'E' && array[i] != 'F')
- // {
- // HEXSYNTAXERROR = YES;
- // HEXSYNTAXERRORBEGANON = LINE;
- // }
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // }
- // else
- // {
- //
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // }
- // if (INASINGLEQUOTE == YES)
- // {
- // printf("Error: Uneven single quote. The single quote that started on line %d is missing a single quote \'.\n", SINGLEQUOTEBEGANON);
- // INASINGLEQUOTE = NO;
- // }
- // if (HEXSYNTAXERROR == YES)
- // {
- // printf("Error: Syntax error. The hexidecimal number on line %d is not acceptable.\n", HEXSYNTAXERRORBEGANON);
- // HEXSYNTAXERROR = NO;
- // }
- // }
- //
- // else if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = YES;
- // DOUBLEQUOTEBEGANON = LINE; //could use one variable QUOTEBEGANON
- // i++;
- // j++;
- // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
- // {
- // if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // else if (array[i] == 'x' && array[i - 1] == '\\' && array[i - 2] != '\\')
- // {
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // while (array[i] != ' ' && array[i] != '\'' && array[i] != '\n')
- // {
- // if (array[i] != '0' && array[i] != '1' && array[i] != '2' && array[i] != '3' && array[i] != '4' && array[i] != '5' && array[i] != '6' && array[i] != '7' && array[i] != '8' && array[i] != '9' && array[i] != 'A' && array[i] != 'B' && array[i] != 'C' && array[i] != 'D' && array[i] != 'E' && array[i] != 'F')
- // {
- // HEXSYNTAXERROR = YES;
- // HEXSYNTAXERRORBEGANON = LINE;
- // }
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // }
- // else
- // {
- // output[j] = array[i];
- //
- // i++;
- // j++;
- // }
- // }
- // if (INADOUBLEQUOTE == YES)
- // {
- // printf("Error: Uneven double quote. The double quote that started on line %d is missing a double quote \".\n", DOUBLEQUOTEBEGANON);
- // INADOUBLEQUOTE = NO;
- // }
- // if (HEXSYNTAXERROR == YES)
- // {
- // printf("Error: Syntax error. The hexidecimal number on line %d is not acceptable.\n", HEXSYNTAXERRORBEGANON);
- // HEXSYNTAXERROR = NO;
- // }
- // }
- //
- // else if (array[i] == '[')
- // {
- // LeftBrackets++;
- // EXTRABRACKETONLINE = LINE;
- //
- // i++;
- // j++;
- // if (LeftBrackets - RightBrackets > 1)
- // {
- // printf("Error: Uneven brackets. An extra [ was found on line %d.\n", EXTRABRACKETONLINE);
- // }
- // }
- // else if (array[i] == ']')
- // {
- // RightBrackets++;
- // EXTRABRACKETONLINE = LINE;
- //
- // i++;
- // j++;
- // if (RightBrackets - LeftBrackets > 0)
- // {
- // printf("Error: Uneven brackets. An extra ] was found on line %d.\n", EXTRABRACKETONLINE);
- // }
- // }
- //
- // else if (array[i] == '(')
- // {
- // LeftParanthesis++;
- // EXTRAPARENTHESISONLINE = LINE;
- //
- // i++;
- // j++;
- // }
- // else if (array[i] == ')')
- // {
- // RightParenthesis++;
- // EXTRAPARENTHESISONLINE = LINE;
- //
- // i++;
- // j++;
- // if (RightParenthesis > LeftParanthesis)
- // {
- // printf("Error: Uneven Right Parenthesis. An extra ) was found on line %d.\n", EXTRAPARENTHESISONLINE);
- // }
- // }
- //
- // else if (array[i] == '{')
- // {
- // LeftBraces++;
- // EXTRALEFTBRACEONLINE = LINE;
- //
- // i++;
- // j++;
- // }
- // else if (array[i] == '}')
- // {
- // RightBraces++;
- // EXTRARIGHTBRACEONLINE = LINE;
- //
- // i++;
- // j++;
- // if (RightBraces > LeftBraces)
- // {
- // printf("Error: Uneven Right Braces. An extra } was found on line %d.\n", EXTRARIGHTBRACEONLINE);
- // }
- // }
- // else if (array[i] != '\0' && array[i] != EOF)
- // {
- // i++;
- // j++;
- // }
- // else
- // ;
- // }
- //
- // if (LeftBraces > RightBraces)
- // {
- // printf("Error: Uneven Left Braces. An extra { was found on line %d.\n", EXTRALEFTBRACEONLINE);
- // }
- //
- // output[j] = '\0'; //DONE
- // printf("\n%s\n", output); //PRINT OUTPUT
- //}
- //
- //void checkCommentsAfterSemicolon(char array[]); //line 0
- //void checkComments(char array[]);
- //void checkSingleQuotes(char array[]);
- //void checkDoubleQuotes(char array[]);
- //void checkHexidecimalEscapeSequences(char array[]);
- //void checkBrackets(char array[]);
- //void checkParenthesis(char array[]);
- //void checkBraces(char array[]);
- //
- //#define MAXARRAYSIZE 50000
- //main()
- //{
- // int c;
- // char array[MAXARRAYSIZE];
- // int i = 0;
- // //octal (come back)
- //
- // while ((c = getchar()) != EOF)
- // {
- // array[i] = c;
- // i++;
- // }
- // array[i] = '\0';
- //
- // printf("\n");
- // //line 0
- // checkCommentsAfterSemicolon(array);
- //
- // checkComments(array);
- //
- // checkSingleQuotes(array);
- //
- // checkDoubleQuotes(array);
- //
- // checkHexidecimalEscapeSequences(array); //line 34
- //
- // checkBrackets(array);
- //
- // checkParenthesis(array);
- //
- // printf("\ndone\n");
- //}
- //
- //void checkCommentsAfterSemicolon(char array[])
- //{
- // int i = 0;
- // char syntaxerror[MAXARRAYSIZE];
- // int k = 0;
- // int STAR = NO;
- // int UNBALANCEDCOMMENT = NO;
- // int INACOMMENT = NO;
- // int COMMENTBEGANON = 0;
- // int COMMENTENDEDON = 0;
- // int LINE = 0;
- // int SYNTAXERROR = NO;
- // int SYNTAXERRORONLINE = 0;
- // int INASINGLEQUOTE = NO;
- // int INADOUBLEQUOTE = NO;
- //
- // while (array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == ';') //line 34
- // {
- // i++;
- // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //WHILE THE CHARACTER WE JUST SAVED IS NOT THE NEW LINE \n CHECK THE SIX CASES
- // {
- // if (INACOMMENT == NO && array[i] != '/' && array[i] != ' ' && array[i] != '\t') //CASE 6
- // {
- // while (array[i] != '/' && array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
- // {
- // syntaxerror[k] = array[i];
- // SYNTAXERRORONLINE = LINE;
- // k++;
- // i++;
- // }
- // syntaxerror[k] = ' ';
- // k++;
- // SYNTAXERROR = YES; //CASE 6 DONE
- // }
- //
- // else if (array[i] == '/') //CASE 1 2 3 4 5
- // {
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // COMMENTBEGANON = LINE;
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
- // {
- // i++;
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 5
- // {
- // UNBALANCEDCOMMENT = YES;
- // INACOMMENT = YES;
- // COMMENTBEGANON = LINE;
- // i++;
- // i++;
- // while (INACOMMENT == YES && array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // i++;
- // }
- // else if (array[i] == '*')
- // {
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // i++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // STAR = NO;
- // }
- // else
- // {
- // i++;
- // STAR = NO;
- // }
- // }
- // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
- // {
- // printf("Multi-line comment started on line %d and ended on %d.\n", COMMENTBEGANON, COMMENTENDEDON); //CASE 5 DONE
- // /*test
- // */
- // }
- // }
- //
- // else
- // {
- // printf("5\n");
- // syntaxerror[k] = array[i];
- // i++;
- // k++;
- //
- // while (array[i] != '\n' && array[i] != '/' && array[i] != '\0' && array[i] != EOF)
- // {
- // syntaxerror[k] = array[i]; // / a b
- // i++;
- // k++;
- // SYNTAXERRORONLINE = LINE;
- // }
- // SYNTAXERROR = YES;
- // }
- // }
- // else
- // i++;
- // }
- //
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
- //
- // if (array[i] == '\0')
- // {
- // //printf("\n%s\n", output);
- // printf("null\n");
- // }
- //
- // if (array[i] == EOF)
- // {
- // printf("EOF\n");
- // }
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- //
- // i++;
- // UNBALANCEDCOMMENT = NO;
- // }
- //
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2 WHITESPACE DONE //CASE 3 NEWLINE DONE //CASE 4 // DONE //CASE 5 /**/ DONE
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // if (SYNTAXERROR == YES) //CASE 6 DONE
- // {
- // syntaxerror[k] = '\0';
- // printf("Error: Syntax error. Text not in a comment on line %d. Code: %s\n", SYNTAXERRORONLINE, syntaxerror);
- // syntaxerror[0] = '\0';
- // k = 0;
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- //
- // i++;
- // SYNTAXERROR = NO;
- // }
- // }
- // else if (array[i] == '/') //3 CASES
- // {
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // COMMENTBEGANON = LINE;
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
- // {
- // i++;
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 3
- // {
- // UNBALANCEDCOMMENT = YES;
- //
- // INACOMMENT = YES;
- //
- // COMMENTBEGANON = LINE;
- // i++;
- // i++;
- // while (INACOMMENT == YES && array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // i++;
- // }
- // else if (array[i] == '*')
- // {
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // i++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // COMMENTENDEDON = LINE;
- // STAR = NO;
- // }
- // else
- // {
- // i++;
- // STAR = NO;
- // }
- // }
- // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
- // {
- // printf("Multi-line comment started on line %d and ended on %d.\n", COMMENTBEGANON, COMMENTENDEDON); //style
- // }
- // }
- // else
- // ; //NEXT CHARACTER (' ') IS HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- //
- // i++;
- // UNBALANCEDCOMMENT = NO;
- // }
- //
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2
- // {
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- // else if (array[i] == '\'' && array[i - 1] != '\\') //wow '\\' is reading \' wow SO THE CODE READS ' and before that the last two characters are \\. cases like \"' work as expected before this fix. LATEST DEBUG 5:02 PM 11/20/2019
- // {
- // INASINGLEQUOTE = YES;
- // i++;
- //
- // while (INASINGLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //if hex number must be 0-9 A-F until a space is read.
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INASINGLEQUOTE == YES)
- // {
- // INASINGLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = YES;
- // i++;
- // while (INADOUBLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //could use one variable INAQUOTE
- // {
- // if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INADOUBLEQUOTE == YES)
- // {
- // INADOUBLEQUOTE = NO;
- // }
- // }
- // else
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- //}
- //
- //void checkComments(char array[])
- //{
- // int i = 0;
- // int STAR = NO;
- // int UNBALANCEDCOMMENT = NO;
- // int INACOMMENT = NO;
- // int COMMENTBEGANON = 0;
- // int COMMENTENDEDON = 0;
- // int LINE = 0;
- // int INASINGLEQUOTE = NO;
- // int INADOUBLEQUOTE = NO;
- //
- // while (array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '/') //3 CASES
- // {
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // COMMENTBEGANON = LINE;
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
- // {
- // i++;
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 3
- // {
- // UNBALANCEDCOMMENT = YES;
- //
- // INACOMMENT = YES;
- //
- // COMMENTBEGANON = LINE;
- // i++;
- // i++;
- // while (INACOMMENT == YES && array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // i++;
- // }
- // else if (array[i] == '*')
- // {
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // i++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // COMMENTENDEDON = LINE;
- // STAR = NO;
- // }
- // else
- // {
- // i++;
- // STAR = NO;
- // }
- // }
- // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
- // {
- // printf("Multi-line comment started on line %d and ended on %d.\n", COMMENTBEGANON, COMMENTENDEDON); //style
- // }
- // }
- // else
- // ; //NEXT CHARACTER (' ') IS HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- //
- // i++;
- // UNBALANCEDCOMMENT = NO;
- // }
- //
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2
- // {
- //
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- // else if (array[i] == '\'' && array[i - 1] != '\\') //wow '\\' is reading \' wow SO THE CODE READS ' and before that the last two characters are \\. cases like \"' work as expected before this fix. LATEST DEBUG 5:02 PM 11/20/2019
- // {
- // INASINGLEQUOTE = YES;
- // i++;
- //
- // while (INASINGLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //if hex number must be 0-9 A-F until a space is read.
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INASINGLEQUOTE == YES)
- // {
- // INASINGLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = YES;
- // i++;
- // while (INADOUBLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //could use one variable INAQUOTE
- // {
- // if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INADOUBLEQUOTE == YES)
- // {
- // INADOUBLEQUOTE = NO;
- // }
- // }
- // else
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- //}
- //
- //void checkSingleQuotes(char array[])
- //{
- // int i = 0;
- // char syntaxerror[MAXARRAYSIZE];
- // int k = 0;
- // int STAR = NO;
- // int UNBALANCEDCOMMENT = NO;
- // int INACOMMENT = NO;
- // int LINE = 0;
- // int INASINGLEQUOTE = NO;
- // int SINGLEQUOTEBEGANON = 0;
- // int INADOUBLEQUOTE = NO;
- //
- // while (array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\') /*wow '\\' is reading \' wow SO THE CODE READS ' and before that the last two characters are \\. cases like \"' work as expected before this fix. LATEST DEBUG 5:02 PM 11/20/2019*/
- // {
- // INASINGLEQUOTE = YES;
- // SINGLEQUOTEBEGANON = LINE;
- // i++;
- //
- // while (INASINGLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //if hex number must be 0-9 A-F until a space is read.
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INASINGLEQUOTE == YES)
- // {
- // printf("Error: Uneven single quote. The single quote that started on line %d is missing a single quote \'.\n", SINGLEQUOTEBEGANON);
- // INASINGLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = YES;
- // i++;
- // while (INADOUBLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //could use one variable INAQUOTE
- // {
- // if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INADOUBLEQUOTE == YES)
- // {
- // INADOUBLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '/') //3 CASES
- // {
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
- // {
- // i++;
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 3
- // {
- // UNBALANCEDCOMMENT = YES;
- // INACOMMENT = YES;
- // i++;
- // i++;
- // while (INACOMMENT == YES && array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // i++;
- // }
- // else if (array[i] == '*')
- // {
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // i++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // STAR = NO;
- // }
- // else
- // {
- // i++;
- // STAR = NO;
- // }
- // }
- // }
- // else
- // {
- // ;//NEXT CHARACTER IS HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
- // /*i++;
- // j++;*/
- // }
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // UNBALANCEDCOMMENT = NO;
- // }
- //
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- // else
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- //}
- //
- //void checkDoubleQuotes(char array[])
- //{
- // int i = 0;
- // char syntaxerror[MAXARRAYSIZE];
- // int k = 0;
- // int STAR = NO;
- // int UNBALANCEDCOMMENT = NO;
- // int INACOMMENT = NO;
- // int LINE = 0;
- // int INADOUBLEQUOTE = NO;
- // int DOUBLEQUOTEBEGANON = 0;
- // int INASINGLEQUOTE = NO;
- //
- // while (array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = YES;
- // DOUBLEQUOTEBEGANON = LINE; //could use one variable QUOTEBEGANON
- // i++;
- // while (INADOUBLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //could use one variable INAQUOTE
- // {
- // if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INADOUBLEQUOTE == YES)
- // {
- // printf("Error: Uneven double quote. The double quote that started on line %d is missing a double quote \".\n", DOUBLEQUOTEBEGANON);
- // INADOUBLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '\'' && array[i - 1] != '\\') //wow '\\' is reading \' wow SO THE CODE READS ' and before that the last two characters are \\. cases like \"' work as expected before this fix. LATEST DEBUG 5:02 PM 11/20/2019
- // {
- // INASINGLEQUOTE = YES;
- // i++;
- //
- // while (INASINGLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //if hex number must be 0-9 A-F until a space is read.
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INASINGLEQUOTE == YES)
- // {
- // INASINGLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '/') //3 CASES
- // {
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
- // {
- // i++;
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 3
- // {
- // UNBALANCEDCOMMENT = YES;
- // INACOMMENT = YES;
- // i++;
- // i++;
- // while (INACOMMENT == YES && array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // i++;
- // }
- // else if (array[i] == '*')
- // {
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // i++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // STAR = NO;
- // }
- // else
- // {
- // i++;
- // STAR = NO;
- // }
- // }
- // }
- // else
- // {
- // ;//NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT BLOCK
- // /*i++;
- // j++;*/
- // }
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // UNBALANCEDCOMMENT = NO;
- // }
- //
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- // else
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- //}
- //
- //void checkHexidecimalEscapeSequences(char array[])
- //{
- // int i = 0;
- // char syntaxerror[MAXARRAYSIZE];
- // int k = 0;
- // int STAR = NO;
- // int UNBALANCEDCOMMENT = NO;
- // int INACOMMENT = NO;
- // int LINE = 0;
- // int INASINGLEQUOTE = NO;
- // int INADOUBLEQUOTE = NO;
- // int HEXSYNTAXERROR = NO;
- // int HEXSYNTAXERRORBEGANON = 0;
- //
- // while (array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\') //wow '\\' is reading \' wow SO THE CODE READS ' and before that the last two characters are \\. cases like \"' work as expected before this fix. LATEST DEBUG 5:02 PM 11/20/2019
- // {
- // INASINGLEQUOTE = YES;
- // i++;
- //
- // while (INASINGLEQUOTE == YES && array[i] != '\n') //if hex number must be 0-9 A-F until a space is read.
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == 'x' && array[i - 1] == '\\' && array[i - 2] != '\\')
- // {
- // i++;
- // while (array[i] != ' ' && array[i] != '\'' && array[i] != '\n')
- // {
- // if (array[i] != '0' && array[i] != '1' && array[i] != '2' && array[i] != '3' && array[i] != '4' && array[i] != '5' && array[i] != '6' && array[i] != '7' && array[i] != '8' && array[i] != '9' && array[i] != 'A' && array[i] != 'B' && array[i] != 'C' && array[i] != 'D' && array[i] != 'E' && array[i] != 'F')
- // {
- // HEXSYNTAXERROR = YES;
- // HEXSYNTAXERRORBEGANON = LINE;
- // }
- // i++;
- // }
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INASINGLEQUOTE == YES)
- // {
- // INASINGLEQUOTE = NO;
- // }
- // if (HEXSYNTAXERROR == YES)
- // {
- // printf("Error: Syntax error. The hexidecimal number in the single quotes on line %d is not acceptable.\n", HEXSYNTAXERRORBEGANON);
- // HEXSYNTAXERROR = NO;
- // }
- // }
- // else if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = YES;
- // i++;
- // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
- // {
- // if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == 'x' && array[i - 1] == '\\' && array[i - 2] != '\\')
- // {
- // i++;
- // while (array[i] != ' ' && array[i] != '\'' && array[i] != '\n')
- // {
- // if (array[i] != '0' && array[i] != '1' && array[i] != '2' && array[i] != '3' && array[i] != '4' && array[i] != '5' && array[i] != '6' && array[i] != '7' && array[i] != '8' && array[i] != '9' && array[i] != 'A' && array[i] != 'B' && array[i] != 'C' && array[i] != 'D' && array[i] != 'E' && array[i] != 'F')
- // {
- // HEXSYNTAXERROR = YES;
- // HEXSYNTAXERRORBEGANON = LINE;
- // }
- // i++;
- // }
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INADOUBLEQUOTE == YES)
- // {
- // INADOUBLEQUOTE = NO;
- // }
- // if (HEXSYNTAXERROR == YES)
- // {
- // printf("Error: Syntax error. The hexidecimal number in the double quotes on line %d is not acceptable.\n", HEXSYNTAXERRORBEGANON);
- // HEXSYNTAXERROR = NO;
- // }
- // }
- // else if (array[i] == '/') //3 CASES
- // {
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n')
- // {
- // i++;
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 3
- // {
- // UNBALANCEDCOMMENT = YES;
- // INACOMMENT = YES;
- // i++;
- // i++;
- // while (INACOMMENT == YES && array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // i++;
- // }
- // else if (array[i] == '*')
- // {
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // i++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // STAR = NO;
- // }
- // else
- // {
- // i++;
- // STAR = NO;
- // }
- // }
- // }
- // else
- // {
- // ;//NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
- // /*i++;
- // j++;*/
- // }
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // UNBALANCEDCOMMENT = NO;
- // }
- //
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- // else
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- //}
- //
- //void checkBrackets(char array[])
- //{
- // int i = 0;
- // int LeftBrackets = 0;
- // int RightBrackets = 0;
- // int EXTRALEFTBRACKETONLINE = 0;
- // int EXTRARIGHTBRACKETONLINE = 0;
- // int STAR = NO;
- // int UNBALANCEDCOMMENT = NO;
- // int INACOMMENT = NO;
- // int LINE = 0;
- // int INASINGLEQUOTE = NO;
- // int INADOUBLEQUOTE = NO;
- //
- // while (array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '[')
- // {
- // LeftBrackets++;
- // EXTRALEFTBRACKETONLINE = LINE;
- // i++;
- // if (LeftBrackets - RightBrackets > 1)
- // {
- // printf("Error: Uneven brackets. An extra [ was found on line %d.\n", EXTRALEFTBRACKETONLINE);
- // }
- // }
- // else if (array[i] == ']')
- // {
- // RightBrackets++;
- // EXTRARIGHTBRACKETONLINE = LINE;
- // i++;
- // if (RightBrackets - LeftBrackets > 0)
- // {
- // printf("Error: Uneven brackets. An extra ] was found on line %d.\n", EXTRARIGHTBRACKETONLINE);
- // }
- // }
- // else if (array[i] == '\'' && array[i - 1] != '\\') //wow '\\' is reading \' wow SO THE CODE READS ' and before that the last two characters are \\. cases like \"' work as expected before this fix. LATEST DEBUG 5:02 PM 11/20/2019
- // {
- // INASINGLEQUOTE = YES;
- // i++;
- //
- // while (INASINGLEQUOTE == YES && array[i] != '\n') //if hex number must be 0-9 A-F until a space is read.
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INASINGLEQUOTE == YES)
- // {
- // INASINGLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = YES;
- // i++;
- // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
- // {
- // if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INADOUBLEQUOTE == YES)
- // {
- // INADOUBLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '/') //3 CASES
- // {
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n')
- // {
- // i++;
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 3
- // {
- // UNBALANCEDCOMMENT = YES;
- // INACOMMENT = YES;
- // i++;
- // i++;
- // while (INACOMMENT == YES && array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // i++;
- // }
- // else if (array[i] == '*')
- // {
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // i++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // STAR = NO;
- // }
- // else
- // {
- // i++;
- // STAR = NO;
- // }
- // }
- // }
- // else
- // {
- // ; //NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
- // /*i++;
- // j++;*/
- // }
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // UNBALANCEDCOMMENT = NO;
- // }
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- // else
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // LeftBrackets = 0;
- // RightBrackets = 0;
- // }
- // i++;
- // }
- // }
- //}
- //
- //void checkParenthesis(char array[])
- //{
- // int i = 0;
- // int LeftParenthesis = 0;
- // int RightParenthesis = 0;
- // int EXTRALEFTPARENTHESISONLINE = 0;
- // int EXTRARIGHTPARENTHESISONLINE = 0;
- // int STAR = NO;
- // int UNBALANCEDCOMMENT = NO;
- // int INACOMMENT = NO;
- // int LINE = 0;
- // int INASINGLEQUOTE = NO;
- // int INADOUBLEQUOTE = NO;
- //
- // while (array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '(')
- // {
- // LeftParenthesis++;
- // EXTRALEFTPARENTHESISONLINE = LINE;
- //
- // i++;
- // }
- // else if (array[i] == ')')
- // {
- // RightParenthesis++;
- // EXTRARIGHTPARENTHESISONLINE = LINE;
- //
- // i++;
- // if (RightParenthesis > LeftParenthesis)
- // {
- // printf("Error: Uneven Right Parenthesis ). An extra ) was found on line %d.\n", EXTRARIGHTPARENTHESISONLINE);
- // }
- // }
- // else if (array[i] == '\'' && array[i - 1] != '\\') //wow '\\' is reading \' wow SO THE CODE READS ' and before that the last two characters are \\. cases like \"' work as expected before this fix. LATEST DEBUG 5:02 PM 11/20/2019
- // {
- // INASINGLEQUOTE = YES;
- // i++;
- //
- // while (INASINGLEQUOTE == YES && array[i] != '\n') //if hex number must be 0-9 A-F until a space is read.
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INASINGLEQUOTE == YES)
- // {
- // INASINGLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = YES;
- // i++;
- // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
- // {
- // if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INADOUBLEQUOTE == YES)
- // {
- // INADOUBLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '/') //3 CASES
- // {
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n')
- // {
- // i++;
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 3
- // {
- // UNBALANCEDCOMMENT = YES;
- // INACOMMENT = YES;
- // i++;
- // i++;
- // while (INACOMMENT == YES && array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // i++;
- // }
- // else if (array[i] == '*')
- // {
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // i++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // STAR = NO;
- // }
- // else
- // {
- // i++;
- // STAR = NO;
- // }
- // }
- // }
- // else
- // {
- // ; //NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
- // /*i++;
- // j++;*/
- // }
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // UNBALANCEDCOMMENT = NO;
- // }
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- // else
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // if (LeftParenthesis > RightParenthesis)
- // {
- // printf("Error: Uneven Left Parenthesis (. An extra ( was found on line %d.\n", EXTRALEFTPARENTHESISONLINE);
- // }
- // LeftParenthesis = 0;
- // RightParenthesis = 0;
- // }
- // i++;
- // }
- // }
- //}
- //
- //void checkBraces(char array[])
- //{
- // int i = 0;
- // int LeftBraces = 0;
- // int RightBraces = 0;
- // int EXTRALEFTBRACEONLINE = 0;
- // int EXTRARIGHTBRACEONLINE = 0;
- // int STAR = NO;
- // int UNBALANCEDCOMMENT = NO;
- // int INACOMMENT = NO;
- // int LINE = 0;
- // int INASINGLEQUOTE = NO;
- // int INADOUBLEQUOTE = NO;
- //
- // while (array[i] != '\0' && array[i] != EOF)
- // {
- // if (array[i] == '{')
- // {
- // LeftBraces++;
- // EXTRALEFTBRACEONLINE = LINE;
- // i++;
- // }
- // else if (array[i] == '}')
- // {
- // RightBraces++;
- // EXTRARIGHTBRACEONLINE = LINE;
- // i++;
- // if (RightBraces - LeftBraces > 0)
- // {
- // printf("Error: Uneven Right Braces. An extra } was found on line %d.\n", EXTRARIGHTBRACEONLINE);
- // }
- // }
- // else if (array[i] == '\'' && array[i - 1] != '\\') //wow '\\' is reading \' wow SO THE CODE READS ' and before that the last two characters are \\. cases like \"' work as expected before this fix. LATEST DEBUG 5:02 PM 11/20/2019
- // {
- // INASINGLEQUOTE = YES;
- // i++;
- //
- // while (INASINGLEQUOTE == YES && array[i] != '\n') //if hex number must be 0-9 A-F until a space is read.
- // {
- // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INASINGLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INASINGLEQUOTE == YES)
- // {
- // INASINGLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = YES;
- // i++;
- // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
- // {
- // if (array[i] == '"' && array[i - 1] != '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
- // {
- // INADOUBLEQUOTE = NO;
- // i++;
- // }
- // else
- // {
- // i++;
- // }
- // }
- // if (INADOUBLEQUOTE == YES)
- // {
- // INADOUBLEQUOTE = NO;
- // }
- // }
- // else if (array[i] == '/') //3 CASES
- // {
- // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
- //
- // if (array[i + 1] == '/') //CASE 4
- // {
- // UNBALANCEDCOMMENT = NO;
- // INACOMMENT = YES;
- // while (array[i] != '\n')
- // {
- // i++;
- // }
- // INACOMMENT = NO;
- // }
- //
- // else if (array[i + 1] == '*') //CASE 3
- // {
- // UNBALANCEDCOMMENT = YES;
- // INACOMMENT = YES;
- // i++;
- // i++;
- // while (INACOMMENT == YES && array[i] != '\0')
- // {
- // if (array[i] == '\n')
- // {
- // LINE++; //LINE COUNTER
- // i++;
- // }
- // else if (array[i] == '*')
- // {
- // i++;
- // STAR = YES;
- // }
- // else if (array[i] == '/' && STAR == YES)
- // {
- // i++;
- // INACOMMENT = NO;
- // UNBALANCEDCOMMENT = NO;
- // STAR = NO;
- // }
- // else
- // {
- // i++;
- // STAR = NO;
- // }
- // }
- // }
- // else
- // {
- // ; //NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
- // /*i++;
- // j++;*/
- // }
- // if (UNBALANCEDCOMMENT == YES) //CASE 1
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // UNBALANCEDCOMMENT = NO;
- // }
- // else if (UNBALANCEDCOMMENT == NO) //CASE 2
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- // else
- // {
- // if (array[i] == '\n')
- // {
- // LINE++;
- // }
- // i++;
- // }
- // }
- // if (LeftBraces > RightBraces)
- // {
- // printf("Error: Uneven amount of Left Braces {. An extra left brace ({) was found on line %d.\n", EXTRALEFTBRACEONLINE);
- // printf("Total number of extra left braces: %d\n", LeftBraces - RightBraces);
- // }
- //}
- //
- //main()
- //{
- /*unsigned int c = 0;
- c--;
- printf("%d", c);*/
- //unsigned int c = 1; //It's about the interpretation that printf gives to the parameter you pass.
- //while (c > 0)
- // c++;
- //c--;
- //printf("%d", c);
- //while (c > 0)
- // c++;
- //printf("%d", c); //It's about the interpretation that printf gives to the parameter you pass.
- //}
- //main()
- //{
- // unsigned char c = 0; //1 bytes 2^8 unsigned char is q byte on this machine
- // c--;
- // printf("%u", c);
- //}
- //main()
- //{
- // signed char c = 1; //1 bytes -2^7 to 2^7 - 1 signed char is q byte on this machine
- // while (c > 0)
- // c++;
- // c--;
- // printf("%c", c); //%c causes unexpected results //%c prints a character, not the decimal representation of an integer. If you want to print the decimal representation of an integer, use %d.
- // printf("\n");
- // printf("%d", c);
- //}
- //main()
- //{
- // unsigned int c = 0; //4 bytes 2^32 unsigned int is 4 bytes on this machine
- // c--;
- // printf("%u", c);
- //}
- //main()
- //{
- // signed int c = 1; //4 bytes -2^32 to 2^32 - 1 signed int is 4 bytes on this machine
- // while (c > 0)
- // c++;
- // c--;
- // printf("%d", c);
- //}
- //Experiment
- //Valuable result: unsigned and signed data type use the same number of bytes. The escape sequence %c prints out the character at the position of the numerical value in the character set of the system of the numerical value of the character passed to it.
- //main()
- //{
- // char zero = 0;
- // char A = 65;
- // printf("%c", zero); //prints NULL and not 0
- // printf("\n");
- // printf("%d", zero); //prints the decimal representation of an integer (char 0; a small integer)
- // printf("\n");
- // printf("%c", A); //prints A and not 65
- // printf("\n");
- // printf("%d", A); //prints the decimal representation of an integer (char 65; a small integer)
- //}
- //Experiment
- //Valueable result: character is a small integer. Use %c to print out the character represented by the numerical value in the character set of the computer of the numerical value of the character passed to it. Use %d to print out the decimal representation of an integer.
- //main()
- //{
- // char zero = 0;
- // char A = 65;
- // printf("%c %d\n", A - zero, A - zero);
- // printf("%c %d\n", A - 0, A - 0); //
- // printf("%c %d\n", A - '0', A - '0');
- // zero = '0';
- // A = 65;
- // printf("%c %d\n", A - zero, A - zero);
- // printf("%c %d\n", A - 0, A - 0); //
- // printf("%c %d\n", A - '0', A - '0');
- //}
- //Experiment
- //Valuable result: the integer 0 stored in variable character zero is different than the character 0 ('0') stored in the variable (character zero). The definition of the variable is directly related to the programs operation(s).
- //main()
- //{
- // char zero = getchar();
- // char A = 65;
- // printf("%c %d\n", A - zero, A - zero);
- // printf("%c %d\n", A - 0, A - 0); //
- // printf("%c %d\n", A - '0', A - '0');
- // zero = '0';
- // A = 65;
- // printf("%c %d\n", A - zero, A - zero);
- // printf("%c %d\n", A - 0, A - 0); //
- // printf("%c %d\n", A - '0', A - '0');
- //}
- //Experiment
- //Valueable result: getchar grabs '0' and '1' not integers 0 and 1. getchar() GRABS CHARACTERS AND NOT INTEGERS!
- //main()
- //{
- // char zero = getchar();
- // char A = 65;
- // printf("%c %d\n", A - (zero - '0'), A - (zero - '0'));
- // printf("%c %d\n", A - 0, A - 0); //
- // printf("%c %d\n", A - '0', A - '0');
- // zero = '0';
- // A = 65;
- // printf("%c %d\n", A - zero, A - zero);
- // printf("%c %d\n", A - 0, A - 0); //
- // printf("%c %d\n", A - '0', A - '0');
- //
- // printf("%c %d\n", A - (zero - '0'), A - (zero - '0'));
- // printf("%c %d\n", A - 0, A - 0);
- // printf("%c %d\n", A - '0', A - '0');
- //}
- //Experiment
- //Valueable result: arithmetic can be used to effectively produce integers from getchar(), like A - (zero - '0')
- //main()
- //{
- // char zero = getchar();
- // char A = 65;
- // printf("%c %d\n", A - (zero - '0'), A - (zero - '0'));
- // printf("%c %d\n", A - 0, A - 0); //
- // printf("%c %d\n", A - '0', A - '0');
- // zero = 'A';
- // A = 65;
- // printf("%c %d\n", A - zero, A - zero);
- // printf("%c %d\n", A - 0, A - 0); //
- // printf("%c %d\n", A - '0', A - '0');
- //}
- //Experiment
- //Valueable result: chacacter read by getchar display character that are defined by small integers and can be implemented into arithmetic
- //unsigned and signed short and long (int), float, double, and long double
- //main()
- //{
- // unsigned short int number = 1; //short is 2 bytes 2^16 = 65535
- // while (number > 0)
- // number++;
- // number--;
- // printf("%u", number);
- //}
- //main()
- //{
- // signed short int number = 1; //short is 2 bytes 2^16-1 to 2^16-1 - 1 = -32768 to 32767
- // while (number > 0)
- // number++;
- // number--;
- // printf("%d", number);
- //}
- //main()
- //{
- // unsigned long int number = 0; //long is 4 bytes 2^32 = 4.29e9
- // /*while (number > 0)
- // number++;*/
- // number--;
- // printf("%u", number);
- //}
- //main()
- //{
- // signed long int number = 1; //long is 4 bytes 2^32-1 = -4.29e9/2 to 4.29e9/2 - 1
- // while (number > 0)
- // number++;
- // //number--;
- // printf("%d", number);
- //}
- //main()
- //{
- // float number = 1;
- // while (number > 0)
- // number++;
- // number--;
- // printf("%f", number);
- //}
- //Valuable result: float does not wrap it goes to infinity. #define FLT_MAX 3.402823466e+38F // max value #define FLT_MIN 1.175494351e-38F // min normalized positive value
- //main()
- //{
- // double number = 99999.1;
- // while (number > 0)
- // {
- // number++;
- // printf("%f\n", number); //fixed.point notation infinity and nan
- // printf("%e\n", number); //standard form e+00
- // printf("%g\n", number); //Normal or exponent notation, whichever is more appropriate. Differs from fixed-point notation in that significant zeroes to the right of the decimal point are not included
- // printf("%F\n", number); //FIXED.POINT NOTATION INFINITY AND NAN
- // printf("%E\n", number); //standard form E+00
- // printf("%G\n", number); ////Normal or exponent notation, uses uppercase letters, whichever is more appropriate. Differs from fixed-point notation in that significant zeroes to the right of the decimal point are not included
- // printf("-\n");
- //
- // /*
- // 1000000.100000
- // 1.000000e+06
- // 1e+06
- // 1000000.100000
- // 1.000000E+06
- // 1E+06
- // -
- // */
- //
- // /*
- // 100000.100000
- // 1.000001e+05
- // 100000
- // 100000.100000
- // 1.000001E+05
- // 100000
- // -
- // */
- // }
- //}
- //Valuable result: double does not wrap it goes to infinity. more of inf and nan support later. #define DBL_MAX 1.7976931348623158e+308 // max value #define DBL_MIN 2.2250738585072014e-308 // min positive value
- //main()
- //{
- // long double number = 99999.1;
- // while (number > 0)
- // {
- // number++;
- // printf("%f\n", number); //fixed.point notation infinity and nan
- // printf("%e\n", number); //standard form e+00
- // printf("%g\n", number); //Normal or exponent notation, whichever is more appropriate. Differs from fixed-point notation in that significant zeroes to the right of the decimal point are not included
- // printf("%F\n", number); //FIXED.POINT NOTATION INFINITY AND NAN
- // printf("%E\n", number); //standard form E+00
- // printf("%G\n", number); ////Normal or exponent notation, uses uppercase letters, whichever is more appropriate. Differs from fixed-point notation in that significant zeroes to the right of the decimal point are not included
- // printf("-\n");
- //
- // /*
- // 1000000.100000
- // 1.000000e+06
- // 1e+06
- // 1000000.100000
- // 1.000000E+06
- // 1E+06
- // -
- // */
- //
- // /*
- // 100000.100000
- // 1.000001e+05
- // 100000
- // 100000.100000
- // 1.000001E+05
- // 100000
- // -
- // */
- // //NOT DIFFERENT FROM DOUBLE
- // }
- //}
- //Valuable result: long double does not wrap it goes to infinity, more on INF and NAN support later #define LDBL_MAX DBL_MAX // max value #define LDBL_MIN DBL_MIN // min normalized positive value
- //Experiment: Changing the maximum and minimum of long double in <float.h>. Thought: 12/1/2019 Tested: not yet
- //main()
- //{
- // float number = 999999.1;
- // while (number > 0)
- // {
- // number++;
- // printf("%f\n", number); //fixed.point notation infinity and nan
- // printf("%e\n", number); //standard form e+00
- // printf("%g\n", number); //Normal or exponent notation, whichever is more appropriate. Differs from fixed-point notation in that significant zeroes to the right of the decimal point are not included
- // printf("%F\n", number); //FIXED.POINT NOTATION INFINITY AND NAN
- // printf("%E\n", number); //standard form E+00
- // printf("%G\n", number); ////Normal or exponent notation, uses uppercase letters, whichever is more appropriate. Differs from fixed-point notation in that significant zeroes to the right of the decimal point are not included
- // printf("-\n");
- //
- // /*
- // 1000000.125000
- // 1.000000e+06
- // 1e+06
- // 1000000.125000
- // 1.000000E+06
- // 1E+06
- // -
- // */
- //
- // /*
- // 100000.101563
- // 1.000001e+05
- // 100000
- // 100000.101563
- // 1.000001E+05
- // 100000
- // -
- // */
- // //DIFFERENT THAN DOUBLE AND LONG DOUBLE IN BOTH 99999.1 + 1 and 999999.1
- // }
- //}
- //
- //main()
- //{
- // float fnumber1 = 99999.1;
- // double dnumber1 = 99999.1;
- // long double ldnumber1 = 99999.1;
- //
- // float fnumber2 = 999999.1;
- // double dnumber2 = 999999.1;
- // long double ldnumber2 = 999999.1;
- //
- // int i = 0;
- // printf("%18d+1%18d+1\n", 99999, 999999);
- // while (i < 1) //Float
- // {
- // printf("Float\n");
- // fnumber1++;
- // fnumber2++;
- // i++;
- // printf("%20f%20f\n\n", fnumber1, fnumber2);
- // printf("%20e%20e\n\n", fnumber1, fnumber2);
- // printf("%20g%20g\n\n", fnumber1, fnumber2);
- // printf("%20F%20F\n\n", fnumber1, fnumber2);
- // printf("%20E%20E\n\n", fnumber1, fnumber2);
- // printf("%20G%20G\n\n", fnumber1, fnumber2);
- // printf("\n");
- // }
- // i = 0;
- //
- // while (i < 1) //Double
- // {
- // printf("Double\n");
- // dnumber1++;
- // dnumber2++;
- // i++;
- // printf("%20f%20f\n\n", dnumber1, dnumber2);
- // printf("%20e%20e\n\n", dnumber1, dnumber2);
- // printf("%20g%20g\n\n", dnumber1, dnumber2);
- // printf("%20F%20F\n\n", dnumber1, dnumber2);
- // printf("%20E%20E\n\n", dnumber1, dnumber2);
- // printf("%20G%20G\n\n", dnumber1, dnumber2);
- // printf("\n");
- // }
- // i = 0;
- //
- // while (i < 1) //Long Double
- // {
- // printf("Long Double\n");
- // ldnumber1++;
- // ldnumber2++;
- // i++;
- // printf("%20f%20f\n\n", ldnumber1, ldnumber2);
- // printf("%20e%20e\n\n", ldnumber1, ldnumber2);
- // printf("%20g%20g\n\n", ldnumber1, ldnumber2);
- // printf("%20F%20F\n\n", ldnumber1, ldnumber2);
- // printf("%20E%20E\n\n", ldnumber1, ldnumber2);
- // printf("%20G%20G\n\n", ldnumber1, ldnumber2);
- // printf("\n");
- // }
- //}
- //The % operator determines what is printed and how it is printed while the variable is unaffected. The float data type output variance is because
- //Valuable result: truncation occurs from double to float and long double to float
- //Valuable result: exponent notation (%g and %G) begins at 1,000,000
- //Valuable results: char 1 byte, short 2 bytes, int 4 bytes, long 4 bytes, float 4 bytes 6 decimal places, double 8 bytes 15 decimal places, long double 10 bytes 19 decimal places on other computers but it is 8 bytes 15 decimal places on my computer
- //https://www.tutorialspoint.com/cprogramming/c_data_types.htm
- //https://en.wikipedia.org/wiki/Printf_format_string
- //Experiment: Changing the maximum and minimum of long double in <float.h>. Thought: 12/1/2019 Tested: not yet
- //main()
- //{
- // printf("unsigned char: %u to %u\n", 0, UCHAR_MAX);
- // printf("signed char: %d to %d\n", SCHAR_MIN, SCHAR_MAX);
- // printf("char: %d to %d\n", CHAR_MIN, CHAR_MAX);
- //
- // printf("unsigned short int: %u to %u\n", 0, USHRT_MAX);
- // printf("signed short int: %d to %d\n", SHRT_MIN, SHRT_MAX); //signed short
- // printf("short: %d to %d\n", SHRT_MIN, SHRT_MAX); //short are the same
- //
- // printf("unsigned int: %u to %u\n", 0, UINT_MAX);
- // printf("signed int: %d to %d\n", INT_MIN, INT_MAX); //signed int
- // printf("int: %d to %d\n", INT_MIN, INT_MAX); //int are the same
- //
- // printf("unsigned long int: %u to %u\n", 0, ULONG_MAX);
- // printf("signed long int: %d to %d\n", LONG_MIN, LONG_MAX); //signed long
- // printf("long: %d to %d\n", LONG_MIN, LONG_MAX); //long are the same
- //
- // printf("unsigned long long int: %llu to %llu\n", 0, ULLONG_MAX);
- // printf("signed long long int: %lld to %lld\n", LLONG_MIN, LLONG_MAX); //signed long long
- // printf("long long: %lld to %lld\n", LLONG_MIN, LLONG_MAX); //long long are the same
- //
- // printf("float: %G to %G\n", FLT_MIN, FLT_MAX);
- //
- // printf("double: %G to %G\n", DBL_MIN, DBL_MAX);
- //
- // printf("long double: %G to %G\n", LDBL_MIN, LDBL_MAX);
- //
- // //limits.h includes number of bits, number of bytes in multibyte char, range for 8-bit/16-bit/32-bit/64-bit/128-bit values
- // /*
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4863,9): warning C4477: 'printf' : format string '%u' requires an argument of type 'unsigned int', but variadic argument 2 has type 'unsigned __int64'
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4863,9): message : consider using '%llu' in the format string
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4863,9): message : consider using '%I64u' in the format string
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4864,9): warning C4477: 'printf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type '__int64'
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4864,9): message : consider using '%lld' in the format string
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4864,9): message : consider using '%I64d' in the format string
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4864,9): warning C4477: 'printf' : format string '%d' requires an argument of type 'int', but variadic argument 2 has type '__int64'
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4864,9): message : consider using '%lld' in the format string
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4864,9): message : consider using '%I64d' in the format string
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4865,9): warning C4477: 'printf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type '__int64'
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4865,9): message : consider using '%lld' in the format string
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4865,9): message : consider using '%I64d' in the format string
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4865,9): warning C4477: 'printf' : format string '%d' requires an argument of type 'int', but variadic argument 2 has type '__int64'
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4865,9): message : consider using '%lld' in the format string
- // 1>C:\Users\funca\source\repos\C\P1\P1.c(4865,9): message : consider using '%I64d' in the format string
- // */
- //
- // /*
- // unsigned char: 0 to 255
- // signed char: -128 to 127
- // char: -128 to 127
- // unsigned short int: 0 to 65535
- // signed short int: -32768 to 32767
- // short: -32768 to 32767
- // unsigned int: 0 to 4294967295
- // signed int: -2147483648 to 2147483647
- // int: -2147483648 to 2147483647
- // unsigned long int: 0 to 4294967295
- // signed long int: -2147483648 to 2147483647
- // long: -2147483648 to 2147483647
- // unsigned long long int: 18446744069414584320 to 27887162523385855
- // signed long long int: -9223372036854775808 to 9223372036854775807
- // long long: -9223372036854775808 to 9223372036854775807
- // float: 1.17549E-38 to 3.40282E+38
- // double: 2.22507E-308 to 1.79769E+308
- // long double: 2.22507E-308 to 1.79769E+308
- // */
- //}
- //
- //main()
- //{
- // int c;
- // int lim;
- // char line[40];
- // int i = 0;
- // for (lim = 0; lim < 100; lim++)
- // {
- // if ((c = getchar()) != '\n')
- // {
- // if (c != EOF)
- // line[i++] = c;
- // }
- // }
- //}
- //int htoi(char array[])
- //{
- // int c;
- // int i;
- // int n;
- // int pp;
- // for (i = 0; isdigit(array[i]) || array[i] >= 'A' && array[i] <= 'Z' || array[i] >= 'a' && array[i] <= 'z'; i++)
- // {
- // if (isdigit(array[i]))
- // pp = array[i] - '0';
- // else if (array[i] == 'A' || array[i] == 'a')
- // pp = 10;
- // else if (array[i] == 'B' || array[i] == 'b')
- // pp = 11;
- // else if (array[i] == 'C' || array[i] == 'c')
- // pp = 12;
- // else if (array[i] == 'D' || array[i] == 'd')
- // pp = 13;
- // else if (array[i] == 'E' || array[i] == 'e')
- // pp = 14;
- // else if (array[i] == 'F' || array[i] == 'f')
- // pp = 15;
- // n = n * 10 + pp;
- // if (i == 0 && array[i] == '0')
- // {
- // i = 3;
- // n = 0;
- // }
- // return n;
- // }
- //}
- //void squeezedelete(char s1[], char s2[])
- //{
- // int i = 0;
- // int j;
- // int k = 0;
- // while (s1[i] != '\0')
- // {
- // j = 0;
- // while (s2[j] != '\0' && s1[i] != s2[j])
- // {
- // if (s2[j+1] == '\0')
- // {
- // s1[k++] = s1[i];
- // }
- // j++;
- // }
- // i++;
- // }
- //}
- //void firstcommoncharacter(char s1[], char s2[])
- //{
- // int i;
- // int j;
- // int fcci = 0;
- //
- // while (s1[i] != '\0')
- // {
- // j = 0;
- // while (s2[j++] != '\0')
- // {
- // if (s1[i] == s2[j])
- // {
- // return ++fcci;
- // }
- // fcci++;
- // }
- // if (s1[i + 1] == '\0')
- // return -1;
- // i++;
- // }
- //}
- //unsigned setbits(unsigned x, int p, int n, unsigned y) //signed instead of unsigned for sign bit sign extension p.50
- //{
- // return ((x >> (p + 1 - n)) & (y & ~(~0 << n));
- //}
- //unsigned invert(unsigned x, int p, int n) //signed instead of unsigned for sign bit sign extension p.50
- //{
- // return x ^ ((~0 << p + 1 - n) >> n - 1); //arithmetic right shift, sign extension vital
- //}
- //unsigned rightrot(unsigned x, int n) //signed instead of unsigned for sign bit sign extension p.50
- //{
- // unsigned x2 = x;
- // int size = bitsize(x); //function bitsize counts the number of bits in x. Example x = 0000 returns 4.
- // return (x >> n) | ((~0 << size - 1) & (x2 << size - n));
- //}
- //unsigned bitcount_Faster(unsigned x)
- //{
- // return ~(x - 1);
- //}
- //void lower(char array[])
- //{
- // int i = 0;
- // while (array[i] != '\0')
- // {
- // array[i] = (array[i] >= 'A' || array[i] <= 'Z') ? array[i] + 'a' - 'A' : array[i];
- // i++;
- // }
- //}
- //int binsearch(int x, char array[], int bottom, int top)
- //{
- // int low = bottom;
- // int high = top - 1;
- // int middle = (high + low) / 2;
- //
- // while (x != array[middle] && (high + middle) / 2 != middle && (low + middle) / 2 != middle)
- // {
- // if (x > array[middle])
- // middle = (high + middle) / 2;
- // else
- // middle = (low + middle) / 2;
- // }
- // if (x == array[middle])
- // return middle;
- // else
- // return -1;
- //} //did not run them next to eachother was not interested in that moment
- //void escape(char s[], char t[])
- //{
- // int i = 0;
- // int j = 0;
- // while (s[i] != '\0')
- // {
- // switch (s[i])
- // {
- // case '\n':
- // t[j] = '\\';
- // j++;
- // t[j] = 'n';
- // i++;
- // break;
- // case '\t':
- // t[j] = '\\';
- // j++;
- // t[j] = 't';
- // i++;
- // break;
- // default:
- // t[j] = s[i];
- // j++;
- // i++;
- // break;
- // }
- // }
- //}
- //void escapereversed(char s[], char t[])
- //{
- // int i = 0;
- // int j = 0;
- // while (s[i] != '\0')
- // {
- // switch (s[i])
- // {
- // case ('\\'):
- // if (s[i + 1] == 'n')
- // {
- // t[j] = '\n';
- // j++;
- // i++;
- // break;
- // }
- // else if (s[i + 1] == 't')
- // {
- // t[j] = '\t';
- // j++;
- // i++;
- // break;
- // }
- // else
- // {
- // t[j] = s[i];
- // j++;
- // i++;
- // break;
- // }
- // default:
- // t[j] = s[i];
- // j++;
- // i++;
- // break;
- // }
- // }
- //}
- //https://www.youtube.com/watch?v=qzXAVXddcPU
- //void expand(char s1[], char s2[]);
- //
- //main()
- //{
- // int c;
- // int i = 0;
- // char s1[MAXARRAYSIZE];
- // char s2[MAXARRAYSIZE];
- // while ((c = getchar()) != EOF)
- // s1[i++] = c;
- // s1[i] = '\0';
- // expand(s1, s2);
- // printf("%s", s2);
- //}
- //
- //void expand(char s1[], char s2[])
- //{
- // int INALETTEREXPANSION = NO;
- // int INANUMBEREXPANSION = NO;
- // int i = 0;
- // int k;
- // int j = 0;
- // int nc = 0;
- // int valk;
- // int vali;
- // int inc;
- // while (s1[i] != '\0' && s1[i] != EOF)
- // {
- // switch (s1[i])
- // {
- // case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
- // case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
- // if (!INALETTEREXPANSION)
- // {
- // s2[j++] = s1[i];
- // INALETTEREXPANSION = YES;
- // }
- // k = i + 1;
- // nc = 1;
- // while (!isalnum(s1[k]) && s1[k] != '-' && s1[k] != '\0' && s1[k] != EOF)
- // nc++, k++;
- // if (isdigit(s1[k]))
- // {
- // INALETTEREXPANSION = NO;
- // i++;
- // }
- // else if (s1[k] == '-')
- // {
- // nc++, k++;
- // while (!isalnum(s1[k]) && s1[k] != '\0' && s1[k] != EOF)
- // nc++, k++;
- // if (isalpha(s1[k]) && s1[k] > s1[i])
- // {
- // valk = s1[k];
- // vali = s1[i];
- // inc = 1;
- // while (valk-- > vali)
- // {
- // s2[j++] = s1[i] + inc++;
- // }
- // i += nc;
- // INALETTEREXPANSION = YES;
- // }
- // else if (isalpha(s1[k]) && s1[k] < s1[i])
- // {
- // valk = s1[k];
- // vali = s1[i];
- // inc = 1;
- // while (valk++ < vali)
- // {
- // s2[j++] = s1[i] - inc++;
- // }
- // i += nc;
- // INALETTEREXPANSION = YES;
- // }
- // else if (isalpha(s1[k]) && s1[k] == s1[i])
- // {
- // s2[j++] = s1[i];
- // i += nc;
- // }
- // else
- // {
- // s2[j++] = '-';
- // i += nc;
- // INALETTEREXPANSION = NO;
- // }
- // }
- // else if (isalpha(s1[k]))
- // {
- // INALETTEREXPANSION = NO;
- // i += nc;
- // }
- // else
- // i++;
- // break;
- // case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
- // if (!INANUMBEREXPANSION)
- // {
- // s2[j++] = s1[i];
- // INANUMBEREXPANSION = YES;
- // }
- // k = i + 1;
- // nc = 1;
- // while (!isalnum(s1[k]) && s1[k] != '-' && s1[k] != '\0' && s1[k] != EOF)
- // nc++, k++;
- // if (isalpha(s1[k]))
- // {
- // INANUMBEREXPANSION = NO;
- // i++;
- // }
- // else if (s1[k] == '-')
- // {
- // nc++, k++;
- // while (!isalnum(s1[k]) && s1[k] != '\0' && s1[k] != EOF)
- // nc++, k++;
- // if (isdigit(s1[k]) && s1[k] > s1[i])
- // {
- // valk = s1[k];
- // vali = s1[i];
- // inc = 1;
- // while (valk-- > vali)
- // {
- // s2[j++] = s1[i] + inc++;
- // }
- // i += nc;
- // INANUMBEREXPANSION = YES;
- // }
- // else if (isdigit(s1[k]) && s1[k] < s1[i])
- // {
- // valk = s1[k];
- // vali = s1[i];
- // inc = 1;
- // while (valk++ < vali)
- // {
- // s2[j++] = s1[i] - inc++;
- // }
- // i += nc;
- // INANUMBEREXPANSION = YES;
- // }
- // else if (isdigit(s1[k]) && s1[k] == s1[i])
- // {
- // s2[j++] = s1[i];
- // i += nc;
- // }
- // else
- // {
- // s2[j++] = '-';
- // i += nc;
- // INANUMBEREXPANSION = NO;
- // }
- // }
- // else if (isalpha(s1[k]))
- // {
- // INANUMBEREXPANSION = NO;
- // i += nc;
- // }
- // else
- // i++;
- // break;
- // default:
- // s2[j++] = s1[i++];
- // break;
- // }
- // }
- // s2[j] = '\0';
- //}
- //void reverse(char s[])
- //{
- // char temp[MAXARRAYSIZE];
- // int i = 0;
- // int j = 0;
- // int pointofreverse = 0;
- //
- // while (s[i] != '\0')
- // {
- // while (s[i] != '\n' && s[i] != '\0')
- // {
- // i++;
- // }
- // pointofreverse = i - 1;
- // while (j < i)
- // {
- // temp[j++] = s[pointofreverse--];
- // }
- // temp[j] = s[i++];
- // }
- // temp[j] = '\0';
- // s = temp; //new reverse on 5373
- //}
- //The problem is that, if n is the largest negative number, when you do n = -n you obtain 0, bacause you cannot represent a positive number that big.
- //A solution can be to hold the positive number in a long integer.
- //Learned ints are stored using binary number representation systems 127 = 01111111 -128 = 10000000. char is a int (56) representing a character 'A
- //void itoa(int n, char s[])
- //{
- // int i;
- // int sign;
- // long long int holdthepositivenumber;
- // if ((sign = n) < 0)
- // holdthepositivenumber = -n; //n = -n;
- // i = 0;
- // do {
- // s[i++] = n % 10 + '0';
- // } while ((n /= 10) > 0);
- // if (sign < 0)
- // s[i++] = '-';
- // s[i] = '\0';
- // reverse(s);
- //}
- //void reverse(char s[]);
- //void itob(int n, char s[], int b);
- //int atoi(char s[]);
- //main()
- //{
- // int c;
- // char anumber[MAXARRAYSIZE];
- // int number;
- // int i = 0;
- // int base;
- // while ((c = getchar()) != '\n')
- // anumber[i++] = c;
- // anumber[i] = '\0', printf("%s\n", anumber);
- // number = atoi(anumber), printf("%d\n", number);
- // i = 0, anumber[0] = '\0';
- // while ((c = getchar()) != '\n')
- // anumber[i++] = c;
- // anumber[i] = '\0', printf("%s\n", anumber);
- // base = atoi(anumber), printf("%d\n", base);
- // anumber[0] = '\0', itob(number, anumber, base), printf("%s\n", anumber);
- //}
- //void itob(int n, char s[], int b)
- //{
- // int i = 0;
- // int nrc;
- // while (n > 0)
- // {
- // if ((nrc = n % b) >= 10)
- // s[i++] = (char) (nrc + 55);
- // else
- // s[i++] = (char) (nrc + '0');
- // n /= b;
- // }
- // s[i] = '\0';
- // reverse(s);
- //}
- //void reverse(char s[])
- //{
- // char temp[MAXARRAYSIZE];
- // int i = 0;
- // int j = 0;
- // int pointofreverse = 0;
- // while (s[i] != '\0' && s[i] != EOF)
- // {
- // while (s[i] != '\n' && s[i] != '\0' && s[i] != EOF)
- // i++;
- // pointofreverse = i - 1;
- // while (j < i)
- // temp[j++] = s[pointofreverse--];
- // temp[j++] = s[i];
- // if (s[i] != '\0')
- // i++;
- // }
- // temp[j] = '\0';
- // i = 0;
- // while ((s[i] = temp[i]) != '\0')
- // i++;
- //}
- //int atoi(char s[])
- //{
- // int sign;
- // int i = 0;
- // int n = 0;
- // if (s[i] == '-')
- // {
- // sign = YES;
- // i++;
- // }
- // while (s[i] != '\0')
- // n = n * 10 + (s[i++] - '0');
- // return n;
- //}
- //void reverse(char s[]);
- //main()
- //{
- // int c;
- // int i = 0;
- // char array[MAXARRAYSIZE];
- // while ((c = getchar()) != '!')
- // array[i++] = c;
- // array[i] = '\0';
- // reverse(array);
- // printf("%s", array);
- //}
- //void reverse(char s[])
- //{
- // char temp[MAXARRAYSIZE];
- // int i = 0;
- // int j = 0;
- // int pointofreverse = 0;
- // while (s[i] != '\0' && s[i] != EOF)
- // {
- // while (s[i] != '\n' && s[i] != '\0' && s[i] != EOF)
- // i++;
- // pointofreverse = i - 1;
- // while (j < i)
- // temp[j++] = s[pointofreverse--];
- // temp[j++] = s[i];
- // if (s[i] != '\0')
- // i++;
- // }
- // temp[j] = '\0';
- // i = 0;
- // while ((s[i] = temp[i]) != '\0')
- // i++;
- //}
- //void itoawithpadding(int n, char s[], int padding)
- //{
- // long long int carefulconversion;
- // int sign = NO;
- // int i = 0;
- // if (n < 0)
- // {
- // n = -n;
- // sign = YES;
- // padding = padding - 1;
- // }
- // while (n > 0)
- // {
- // s[i++] = n % 10;
- // n /= 10;
- // padding--;
- // }
- // s[i++] = '-';
- // while (padding-- > 0)
- // {
- // s[i++] = ' ';
- // }
- // s[i] = '\0'; //this one character more than the minimum width padding
- // reverse(s);
- //}
Advertisement
Add Comment
Please, Sign In to add comment