rmoronsv

Untitled

Dec 19th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 124.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <float.h>
  3. #include <limits.h>
  4. #include <conio.h>
  5. #include <ctype.h>
  6. #include <string.h>
  7. #include <math.h>
  8.  
  9. //main()
  10. //{
  11. // printf("hello ");
  12. // printf("world");
  13. // printf("\n");
  14. // printf("\f");
  15. //
  16. //}
  17.  
  18. //main()
  19. //{
  20. // float fahr, celcius;
  21. // int lower, upper, step;
  22. //
  23. // lower = 0;
  24. // upper = 300;
  25. // step = 20;
  26. //
  27. // fahr = lower;
  28. //
  29. // printf("Fahrenheit\tCelcius\n");
  30. // while (fahr <= upper)
  31. // {
  32. // celcius = (5.0 / 9.0) * (fahr - 32.0); //5.0 for floating point number arithmetic
  33. // printf("%10.0f %12.1f\n", fahr, celcius);
  34. // fahr = fahr + step;
  35. // }
  36. // printf("\n\n\n\n\n\n\n\n\n\n\n");
  37. //}
  38.  
  39. //main()
  40. //{
  41. // float fahr, celcius;
  42. // int lower, upper, step;
  43. //
  44. // lower = 0;
  45. // upper = 300;
  46. // step = 20;
  47. //
  48. // celcius = lower;
  49. //
  50. // printf("Celcius \tFahrenheit\n");
  51. // while (celcius <= upper)
  52. // {
  53. // fahr = ((9.0 / 5.0) * (celcius)) + 32.0; //5.0 for floating point number arithmetic
  54. // printf("%7.0f %18.1f\n", celcius, fahr);
  55. // celcius = celcius + step;
  56. // }
  57. // printf("\n\n\n\n\n\n\n\n\n\n\n");
  58. //}
  59.  
  60. //main()
  61. //{
  62. // float fahr, celcius;
  63. // int lower, upper, step;
  64. //
  65. // lower = 0;
  66. // upper = 300;
  67. // step = 20;
  68. //
  69. // celcius = upper;
  70. //
  71. // printf("Celcius \tFahrenheit\n");
  72. // while (celcius >= lower)
  73. // {
  74. // fahr = ((9.0 / 5.0) * (celcius)) + 32.0; //5.0 for floating point number arithmetic
  75. // printf("%7.0f %18.1f\n", celcius, fahr);
  76. // celcius = celcius - step;
  77. // }
  78. // printf("\n\n\n\n\n\n\n\n\n\n\n");
  79. //}
  80.  
  81. //main()
  82. //{
  83. // int c;
  84. // while (c = (getchar() != EOF))
  85. // {
  86. // printf("%d\n", c);
  87. // }
  88. // printf("%d", c);
  89. //}
  90.  
  91. //#define BUFSIZE 100
  92. //char buf[BUFSIZE];
  93. //int bufp = 0;
  94. //
  95. //main()
  96. //{
  97. // int getch(void);
  98. // void ungetch(int);
  99. // int c;
  100. //
  101. // Start:
  102. // while (c = (getch() != EOF))
  103. // {
  104. // ungetch(); //c is 1, it returns a 1 to buf.
  105. // if (c = (getch() != '\n'))
  106. // {
  107. // ungetch(c);
  108. // if (c = (getch() != ' '))
  109. // {
  110. // printf("%d\n", c);
  111. // }
  112. // else
  113. // {
  114. // printf("skipped: <-\n");
  115. // }
  116. // }
  117. // else
  118. // {
  119. // printf("skipped: \\n <-\n");
  120. // }
  121. // }
  122. // printf("%d", c);
  123. // goto Start;
  124. //}
  125. //
  126. //int getch(void)
  127. //{
  128. // return (bufp > 0) ? buf[--bufp] : getchar();
  129. //}
  130. //void ungetch(int c)
  131. //{
  132. // if (bufp >= BUFSIZE) printf("ungetch: too many characters\n");
  133. // else
  134. // buf[bufp++] = c;
  135. //}
  136.  
  137. //main()
  138. //{
  139. // int c;
  140. //
  141. // if (c = (getchar() != EOF))
  142. // {
  143. // printf("if loop executed so c was 1 because getchar() was 1.\n");
  144. // printf("value of getchar(): %d\n\n", c);
  145. // }
  146. // else
  147. // {
  148. // printf("if loop exited so c was 0 because getchar() was 0.\n");
  149. // printf("value of getchar(): %d", c);
  150. // }
  151. //}
  152.  
  153. //main()
  154. //{
  155. // int c = EOF;
  156. // printf("%d\n", c);
  157. //}
  158.  
  159. //main()
  160. //{
  161. // int c;
  162. // int NumberOfNewLines = 0;
  163. // int NumberOfTabs = 0;
  164. // int NumberOfSpaces = 0;
  165. //
  166. //
  167. // while ((c = getchar()) != EOF)
  168. // {
  169. // if (c == '\n')
  170. // {
  171. // NumberOfNewLines++;
  172. // }
  173. // else if (c == '\t')
  174. // {
  175. // NumberOfTabs++;
  176. // }
  177. // else if (c == ' ')
  178. // {
  179. // NumberOfSpaces++;
  180. // }
  181. // }
  182. //
  183. // printf("Number of New Lines: %d\nNumber of Tabs: %d\nNumber of Spaces: %d\n", NumberOfNewLines, NumberOfTabs, NumberOfSpaces);
  184. //}
  185.  
  186. //main()
  187. //{
  188. // int c;
  189. // int OneSpaceRead = 0;
  190. //
  191. // while ((c = getchar()) != EOF)
  192. // {
  193. // if (c != ' ')
  194. // {
  195. // putchar(c);
  196. // OneSpaceRead = 0;
  197. // }
  198. // else if (c == ' ' && OneSpaceRead == 0)
  199. // {
  200. // putchar(c);
  201. // OneSpaceRead = 1;
  202. // }
  203. // }
  204. //}
  205.  
  206.  
  207. //main()
  208. //{
  209. // int c;
  210. //
  211. // while ((c = getchar()) != EOF)
  212. // {
  213. // if (c != '\n' && c != '\b' && c != '\t')
  214. // putchar(c);
  215. // else if (c == '\n')
  216. // {
  217. // printf("\\n");
  218. // }
  219. // else if (c == '\t')
  220. // {
  221. // printf("\\t");
  222. // }
  223. // else if (c == '\\')
  224. // {
  225. // printf("\\");
  226. // }
  227. // else if (c == '\b')
  228. // {
  229. // printf("backspace");
  230. // }
  231. // }
  232. //}
  233.  
  234. //main()
  235. //{
  236. // int c;
  237. // int InAWord = 0;
  238. //
  239. // printf("This program prints out every word and spacebar on an individual line.");
  240. //
  241. // while ((c = getchar()) != EOF)
  242. // {
  243. // if (c != ' ' && c != '\n')
  244. // {
  245. // putchar(c);
  246. // InAWord = 1;
  247. // }
  248. // if (c == ' ')
  249. // {
  250. // if (InAWord == 1)
  251. // {
  252. // printf("\n");
  253. // putchar(c);
  254. // printf("\n");
  255. // InAWord = 0;
  256. // }
  257. // else if (InAWord == 0)
  258. // {
  259. // putchar(c);
  260. // printf("\n");
  261. // }
  262. // }
  263. // if (c == '\n')
  264. // {
  265. // putchar(c);
  266. // }
  267. // }
  268. //}
  269.  
  270.  
  271. //main()
  272. //{
  273. // #define parameter 100
  274. // int c;
  275. // int NumberOfLetters[parameter];
  276. // int NumberOfLettersIndex = 0;
  277. //
  278. // int i = 0;
  279. // int indexForNumberOfLettersArray = 0;
  280. //
  281. // for (i = 0; i < parameter; i++)
  282. // {
  283. // NumberOfLetters[i] = 0;
  284. // }
  285. //
  286. // while ((c = getchar()) != EOF && c != '\n')
  287. // {
  288. // if (c != ' ' && c != '\n')
  289. // {
  290. // NumberOfLetters[NumberOfLettersIndex]++;
  291. // }
  292. // if (c == ' ')
  293. // {
  294. // NumberOfLettersIndex++;
  295. // NumberOfLetters[NumberOfLettersIndex]++;
  296. // NumberOfLettersIndex++;
  297. // }
  298. // }
  299. //
  300. // for (i = 0; i < parameter; i = i + 1)
  301. // {
  302. // if ((NumberOfLetters[i]) > 0)
  303. // {
  304. // while ((NumberOfLetters[i]) > 0)
  305. // {
  306. // printf("*");
  307. // NumberOfLetters[i]--;
  308. // }
  309. // printf("\n");
  310. // }
  311. // else if ((NumberOfLetters[i]) == 0)
  312. // break;
  313. // }
  314. //}
  315.  
  316. //#define MAXSIZE 100
  317. //#define IN 1
  318. //#define OUT 0
  319. //
  320. //main()
  321. //{
  322. // int c;
  323. // int MAXLETTERCOUNT = 0;
  324. // int WORDCOUNT = 0;
  325. // int i = 0;
  326. // int j;
  327. // int Array[MAXSIZE];
  328. // int State = OUT; //flag for whether in word or not
  329. // int Max[MAXSIZE];
  330. //
  331. // for (i = 0; i < MAXSIZE; i++) //i < MAXSIZE
  332. // {
  333. // Array[i] = 0;
  334. // Max[i] = 1;
  335. // }
  336. //
  337. // i = 0;//
  338. //
  339. // while ((c = getchar()) != EOF)
  340. // {
  341. // if (isalpha(c)) //isalphanumerical
  342. // {
  343. // State = IN;
  344. // Array[i]++;
  345. // Max[i]++;
  346. // if (Array[i] >= MAXLETTERCOUNT)
  347. // {
  348. // MAXLETTERCOUNT = Array[i];
  349. // }
  350. // }
  351. // else if (State == IN && (c == ' ' || c == '\t' || c == '\n'))
  352. // {
  353. // WORDCOUNT++;
  354. // i++;
  355. // State = OUT;
  356. // }
  357. // else
  358. // continue;
  359. // }
  360. //
  361. // for (i = MAXLETTERCOUNT + 1; i > 0; i--)
  362. // {
  363. // for (j = 0; j < WORDCOUNT; j++)
  364. // {
  365. // if (Max[j] == i)
  366. // {
  367. // printf("%5d", Max[j] - 1);
  368. // }
  369. // else if (Array[j] == i)
  370. // {
  371. // printf(" *");
  372. // Array[j]--;
  373. // }
  374. // else
  375. // {
  376. // printf(" ");
  377. // }
  378. // }
  379. // printf("\n");
  380. // }
  381. //
  382. // for (i = 1; i <= WORDCOUNT; i++)
  383. // printf("%5d", i);
  384. //
  385. // printf("\n");
  386. //}
  387.  
  388. //#define MAXSIZE 100
  389. //#define IN 1
  390. //#define OUT 0
  391. //
  392. //main()
  393. //{
  394. // int c;
  395. // int MAXLETTERCOUNT = 0;
  396. // int i = 0;
  397. // int j;
  398. // int nl = 0;
  399. // int Array[MAXSIZE];
  400. // int State = OUT; //flag for whether in word or not
  401. //
  402. // for (i = 0; i < MAXSIZE; i++) //i < MAXSIZE
  403. // {
  404. // Array[i] = 0;
  405. // }
  406. //
  407. // i = 0;//
  408. //
  409. // while ((c = getchar()) != EOF)
  410. // {
  411. // if (isalpha(c)) //isalphanumerical
  412. // {
  413. // State = IN;
  414. // nl++;
  415. // if (nl >= MAXLETTERCOUNT)
  416. // {
  417. // MAXLETTERCOUNT = nl;
  418. // }
  419. // }
  420. // else if (State == IN && (c == ' ' || c == '\t' || c == '\n'))
  421. // {
  422. // Array[nl]++;
  423. // nl = 0;
  424. // State = OUT;
  425. // }
  426. // else
  427. // continue;
  428. // }
  429. //
  430. // for (i = 1; i <= MAXLETTERCOUNT; i++)
  431. // printf("%5d", Array[i]);
  432. //
  433. // printf("\n");
  434. //
  435. // for (i = 1; i <= MAXLETTERCOUNT; i++)
  436. // printf("%5d", i);
  437. //
  438. // printf("\n");
  439. //}
  440.  
  441. //double toCelcius(double);
  442. //
  443. ////main()
  444. ////{
  445. //// int c;
  446. //// while ((c = getchar()) != EOF)
  447. //// {
  448. ////
  449. //// }
  450. ////
  451. ////}
  452. //
  453. //main()
  454. //{
  455. // int i = 0;
  456. // while (i <= 212)
  457. // {
  458. // printf("%9.4f\n", toCelcius(i));
  459. // i++;
  460. // }
  461. //
  462. //}
  463. //
  464. //double toCelcius(double F)
  465. //{
  466. // double C;
  467. // C = (5.0 / 9.0) * (F - 32);
  468. // return C;
  469. //}
  470.  
  471. //#define MAXLINE 1000
  472.  
  473. //int getline(char line[], int maxline);
  474. //void copy(char from[], char to[]);
  475. //
  476. //main()
  477. //{
  478. // int len;
  479. // int max = 0;
  480. // char line[MAXLINE];
  481. // char longest[MAXLINE];
  482. //
  483. // while ((len = getline(line, MAXLINE)) > 0)
  484. // {
  485. // if (len > max)
  486. // {
  487. // max = len;
  488. // copy(line, longest);
  489. // }
  490. // }
  491. // if (max > 0)
  492. // printf("%s", longest);
  493. // return 0;
  494. //}
  495. //
  496. //int getline(char s[], int limit)
  497. //{
  498. // int i;
  499. // int c;
  500. //
  501. // for (i = 0; i < limit - 1 && (c = getchar()) != EOF && c != '\n'; i++)
  502. // {
  503. // s[i] = c;
  504. // }
  505. // if (c == '\n')
  506. // {
  507. // s[i] = c;
  508. // i++;
  509. // }
  510. // s[i] = '\0';
  511. // return i;
  512. //}
  513. //
  514. //void copy(char from[], char to[])
  515. //{
  516. // int i = 0;
  517. // while ((to[i] = from[i]) != '\0')
  518. // {
  519. // i++;
  520. // }
  521. //}
  522.  
  523. //main()
  524. //{
  525. // int i = 0;
  526. // int nc = 0;
  527. // int limit = 0;
  528. // int c;
  529. // char array[MAXLINE];
  530. // for (limit = 0; limit < 100; limit++)
  531. // {
  532. // i = 0;
  533. // while ((c = getchar()) != EOF && c != '\n' && i < MAXLINE - 1)
  534. // {
  535. // array[i] = c;
  536. // i++;
  537. // nc++;
  538. // }
  539. // array[i] = '\0';
  540. // //i = 0;
  541. // printf("%s %d\n", array, nc);
  542. // nc = 0;
  543. // }
  544. //}
  545.  
  546. //main()
  547. //{
  548. // int i = 0; D
  549. // int nc = 0; O
  550. // int limit = 0; E
  551. // int c; S
  552. // int array[MAXLINE];
  553. // while ((c = getchar()) != EOF && c != '\n' && limit < 100) N
  554. // { O
  555. // array[i] = c; T
  556. // i++;
  557. // nc++; W
  558. // } O
  559. // array[i] = '\0'; R
  560. // i = 0; K
  561. // printf("%s %d\n", array, nc);
  562. //}
  563.  
  564. //main()
  565. //{
  566. // int i = 0;
  567. // int nc = 0;
  568. // int limit = 0;
  569. // int max = 0;
  570. // int c;
  571. // char array[MAXLINE];
  572. // char longest[MAXLINE];
  573. // for (limit = 0; limit < 100; limit++)
  574. // {
  575. // i = 0;
  576. // while ((c = getchar()) != EOF && c != '\n' && i < MAXLINE - 1)
  577. // {
  578. // array[i] = c;
  579. // i++;
  580. // nc++;
  581. // }
  582. // array[i] = '\0';
  583. // i = 0;
  584. // if (nc > max)
  585. // {
  586. // max = nc;
  587. // while ((longest[i] = array[i]) != '\0')
  588. // i++;
  589. // }
  590. // //i = 0;
  591. // if (c == EOF)
  592. // printf("%s %d\n", longest, max);
  593. // nc = 0;
  594. // }
  595. //}
  596.  
  597. //main()
  598. //{
  599. // int i = 0;
  600. // int nc = 0;
  601. // int limit = 0;
  602. // int c;
  603. // char array[MAXLINE];
  604. // for (limit = 0; limit < 100; limit++)
  605. // {
  606. // i = 0;
  607. // while ((c = getchar()) != EOF && c != '\n' && i < MAXLINE - 1)
  608. // {
  609. // array[i] = c;
  610. // i++;
  611. // nc++;
  612. // }
  613. // array[i] = '\0';
  614. // //i = 0;
  615. // if (nc > 80)
  616. // printf("%s %d\n", array, nc);
  617. // nc = 0;
  618. // }
  619. //}
  620.  
  621. #define YES 1
  622. #define NO 0
  623.  
  624. //main()
  625. //{
  626. // int c;
  627. // char array[MAXLINE];
  628. // int INALINE = NO;
  629. // int TRAILING = NO;
  630. // int i = 0;
  631. // int index = 0;
  632. // int limit = 0;
  633. // int linesskipped = 0;
  634. // for (limit = 0; limit < 100; limit++)
  635. // {
  636. // while ((c = getchar()) != EOF && i < MAXLINE - 1)
  637. // {
  638. // if (c != '\n' && c != ' ' && c != '\t')
  639. // {
  640. // array[i] = c;
  641. // INALINE = YES;
  642. // TRAILING = NO;
  643. // i++;
  644. // }
  645. // if ((c == ' ' || c == '\t') && TRAILING == NO)
  646. // {
  647. // array[i] = c;
  648. // index = i;
  649. // TRAILING = YES;
  650. // i++;
  651. // }
  652. // else if ((c == ' ' || c == '\t') && TRAILING == YES)
  653. // {
  654. // array[i] = c;
  655. // i++;
  656. // }
  657. // if (c == '\n' && TRAILING == YES && INALINE == YES)
  658. // {
  659. // INALINE = NO;
  660. // TRAILING = NO;
  661. // array[index] = '\0';
  662. // array[index] = 'x';
  663. // array[index+1] = '\n';
  664. // i = index + 2;
  665. // }
  666. // else if (c == '\n' && TRAILING == NO && INALINE == YES)
  667. // {
  668. // INALINE = NO;
  669. // TRAILING = NO;
  670. // array[i] = 'x';
  671. // array[i+1] = '\n';
  672. // i = i + 2;
  673. // }
  674. // else if (c == '\n' && TRAILING == YES && INALINE == NO)
  675. // {
  676. // TRAILING = NO;
  677. // array[index] = '\0';
  678. // array[index] = 'x';
  679. // array[index + 1] = '\n';
  680. // i = index + 2;
  681. // }
  682. // }
  683. // if (c == EOF)
  684. // {
  685. // array[i] = '\0';
  686. // printf("%s", array);
  687. // array[0] = '\0';
  688. // i = 0;
  689. // }
  690. // }
  691. //}
  692.  
  693. //#define MAXLENGTH 10000
  694. //
  695. //void reverse(char[], char[], int length); //new reverse(s) on line 5295
  696. //
  697. //main()
  698. //{
  699. // int c;
  700. // int i = 0;
  701. // int SOMETHINGWASREVERSED = NO;
  702. // char array[MAXLENGTH];
  703. // char reversearray[MAXLENGTH];
  704. //
  705. // while ((c = getchar()) != '!' && i < MAXLENGTH - 1)
  706. // {
  707. // if (c == '\n' && SOMETHINGWASREVERSED == YES)
  708. // {
  709. // printf("\n");
  710. // SOMETHINGWASREVERSED = NO;
  711. // }
  712. // else if (c == '?')
  713. // {
  714. // SOMETHINGWASREVERSED = YES;
  715. // array[i] = '\0';
  716. // reverse(array, reversearray, i);
  717. // printf("%s", reversearray);
  718. // array[0] = '\0';
  719. // reversearray[0] = '\0';
  720. // i = 0;
  721. // }
  722. //
  723. // else
  724. // {
  725. // array[i] = c;
  726. // i++;
  727. // }
  728. // }
  729. // array[i] = '\0';
  730. // reverse(array, reversearray, i);
  731. // printf("%s\n", reversearray);
  732. //}
  733. //
  734. //void reverse(char from[], char to[], int length)
  735. //{
  736. // int i = 0;
  737. // while (length - 1 >= 0)
  738. // {
  739. // to[i] = from[length - 1];
  740. // length--;
  741. // i++;
  742. // }
  743. // to[i] = '\0';
  744. //}
  745.  
  746. //#define MAXSIZE 1000
  747. //
  748. //main()
  749. //{
  750. // int c;
  751. // int tabspaces = 0;
  752. // int spaces = 0;
  753. // int i = 0;
  754. // int nc = 0;
  755. // char array[MAXSIZE];
  756. //
  757. // printf("How many tab spaces? Type in the number of tab spaces and then press enter\n");
  758. //
  759. // while ((tabspaces = getchar()) == '\n')
  760. // ;
  761. //
  762. // while (tabspaces < '0' || tabspaces > '9')
  763. // {
  764. // printf("Not a number between 0 and 9.\nType in the number of tab spaces and then press enter\n");
  765. // while ((tabspaces = getchar()) == '\n')
  766. // ;
  767. // }
  768. // 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');
  769. // while ((c = getchar()) != EOF && i < MAXSIZE)
  770. // {
  771. // if (c != '\t' && c != '\n')
  772. // {
  773. // array[i] = c;
  774. // i++;
  775. // nc++;
  776. // }
  777. // else if (c == '\n')
  778. // {
  779. // array[i] = c;
  780. // i++;
  781. // nc = 0;
  782. // }
  783. // else if (c == '\t')
  784. // {
  785. // 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.
  786. // while (spaces > 0)
  787. // {
  788. // array[i] = 'x';
  789. // i++;
  790. // spaces--;
  791. // 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.
  792. // }
  793. // }
  794. // }
  795. // array[i] = '\0';
  796. // printf("%s\n", array);
  797. //}
  798.  
  799. //inastringofspace
  800. //beginning of text
  801. //#define MAXSIZE 1000
  802. //main()
  803. //{
  804. // int c;
  805. // int i = 0;
  806. // int nc = 0;
  807. // int nfl = 0;
  808. // int Firsttab = 0;
  809. // int spacesfromtab = 0;
  810. // int stringspaces = 0;
  811. // int STRINGOFSPACES = NO;
  812. // char array[MAXSIZE];
  813. // while ((c = getchar()) != EOF && i < MAXSIZE - 1)
  814. // {
  815. // if (c != '\t' && c != ' ' && c != '\n')
  816. // {
  817. // if (STRINGOFSPACES == YES)
  818. // {
  819. // if (8 - (nfl % 8) <= stringspaces)
  820. // {
  821. // stringspaces = stringspaces - (8 - (nfl % 8));
  822. // array[i] = '\t';
  823. // i++;
  824. // nc = 0;
  825. // nfl = 0;
  826. // while (stringspaces / 8 > 0)
  827. // {
  828. // array[i] = '\t';
  829. // i++;
  830. // stringspaces = stringspaces - 8;
  831. // }
  832. // }
  833. // while (stringspaces > 0)
  834. // {
  835. // array[i] = 'y';
  836. // i++;
  837. // nc++;
  838. // stringspaces--;
  839. // nfl = 0;
  840. // }
  841. // }
  842. // STRINGOFSPACES = NO;
  843. // array[i] = c;
  844. // i++;
  845. // nc++;
  846. // nfl++;
  847. // }
  848. // else if (c == '\t')
  849. // {
  850. // STRINGOFSPACES = YES;
  851. // spacesfromtab = 8 - (nc % 8);
  852. // nc = 0;
  853. // stringspaces = stringspaces + spacesfromtab;
  854. // }
  855. // else if (c == ' ')
  856. // {
  857. // STRINGOFSPACES = YES;
  858. // stringspaces++;
  859. // nc++;
  860. // }
  861. // else if (c == '\n')
  862. // {
  863. // if (STRINGOFSPACES == YES)
  864. // {
  865. // if (8 - (nfl % 8) <= stringspaces)
  866. // {
  867. // stringspaces = stringspaces - (8 - (nfl % 8));
  868. // array[i] = '\t';
  869. // i++;
  870. // nc = 0;
  871. // nfl = 0;
  872. // while (stringspaces / 8 > 0)
  873. // {
  874. // array[i] = '\t';
  875. // i++;
  876. // stringspaces = stringspaces - 8;
  877. // }
  878. // }
  879. // while (stringspaces > 0)
  880. // {
  881. // array[i] = 'y';
  882. // i++;
  883. // nc++;
  884. // stringspaces--;
  885. // nfl = 0;
  886. // }
  887. // }
  888. // nc = 0;
  889. // nfl = 0;
  890. // STRINGOFSPACES = NO;
  891. // array[i] = c;
  892. // i++;
  893. // }
  894. // }
  895. //
  896. // if (STRINGOFSPACES == YES)
  897. // {
  898. // if (8 - (nfl % 8) <= stringspaces)
  899. // {
  900. // stringspaces = stringspaces - (8 - (nfl % 8));
  901. // array[i] = '\t';
  902. // i++;
  903. // nc = 0;
  904. // nfl = 0;
  905. // while (stringspaces / 8 > 0)
  906. // {
  907. // array[i] = '\t';
  908. // i++;
  909. // stringspaces = stringspaces - 8;
  910. // }
  911. // }
  912. // while (stringspaces > 0)
  913. // {
  914. // array[i] = 'y';
  915. // i++;
  916. // nc++;
  917. // stringspaces--;
  918. // nfl = 0;
  919. // }
  920. //
  921. // array[i] = '\0';
  922. // printf("%s\n", array);a
  923. //}
  924.  
  925. //#define MAXCHARACTERS 1000
  926. //main()
  927. //{
  928. // int c;
  929. // int i = 0;
  930. // int j = 0;
  931. // int nc = 0;
  932. // char array[MAXCHARACTERS];
  933. // char output[MAXCHARACTERS];
  934. // while ((c = getchar()) != EOF)
  935. // {
  936. // array[i++] = c;
  937. // }
  938. // array[i] = '\0';
  939. // i = 0;
  940. // while (array[i] != '\0')
  941. // {
  942. // while (nc < 9 && array[i] != '\0')
  943. // {
  944. // if (array[i] == '\t')
  945. // {
  946. // nc = nc + 8 - (nc % 8);
  947. // if (nc > 9)
  948. // {
  949. // output[j++] = '\n';
  950. // output[j++] = '\t';
  951. // nc = 8;
  952. // }
  953. // }
  954. // else if (array[i] != '\t')
  955. // nc++;
  956. // output[j] = array[i];
  957. // i++;
  958. // j++;
  959. // }
  960. //
  961. // if (nc == 9)
  962. // {
  963. // if (array[i] != ' ' && array[i] != '\t' && array[i] != '\n')
  964. // {
  965. // output[j++] = '-';
  966. // output[j++] = '\n';
  967. // nc = 0;
  968. // }
  969. // else
  970. // {
  971. // output[j++] = '\n';
  972. // nc = 0;
  973. // }
  974. // }
  975. // }
  976. // output[j] = '\0';
  977. // printf("%s\n", output);
  978. //}
  979.  
  980. //#define MAXCHARACTERS 1000
  981. //main()
  982. //{
  983. // int c;
  984. // int i = 0;
  985. // int j = 0;
  986. // int k = 0;
  987. // int nc = 1;
  988. // int counter = 1;
  989. // char array[MAXCHARACTERS];
  990. // char output[MAXCHARACTERS];
  991. // while ((c = getchar()) != EOF)
  992. // {
  993. // array[i++] = c;
  994. // }
  995. // array[i] = '\0';
  996. // i = 0;
  997. //
  998. // while (array[i] != '\0')
  999. // {
  1000. // while (counter < 9 && array[i] != '\0')
  1001. // {
  1002. // if (array[i] == '\t')
  1003. // {
  1004. // k = 8 - nc % 8;
  1005. // while (k >= 0)
  1006. // {
  1007. // output[j++] = ' ';
  1008. // k--;
  1009. // counter++;
  1010. // nc++;
  1011. // }
  1012. // i++;
  1013. // }
  1014. // else if (array[i] != '\t' && array[i] != '\n')
  1015. // {
  1016. // output[j] = array[i];
  1017. // i++;
  1018. // j++;
  1019. // nc++;
  1020. // counter++;
  1021. // }
  1022. // else if (array[i] == '\n')
  1023. // {
  1024. // output[j] = array[i];
  1025. // i++;
  1026. // j++;
  1027. // nc = 1;
  1028. // counter = 1;
  1029. // }
  1030. // }
  1031. // if (counter >= 9)
  1032. // {
  1033. // if (array[i] != ' ' && array[i] != '\t' && array[i] != '\n' && array[i+1] != ' ' && array[i+1] != '\t' && array[i+1] != '\n')
  1034. // {
  1035. // output[j] = array[i];
  1036. // i++;
  1037. // j++;
  1038. // output[j++] = '-';
  1039. // output[j++] = '\n';
  1040. // nc++;
  1041. // counter = 1;
  1042. // }
  1043. // else if (array[i] == '\t')
  1044. // {
  1045. // output[j++] = '\n';
  1046. // output[j++] = '\t';
  1047. // i++;
  1048. // nc++;
  1049. // counter = 8;
  1050. // }
  1051. // else if (array[i] == ' ')
  1052. // {
  1053. // output[j++] = ' ';
  1054. // output[j++] = '\n';
  1055. // i++;
  1056. // nc++;
  1057. // counter = 1;
  1058. //
  1059. // }
  1060. // else if (array[i] == '\n')
  1061. // {
  1062. // output[j] = array[i];
  1063. // i++;
  1064. // j++;
  1065. // nc = 1;
  1066. // counter = 1;
  1067. // }
  1068. // else
  1069. // {
  1070. // output[j] = array[i];
  1071. // i++;
  1072. // j++;
  1073. // output[j++] = '\n';
  1074. // nc++;
  1075. // counter = 1;
  1076. // }
  1077. // }
  1078. // }
  1079. //
  1080. // output[j] = '\0';
  1081. // printf("%s\n", output);
  1082. //}
  1083. //#define MAXARRAYSIZE 1000
  1084. //#define ON 1
  1085. //#define OFF 0
  1086. //main()
  1087. //{
  1088. // int c;
  1089. // char array[MAXARRAYSIZE];
  1090. // int i = 0;
  1091. // int j = 0;
  1092. // char output[MAXARRAYSIZE];
  1093. // int DONE = NO;
  1094. // int STAR = NO;
  1095. // int COMMENTCHECKING = ON;
  1096. //
  1097. // while ((c = getchar()) != EOF && i < MAXARRAYSIZE - 1)
  1098. // {
  1099. // array[i] = c;
  1100. // i++;
  1101. // }
  1102. // array[i] = '\0';
  1103. // i = 0;
  1104. // while (array[i] != '\0')
  1105. // {
  1106. // while (COMMENTCHECKING == ON && array[i] != '\0')
  1107. // {
  1108. // output[j] = array[i];
  1109. // if (array[i] == '/' && COMMENTCHECKING == YES)
  1110. // {
  1111. // if (array[i + 1] == '/')
  1112. // {
  1113. // i++;
  1114. // while (array[i] != '\n')
  1115. // {
  1116. // i++;
  1117. // }
  1118. // output[j] = array[i];
  1119. // }
  1120. // else if (array[i + 1] == '*' && COMMENTCHECKING == YES)
  1121. // {
  1122. // i++;
  1123. // while (DONE == NO)
  1124. // {
  1125. // if (array[i] == '*')
  1126. // {
  1127. // STAR = YES;
  1128. // i++;
  1129. // }
  1130. // else if (array[i] == '/' && STAR == YES)
  1131. // {
  1132. // DONE = YES;
  1133. // i++;
  1134. // }
  1135. // else
  1136. // {
  1137. // STAR = NO;
  1138. // i++;
  1139. // }
  1140. // output[j] = array[i];
  1141. // }
  1142. // }
  1143. // }
  1144. // else if (array[i] == '"')
  1145. // {
  1146. // COMMENTCHECKING = OFF;
  1147. // }
  1148. // i++;
  1149. // j++;
  1150. // }
  1151. // while (COMMENTCHECKING == OFF && array[i] != '\0')
  1152. // {
  1153. // output[j] = array[i];
  1154. // i++;
  1155. // j++;
  1156. // if (array[i] == '"')
  1157. // {
  1158. // COMMENTCHECKING = ON;
  1159. // }
  1160. // }
  1161. // }
  1162. // output[j] = array[i];
  1163. // printf("%s\n", output);
  1164. //}
  1165. //#define MAXARRAYSIZE 10000
  1166. //#define ON 1
  1167. //#define OFF 0
  1168. //main()
  1169. //{ //test
  1170. // int c;
  1171. // char array[MAXARRAYSIZE]; /*test*/
  1172. // int i = 0;
  1173. // int j = 0;
  1174. // char output[MAXARRAYSIZE];
  1175. // int COMMENT = NO;
  1176. // int STAR = NO;
  1177. // int SQCOMMENTCHECKING = ON;
  1178. // int DQCOMMENTCHECKING = ON;
  1179. // /*test
  1180. // a
  1181. // b
  1182. // c*/
  1183. // while ((c = getchar()) != EOF && i < MAXARRAYSIZE - 1)
  1184. // {
  1185. // array[i] = c;
  1186. // i++;
  1187. // }
  1188. // array[i] = '\0';
  1189. // i = 0; //test
  1190. // while (array[i] != '\0') /*test
  1191. // a
  1192. // b
  1193. // c*/
  1194. // {
  1195. // while (SQCOMMENTCHECKING == ON && DQCOMMENTCHECKING == ON && array[i] != '\0')
  1196. // {
  1197. // output[j] = array[i];
  1198. // if (array[i] == '/' && SQCOMMENTCHECKING == ON && DQCOMMENTCHECKING == ON)
  1199. // {
  1200. // if (array[i + 1] == '/')
  1201. // {
  1202. // i++;
  1203. // while (array[i] != '\n')
  1204. // {
  1205. // i++;
  1206. // }
  1207. // output[j] = array[i];//test
  1208. // }
  1209. // else if (array[i + 1] == '*' && SQCOMMENTCHECKING == ON && DQCOMMENTCHECKING == ON)
  1210. // {
  1211. // i++;
  1212. // i++;
  1213. // COMMENT = YES;
  1214. // while (COMMENT == YES)
  1215. // {//test
  1216. // if (array[i] == '*')
  1217. // {
  1218. // STAR = YES;
  1219. // i++;//test
  1220. // } /*test
  1221. // a
  1222. // b
  1223. // c*/
  1224. // else if (array[i] == '/' && STAR == YES)
  1225. // {
  1226. // COMMENT = NO;
  1227. // i++;
  1228. // }
  1229. // else
  1230. // {
  1231. // STAR = NO;//test
  1232. // i++;
  1233. // }
  1234. // }
  1235. // //output[j] = array[i];
  1236. // }
  1237. // }
  1238. // /*else if (array[i] == '"' && array[i-1] != '\'')
  1239. // {
  1240. // output[j] = array[i];
  1241. // i++;
  1242. // j++;
  1243. // COMMENTCHECKING = OFF;
  1244. // }*/
  1245. // else if (array[i] == '\'' && array[i - 1] != '\\')
  1246. // {
  1247. // output[j] = array[i];
  1248. // i++;
  1249. // j++;
  1250. // SQCOMMENTCHECKING = OFF;
  1251. // }
  1252. // else if (array[i] == '"' && array[i - 1] != '\\')
  1253. // {
  1254. // output[j] = array[i];
  1255. // i++;
  1256. // j++;
  1257. // DQCOMMENTCHECKING = OFF;
  1258. // }
  1259. // else
  1260. // {
  1261. // i++;
  1262. // j++;
  1263. // }
  1264. // }
  1265. // while ((SQCOMMENTCHECKING == OFF || DQCOMMENTCHECKING == OFF) && array[i] != '\0')
  1266. // {
  1267. // if (array[i] == '\'' && array[i - 1] != '\\')
  1268. // {
  1269. // output[j] = array[i];
  1270. // i++;
  1271. // j++;
  1272. // SQCOMMENTCHECKING = ON;
  1273. // }
  1274. // else if (array[i] == '"' && array[i - 1] != '\\')
  1275. // {
  1276. // output[j] = array[i];
  1277. // i++;
  1278. // j++;
  1279. // DQCOMMENTCHECKING = ON;
  1280. // }
  1281. // else
  1282. // {
  1283. // output[j] = array[i];
  1284. // i++;
  1285. // j++;
  1286. // }
  1287. // // if (array[i] == '"')
  1288. // // { /*test
  1289. // //a
  1290. // //b
  1291. // //c*//*test*///
  1292. // // COMMENTCHECKING = ON;
  1293. // // }
  1294. // }
  1295. // }
  1296. // output[j] = array[i];
  1297. // printf("%s\n", output);
  1298. //}
  1299. #define MAXARRAYSIZE 10000
  1300.  
  1301.  
  1302. //main()
  1303. //{
  1304. // int c;
  1305. // char array[MAXARRAYSIZE];
  1306. // int i = 0;
  1307. // char output[MAXARRAYSIZE];
  1308. // int j = 0;
  1309. // int MAXLParenthesis = 0;
  1310. // int MAXLBraces = 0;
  1311. // int MAXLBrackets = 0;
  1312. // int RParenthesis = 0;
  1313. // int RBraces = 0;
  1314. // int RBrackets = 0;
  1315. // int COMMENT = NO;
  1316. // int STAR = NO;
  1317. // int COMMENTDONE = NO;
  1318. // int COMMENTBEGANON = 0;
  1319. // int COMMENTBEGANON_REGISTERED = NO;
  1320. // int LINE = 0;
  1321. // int UNEVENCOMMENT = NO;
  1322. // int INACOMMENT = NO;
  1323. // while ((c = getchar()) != EOF)
  1324. // {
  1325. // array[i] = c;
  1326. // i++;
  1327. // }
  1328. // array[i] = '\0';
  1329. // i = 0;
  1330. // while (array[i] != '\0')
  1331. // {
  1332. // if (array[i] == '\n')
  1333. // {
  1334. // LINE++; //LINE COUNTER
  1335. // } //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
  1336. //
  1337. // output[j] = array[i]; //STORES EVERY CHARACTER FROM array
  1338. //
  1339. // if (array[i] == ';') //THIS CHECKS FOR COMMENTS AFTER ;
  1340. // {
  1341. // i++;
  1342. // j++;
  1343. // output[j] = array[i]; //CHECKS EITHER // OR /* OR / OR WHITE SPACE OR NEWLINE . FIVE DIFFERENT CASES.
  1344. //
  1345. // while (array[i] != '\n') //WHILE THE CHARACTER WE JUST SAVED IS NOT THE NEW LINE \n CHECK THE SIX CASES
  1346. // {
  1347. // i++;
  1348. // j++;
  1349. // output[j] = array[i];
  1350. // if (INACOMMENT == NO && array[i] != '/' && array[i] != '*' && array[i] != ' ' && array[i] != '\t')
  1351. // {
  1352. // while (array[i] != '\n')
  1353. // {
  1354. // i++;
  1355. // j++;
  1356. // output[j] = array[i]; // //CASE 6 TEXT NOT IN A COMMENT
  1357. // }
  1358. // printf("Error: Syntax error. Text not in a comment on line %d.", LINE);
  1359. // }
  1360. //
  1361. // if (array[i] == '/') //CHECKS CASE 1 2 3 4 5
  1362. // {
  1363. // UNEVENCOMMENT = YES; //CASE 1 UNEVEN COMMENT
  1364. // INACOMMENT == YES;
  1365. // COMMENTBEGANON = LINE;
  1366. // if (array[i + 1] == '/')
  1367. // {
  1368. // UNEVENCOMMENT = NO;
  1369. // INACOMMENT = YES;
  1370. // while (array[i] != '\n')
  1371. // {
  1372. // i++;
  1373. // j++;
  1374. // output[j] = array[i]; //CASE 4 SINGLE LINE COMMENT //
  1375. // }
  1376. // }
  1377. //
  1378. // else if (array[i + 1] == '*') //CASE 5 MULTI LINE COMMENT /*
  1379. // {
  1380. // UNEVENCOMMENT = NO;
  1381. // INACOMMENT = YES;
  1382. // while (INACOMMENT == YES && array[i] != '\0')
  1383. // {
  1384. // if (array[i] == '\n')
  1385. // {
  1386. // if (COMMENTBEGANON_REGISTERED == NO)
  1387. // {
  1388. // COMMENTBEGANON = LINE;
  1389. // COMMENTBEGANON_REGISTERED == YES;
  1390. // }
  1391. // LINE++; //LINE COUNTER
  1392. // }
  1393. // if (array[i] == '*')
  1394. // {
  1395. // output[j] == array[i];
  1396. // j++;
  1397. // i++;
  1398. // STAR = YES;
  1399. // }
  1400. // else if (array[i] == '/' && STAR == YES)
  1401. // {
  1402. // output[j] == array[i];
  1403. // j++;
  1404. // i++;
  1405. // INACOMMENT = NO;
  1406. // COMMENTBEGANON_REGISTERED == NO;
  1407. // }
  1408. // else
  1409. // {
  1410. // output[j] == array[i];
  1411. // j++;
  1412. // i++;
  1413. // STAR = NO;
  1414. // }
  1415. // }
  1416. // printf(" End of multi line comment. New line will be printed v \n");
  1417. // }
  1418. // }
  1419. // }
  1420. // if (UNEVENCOMMENT == YES)
  1421. // {
  1422. // printf("Error: Unbalanced comment on line. Missing / or *.");
  1423. // output[j] = array[i];
  1424. // i++;
  1425. // j++;
  1426. // }
  1427. // else if (UNEVENCOMMENT == NO) //CASE 2 WHITESPACE //CASE 3 NEWLINE
  1428. // {
  1429. // output[j] = array[i];
  1430. // i++;
  1431. // j++;
  1432. // }
  1433. // }
  1434. // if (array[i] == '/')
  1435. // {
  1436. // if (array[i + 1] == '/')
  1437. // {
  1438. // output[j] == 'C';
  1439. // j++;
  1440. // output[j] == 'O';
  1441. // j++;
  1442. // output[j] == 'M';
  1443. // j++;
  1444. // output[j] == 'M';
  1445. // j++;
  1446. // output[j] == 'E';
  1447. // j++;
  1448. // output[j] == 'N';
  1449. // j++;
  1450. // output[j] == 'T';
  1451. // j++;
  1452. // output[j] == ':';
  1453. // j++;
  1454. // output[j] = array[i]; // /
  1455. // i++;
  1456. // j++;
  1457. // output[j] = array[i]; // //
  1458. // i++;
  1459. // j++;
  1460. // COMMENT = YES;
  1461. // while (c != '\n')
  1462. // {
  1463. // output[j] = array[i];//comment text
  1464. // i++;
  1465. // j++;
  1466. // }
  1467. // //output[j] = array[i]; //\n
  1468. // //i++;
  1469. // //j++;
  1470. // }
  1471. // else if (array[i + 1] == '*')
  1472. // {
  1473. // output[j] == 'C';
  1474. // j++;
  1475. // output[j] == 'O';
  1476. // j++;
  1477. // output[j] == 'M';
  1478. // j++;
  1479. // output[j] == 'M';
  1480. // j++;
  1481. // output[j] == 'E';
  1482. // j++;
  1483. // output[j] == 'N';
  1484. // j++;
  1485. // output[j] == 'T';
  1486. // j++;
  1487. // output[j] == ':';
  1488. // j++;
  1489. // output[j] = array[i]; // /
  1490. // i++;
  1491. // j++;
  1492. // output[j] = array[i]; // //
  1493. // i++;
  1494. // j++;
  1495. // COMMENT = YES;
  1496. // COMMENTBEGANON = LINE; //comment that began on Line 1 never terminated.
  1497. // while (COMMENTDONE == NO && array[i] != '\0')
  1498. // {
  1499. // if (array[i] == '*')
  1500. // {
  1501. // output[j] == array[i];
  1502. // j++;
  1503. // i++;
  1504. // STAR = YES;
  1505. // }
  1506. // else if (array[i] == '/' && STAR == YES)
  1507. // {
  1508. // output[j] == array[i];
  1509. // j++;
  1510. // i++;
  1511. // COMMENTDONE = YES;
  1512. // }
  1513. // else
  1514. // {
  1515. // output[j] == array[i];
  1516. // j++;
  1517. // i++;
  1518. // STAR = NO;
  1519. // }
  1520. // }
  1521. // if (array[i] == '\0' && COMMENTDONE == NO)
  1522. // {
  1523. // printf("Error: Unbalanced cooment. The comment that started on Line %d never finished.", COMMENTBEGANON);
  1524. // }
  1525. // COMMENT = NO;
  1526. // }
  1527. // else
  1528. // ;
  1529. // }
  1530. // else
  1531. // {
  1532. // j++;
  1533. // i++;
  1534. // }
  1535. //
  1536. // }
  1537. // output[j] = '\0';
  1538. // printf("%s\n", output);
  1539. //}
  1540.  
  1541. //#define MAXARRAYSIZE 10000
  1542. //
  1543. //
  1544. //main()
  1545. //{
  1546. // int c;
  1547. // char array[MAXARRAYSIZE];
  1548. // int i = 0;
  1549. // char output[MAXARRAYSIZE];
  1550. // int j = 0;
  1551. // int MAXLParenthesis = 0;
  1552. // int MAXLBraces = 0;
  1553. // int MAXLBrackets = 0;
  1554. // int RParenthesis = 0;
  1555. // int RBraces = 0;
  1556. // int RBrackets = 0;
  1557. // int COMMENT = NO;
  1558. // int STAR = NO;
  1559. // int COMMENTDONE = NO;
  1560. // int COMMENTBEGANON = 0;
  1561. // int COMMENTBEGANON_REGISTERED = NO;
  1562. // int LINE = 0;
  1563. // int UNEVENCOMMENT = NO;
  1564. // int INACOMMENT = NO;
  1565. // while ((c = getchar()) != EOF)
  1566. // {
  1567. // array[i] = c;
  1568. // i++;
  1569. // }
  1570. // array[i] = '\0';
  1571. // i = 0;
  1572. // while (array[i] != '\0')
  1573. // {
  1574. // if (array[i] == '\n')
  1575. // {
  1576. // LINE++; //LINE COUNTER
  1577. // }
  1578. //
  1579. // output[j] = array[i]; //STORES EVERY CHARACTER FROM array to output
  1580. //
  1581. // if (array[i] == ';') //THIS CHECKS FOR COMMENTS AND TEXT OUTSIDE OF COMMENTS AFTER ;
  1582. // {
  1583. // i++;
  1584. // j++;
  1585. //
  1586. // output[j] = array[i]; //CHECKS EITHER // OR /* OR / OR WHITE SPACE OR NEWLINE OR TEXT. SIX DIFFERENT CASES.
  1587. //
  1588. // while (array[i] != '\n') //CHECK THE SIX CASES
  1589. // {
  1590. // i++;
  1591. // j++;
  1592. //
  1593. // output[j] = array[i]; //BEGIINNING OF TEXT THAT HAS TO BE ANALYZED. SAVED AND NOT NEXT.
  1594. //
  1595. // if (INACOMMENT == NO && array[i] != '/' && array[i] != '*' && array[i] != ' ' && array[i] != '\t') //CASE 6
  1596. // {
  1597. // while (array[i] != '\n')
  1598. // {
  1599. // i++;
  1600. // j++;
  1601. //
  1602. // output[j] = array[i];
  1603. // }
  1604. // printf("Error: Syntax error. Text not in a comment on line %d.", LINE);
  1605. // }
  1606. //
  1607. // if (array[i] == '/') //CHECKS CASE 1 2 3 4 5
  1608. // {
  1609. // UNEVENCOMMENT = YES; //CASE 1 UNEVEN COMMENT
  1610. // INACOMMENT == YES;
  1611. // COMMENTBEGANON = LINE;
  1612. // if (array[i + 1] == '/')
  1613. // {
  1614. // UNEVENCOMMENT = NO;
  1615. // INACOMMENT = YES;
  1616. // while (array[i] != '\n')
  1617. // {
  1618. // i++;
  1619. // j++;
  1620. // output[j] = array[i]; //CASE 4 SINGLE LINE COMMENT //
  1621. // }
  1622. // }
  1623. //
  1624. // else if (array[i + 1] == '*') //CASE 5 MULTI LINE COMMENT /*
  1625. // {
  1626. // UNEVENCOMMENT = NO;
  1627. // INACOMMENT = YES;
  1628. // while (INACOMMENT == YES && array[i] != '\0')
  1629. // {
  1630. // if (array[i] == '\n')
  1631. // {
  1632. // if (COMMENTBEGANON_REGISTERED == NO)
  1633. // {
  1634. // COMMENTBEGANON = LINE;
  1635. // COMMENTBEGANON_REGISTERED == YES;
  1636. // }
  1637. // LINE++; //LINE COUNTER
  1638. // }
  1639. // if (array[i] == '*')
  1640. // {
  1641. // output[j] == array[i];
  1642. // j++;
  1643. // i++;
  1644. // STAR = YES;
  1645. // }
  1646. // else if (array[i] == '/' && STAR == YES)
  1647. // {
  1648. // output[j] == array[i];
  1649. // j++;
  1650. // i++;
  1651. // INACOMMENT = NO;
  1652. // COMMENTBEGANON_REGISTERED == NO;
  1653. // }
  1654. // else
  1655. // {
  1656. // output[j] == array[i];
  1657. // j++;
  1658. // i++;
  1659. // STAR = NO;
  1660. // }
  1661. // }
  1662. // printf(" End of multi line comment. New line will be printed v \n");
  1663. // }
  1664. // }
  1665. // }
  1666. // if (UNEVENCOMMENT == YES)
  1667. // {
  1668. // printf("Error: Unbalanced comment on line. Missing / or *.");
  1669. // output[j] = array[i];
  1670. // i++;
  1671. // j++;
  1672. // }
  1673. // else if (UNEVENCOMMENT == NO) //CASE 2 WHITESPACE //CASE 3 NEWLINE
  1674. // {
  1675. // output[j] = array[i];
  1676. // i++;
  1677. // j++;
  1678. // }
  1679. // }
  1680. // if (array[i] == '/')
  1681. // {
  1682. // if (array[i + 1] == '/')
  1683. // {
  1684. // output[j] == 'C';
  1685. // j++;
  1686. // output[j] == 'O';
  1687. // j++;
  1688. // output[j] == 'M';
  1689. // j++;
  1690. // output[j] == 'M';
  1691. // j++;
  1692. // output[j] == 'E';
  1693. // j++;
  1694. // output[j] == 'N';
  1695. // j++;
  1696. // output[j] == 'T';
  1697. // j++;
  1698. // output[j] == ':';
  1699. // j++;
  1700. // output[j] = array[i]; // /
  1701. // i++;
  1702. // j++;
  1703. // output[j] = array[i]; // //
  1704. // i++;
  1705. // j++;
  1706. // COMMENT = YES;
  1707. // while (c != '\n')
  1708. // {
  1709. // output[j] = array[i];//comment text
  1710. // i++;
  1711. // j++;
  1712. // }
  1713. // //output[j] = array[i]; //\n
  1714. // //i++;
  1715. // //j++;
  1716. // }
  1717. // else if (array[i + 1] == '*')
  1718. // {
  1719. // output[j] == 'C';
  1720. // j++;
  1721. // output[j] == 'O';
  1722. // j++;
  1723. // output[j] == 'M';
  1724. // j++;
  1725. // output[j] == 'M';
  1726. // j++;
  1727. // output[j] == 'E';
  1728. // j++;
  1729. // output[j] == 'N';
  1730. // j++;
  1731. // output[j] == 'T';
  1732. // j++;
  1733. // output[j] == ':';
  1734. // j++;
  1735. // output[j] = array[i]; // /
  1736. // i++;
  1737. // j++;
  1738. // output[j] = array[i]; // //
  1739. // i++;
  1740. // j++;
  1741. // COMMENT = YES;
  1742. // COMMENTBEGANON = LINE; //comment that began on Line 1 never terminated.
  1743. // while (COMMENTDONE == NO && array[i] != '\0')
  1744. // {
  1745. // if (array[i] == '*')
  1746. // {
  1747. // output[j] == array[i];
  1748. // j++;
  1749. // i++;
  1750. // STAR = YES;
  1751. // }
  1752. // else if (array[i] == '/' && STAR == YES)
  1753. // {
  1754. // output[j] == array[i];
  1755. // j++;
  1756. // i++;
  1757. // COMMENTDONE = YES;
  1758. // }
  1759. // else
  1760. // {
  1761. // output[j] == array[i];
  1762. // j++;
  1763. // i++;
  1764. // STAR = NO;
  1765. // }
  1766. // }
  1767. // if (array[i] == '\0' && COMMENTDONE == NO)
  1768. // {
  1769. // printf("Error: Unbalanced cooment. The comment that started on Line %d never finished.", COMMENTBEGANON);
  1770. // }
  1771. // COMMENT = NO;
  1772. // }
  1773. // else
  1774. // ;
  1775. // }
  1776. // else
  1777. // {
  1778. // j++;
  1779. // i++;
  1780. // }
  1781. //
  1782. // }
  1783. // output[j] = '\0';
  1784. // printf("%s\n", output);
  1785. //}
  1786. //
  1787. //
  1788. //if (array[i] == '/')
  1789. //{
  1790. // if (array[i + 1] == '/')
  1791. // {
  1792. // output[j] == 'C';
  1793. // j++;
  1794. // output[j] == 'O';
  1795. // j++;
  1796. // output[j] == 'M';
  1797. // j++;
  1798. // output[j] == 'M';
  1799. // j++;
  1800. // output[j] == 'E';
  1801. // j++;
  1802. // output[j] == 'N';
  1803. // j++;
  1804. // output[j] == 'T';
  1805. // j++;
  1806. // output[j] == ':';
  1807. // j++;
  1808. // output[j] = array[i]; // /
  1809. // i++;
  1810. // j++;
  1811. // output[j] = array[i]; // //
  1812. // i++;
  1813. // j++;
  1814. // COMMENT = YES;
  1815. // while (c != '\n')
  1816. // {
  1817. // output[j] = array[i];//comment text
  1818. // i++;
  1819. // j++;
  1820. // }
  1821. // //output[j] = array[i]; //\n
  1822. // //i++;
  1823. // //j++;
  1824. // }
  1825. // else if (array[i + 1] == '*')
  1826. // {
  1827. // output[j] == 'C';
  1828. // j++;
  1829. // output[j] == 'O';
  1830. // j++;
  1831. // output[j] == 'M';
  1832. // j++;
  1833. // output[j] == 'M';
  1834. // j++;
  1835. // output[j] == 'E';
  1836. // j++;
  1837. // output[j] == 'N';
  1838. // j++;
  1839. // output[j] == 'T';
  1840. // j++;
  1841. // output[j] == ':';
  1842. // j++;
  1843. // output[j] = array[i]; // /
  1844. // i++;
  1845. // j++;
  1846. // output[j] = array[i]; // //
  1847. // i++;
  1848. // j++;
  1849. // COMMENT = YES;
  1850. // COMMENTBEGANON = LINE; //comment that began on Line 1 never terminated.
  1851. // while (COMMENTDONE == NO && array[i] != '\0')
  1852. // {
  1853. // if (array[i] == '*')
  1854. // {
  1855. // output[j] == array[i];
  1856. // j++;
  1857. // i++;
  1858. // STAR = YES;
  1859. // }
  1860. // else if (array[i] == '/' && STAR == YES)
  1861. // {
  1862. // output[j] == array[i];
  1863. // j++;
  1864. // i++;
  1865. // COMMENTDONE = YES;
  1866. // }
  1867. // else
  1868. // {
  1869. // output[j] == array[i];
  1870. // j++;
  1871. // i++;
  1872. // STAR = NO;
  1873. // }
  1874. // }
  1875. // if (array[i] == '\0' && COMMENTDONE == NO)
  1876. // {
  1877. // printf("Error: Unbalanced cooment. The comment that started on Line %d never finished.", COMMENTBEGANON);
  1878. // }
  1879. // COMMENT = NO;
  1880. // }
  1881. // else
  1882. // ;
  1883. //}
  1884. //else
  1885. //{
  1886. // j++;
  1887. // i++;
  1888. //}
  1889. //
  1890. //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,
  1891.  
  1892. //#define MAXARRAYSIZE 10000
  1893. //main()
  1894. //{
  1895. // int c;
  1896. // char array[MAXARRAYSIZE];
  1897. // int i = 0;
  1898. // char output[MAXARRAYSIZE];
  1899. // int j = 0;
  1900. // char syntaxerror[MAXARRAYSIZE];
  1901. // int k = 0;
  1902. // int LeftBrackets = 0;
  1903. // int RightBrackets = 0;
  1904. // int EXTRABRACKETONLINE = 0;
  1905. // int RightParenthesis = 0;
  1906. // int LeftParanthesis = 0;
  1907. // int EXTRAPARENTHESISONLINE = 0;
  1908. // int RightBraces = 0;
  1909. // int LeftBraces = 0;
  1910. // int EXTRABRACESONLINE = 0;
  1911. // int STAR = NO;
  1912. // int UNBALANCEDCOMMENT = NO;
  1913. // int INACOMMENT = NO;
  1914. // int COMMENTDONE = NO;
  1915. // int COMMENTBEGANON = 0;
  1916. // int COMMENTENDEDON = 0;
  1917. // int LINE = 1;
  1918. // int SYNTAXERROR = NO;
  1919. // int SYNTAXERRORONLINE = 0;
  1920. // int INASINGLEQUOTE = NO;
  1921. // int INADOUBLEQUOTE = NO;
  1922. // int SINGLEQUOTEBEGANON = 0;
  1923. // int DOUBLEQUOTEBEGANON = 0;
  1924. // while ((c = getchar()) != EOF)
  1925. // {
  1926. // array[i] = c;
  1927. // i++;
  1928. // }
  1929. // array[i] = '\0';
  1930. // i = 0;
  1931. // while (array[i] != '\0' && array[i] != EOF)
  1932. // {
  1933. //
  1934. // if (array[i] == '\n')
  1935. // {
  1936. // LINE++; //LINE COUNTER
  1937. // if (LeftParanthesis > RightParenthesis)
  1938. // {
  1939. // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d. \t", EXTRAPARENTHESISONLINE);
  1940. // }
  1941. // RightBrackets = 0;
  1942. // LeftBrackets = 0;
  1943. // }
  1944. //
  1945. // output[j] = array[i]; //STORES EVERY CHARACTER FROM array
  1946. //
  1947. // if (array[i] == ';') //THIS CHECKS FOR COMMENTS AFTER ;
  1948. // {
  1949. // i++;
  1950. // j++;
  1951. //
  1952. // output[j] = array[i]; //CHECKS EITHER // OR /* OR / OR WHITE SPACE OR NEWLINE . SIX DIFFERENT CASES.
  1953. // if (LeftParanthesis > RightParenthesis)
  1954. // {
  1955. // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d. \n", EXTRAPARENTHESISONLINE);
  1956. // }
  1957. // RightBrackets = 0;
  1958. // LeftBrackets = 0;
  1959. //
  1960. // while (array[i] != '\n' && array[i] != '\0') //WHILE THE CHARACTER WE JUST SAVED IS NOT THE NEW LINE \n CHECK THE SIX CASES
  1961. // {
  1962. // if (INACOMMENT == NO && array[i] != '/' && array[i] != '*' && array[i] != ' ' && array[i] != '\t') //CASE 6
  1963. // {
  1964. // while (array[i] != '/' && array[i] != '\n' && array[i] != '\0')
  1965. // {
  1966. // output[j] = array[i];
  1967. // syntaxerror[k] = array[i];
  1968. // SYNTAXERRORONLINE = LINE;
  1969. // k++;
  1970. // i++;
  1971. // j++;
  1972. // }
  1973. // SYNTAXERROR = YES; //CASE 6 DONE
  1974. // }
  1975. //
  1976. // else if (array[i] == '/') //CASE 1 2 3 4 5
  1977. // {
  1978. // output[j] = array[i];
  1979. //
  1980. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  1981. //
  1982. // COMMENTBEGANON = LINE;
  1983. //
  1984. // if (array[i + 1] == '/') //CASE 4
  1985. // {
  1986. // UNBALANCEDCOMMENT = NO;
  1987. // INACOMMENT = YES;
  1988. // while (array[i] != '\n')
  1989. // {
  1990. // i++;
  1991. // j++;
  1992. // output[j] = array[i]; //CASE 4 DONE
  1993. // }
  1994. // INACOMMENT = NO;
  1995. // }
  1996. //
  1997. // else if (array[i + 1] == '*') //CASE 5
  1998. // {
  1999. // UNBALANCEDCOMMENT = YES;
  2000. // INACOMMENT = YES;
  2001. // COMMENTBEGANON = LINE;
  2002. // i++;
  2003. // j++;
  2004. // output[j] = array[i];
  2005. // i++;
  2006. // j++;
  2007. // while (INACOMMENT == YES && array[i] != '\0')
  2008. // {
  2009. // if (array[i] == '\n')
  2010. // {
  2011. // LINE++; //LINE COUNTER
  2012. // }
  2013. // else if (array[i] == '*')
  2014. // {
  2015. // output[j] = array[i];
  2016. // i++;
  2017. // j++;
  2018. // STAR = YES;
  2019. // }
  2020. // else if (array[i] == '/' && STAR == YES)
  2021. // {
  2022. // output[j] = array[i];
  2023. // i++;
  2024. // j++;
  2025. // INACOMMENT = NO;
  2026. // UNBALANCEDCOMMENT = NO;
  2027. // COMMENTENDEDON = LINE;
  2028. // STAR = NO;
  2029. // }
  2030. // else
  2031. // {
  2032. // output[j] = array[i];
  2033. // i++;
  2034. // j++;
  2035. // STAR = NO;
  2036. // }
  2037. // }
  2038. // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
  2039. // {
  2040. // printf("Multi-line comment that started on line %d and ended on %d. New line.\n", COMMENTBEGANON, COMMENTENDEDON); //CASE 5 DONE
  2041. // }
  2042. // }
  2043. //
  2044. // else
  2045. // {
  2046. // while (array[i] != '\n')
  2047. // {
  2048. // syntaxerror[k] = array[i]; // / a b
  2049. // i++;
  2050. // j++;
  2051. // k++;
  2052. // if (array[i] != '\n')
  2053. // {
  2054. // output[j] = array[i]; // a b
  2055. // }
  2056. // SYNTAXERRORONLINE = LINE;
  2057. // }
  2058. // SYNTAXERROR = YES;
  2059. // }
  2060. // }
  2061. // else
  2062. // {
  2063. // i++;
  2064. // j++;
  2065. // }
  2066. // }
  2067. //
  2068. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  2069. // {
  2070. // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
  2071. // output[j] = array[i];
  2072. //
  2073. // if (array[i] == '\n')
  2074. // {
  2075. // LINE++;
  2076. // }
  2077. //
  2078. // i++;
  2079. // j++;
  2080. // UNBALANCEDCOMMENT = NO;
  2081. // }
  2082. //
  2083. // else if (UNBALANCEDCOMMENT == NO) //CASE 2 WHITESPACE DONE //CASE 3 NEWLINE DONE //CASE 4 // DONE //CASE 5 /**/ DONE
  2084. // {
  2085. // output[j] = array[i]; //SAVES /n THEN NEXT -- EXITS CHECKING AFTER ;
  2086. //
  2087. // if (array[i] == '\n')
  2088. // {
  2089. // LINE++;
  2090. // }
  2091. //
  2092. // i++;
  2093. // j++;
  2094. // }
  2095. // if (SYNTAXERROR == YES) //CASE 6 DONE
  2096. // {
  2097. // syntaxerror[k] = '\0';
  2098. // printf("Error: Syntax error. Text not in a comment on line %d. Code: %s\n", SYNTAXERRORONLINE, syntaxerror);
  2099. // syntaxerror[0] = '\0';
  2100. // k = 0;
  2101. // output[j] = array[i];
  2102. //
  2103. // if (array[i] == '\n')
  2104. // {
  2105. // LINE++;
  2106. // }
  2107. //
  2108. // i++;
  2109. // j++;
  2110. // SYNTAXERROR = NO;
  2111. // }
  2112. // } //; DONE
  2113. //
  2114. //
  2115. // else if (array[i] == '/') //3 CASES
  2116. // {
  2117. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  2118. //
  2119. // COMMENTBEGANON = LINE;
  2120. //
  2121. // if (array[i + 1] == '/') //CASE 2
  2122. // {
  2123. // UNBALANCEDCOMMENT = NO;
  2124. //
  2125. // INACOMMENT = YES;
  2126. //
  2127. // while (array[i] != '\n')
  2128. // {
  2129. // i++;
  2130. // j++;
  2131. // output[j] = array[i];
  2132. // }
  2133. // INACOMMENT = NO; //CASE 2 DONE
  2134. // }
  2135. //
  2136. // else if (array[i + 1] == '*') //CASE 3
  2137. // {
  2138. // UNBALANCEDCOMMENT = YES;
  2139. //
  2140. // INACOMMENT = YES;
  2141. //
  2142. // COMMENTBEGANON = LINE;
  2143. //
  2144. // while (INACOMMENT == YES && array[i] != '\0')
  2145. // {
  2146. // if (array[i] == '\n')
  2147. // {
  2148. // LINE++; //LINE COUNTER
  2149. // }
  2150. // if (array[i] == '*')
  2151. // {
  2152. // i++;
  2153. // j++;
  2154. // output[j] == array[i];
  2155. // STAR = YES;
  2156. // }
  2157. // else if (array[i] == '/' && STAR == YES)
  2158. // {
  2159. // i++;
  2160. // j++;
  2161. // output[j] == array[i];
  2162. // INACOMMENT = NO;
  2163. // UNBALANCEDCOMMENT = NO;
  2164. // }
  2165. // else
  2166. // {
  2167. // i++;
  2168. // j++;
  2169. // output[j] == array[i];
  2170. // STAR = NO;
  2171. // }
  2172. // }
  2173. // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO && SYNTAXERROR == NO)
  2174. // {
  2175. // 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
  2176. // }
  2177. // }
  2178. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  2179. // {
  2180. // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
  2181. // output[j] = array[i];
  2182. //
  2183. // if (array[i] == '\n')
  2184. // {
  2185. // LINE++;
  2186. // }
  2187. //
  2188. // i++;
  2189. // j++;
  2190. // UNBALANCEDCOMMENT = NO;
  2191. // }
  2192. //
  2193. // else if (UNBALANCEDCOMMENT == NO) //CASE 2
  2194. // {
  2195. // output[j] = array[i]; //SAVES /n THEN NEXT
  2196. //
  2197. // if (array[i] == '\n')
  2198. // {
  2199. // LINE++;
  2200. // }
  2201. //
  2202. // i++;
  2203. // j++;
  2204. // }
  2205. // }
  2206. //
  2207. // else if (array[i] == '\'' && array[i - 1] != '\\')
  2208. // {
  2209. // INASINGLEQUOTE = YES;
  2210. // SINGLEQUOTEBEGANON = LINE;
  2211. // i++;
  2212. // j++;
  2213. //
  2214. // while (INASINGLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
  2215. // {
  2216. // if (array[i] == '\'' && array[i - 1] != '\\')
  2217. // {
  2218. // INASINGLEQUOTE = NO;
  2219. // output[j] = array[i];
  2220. //
  2221. // i++;
  2222. // j++;
  2223. // }
  2224. // else
  2225. // {
  2226. // output[j] = array[i];
  2227. //
  2228. // i++;
  2229. // j++;
  2230. // }
  2231. // }
  2232. // if (INASINGLEQUOTE == YES)
  2233. // {
  2234. // printf("Error: Uneven single quote. The quote that started on line %d is missing a single quote \'.\n", SINGLEQUOTEBEGANON);
  2235. // INASINGLEQUOTE = NO;
  2236. // }
  2237. //
  2238. // }
  2239. //
  2240. // else if (array[i] == '"' && array[i - 1] != '\\')
  2241. // {
  2242. // INADOUBLEQUOTE = YES;
  2243. // DOUBLEQUOTEBEGANON = LINE; //could use one variable QUOTEBEGANON
  2244. // i++;
  2245. // j++;
  2246. // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
  2247. // {
  2248. // if (array[i] == '"' && array[i - 1] != '\\')
  2249. // {
  2250. // INADOUBLEQUOTE = NO;
  2251. // output[j] = array[i];
  2252. //
  2253. // i++;
  2254. // j++;
  2255. // }
  2256. // else
  2257. // {
  2258. // output[j] = array[i];
  2259. //
  2260. // i++;
  2261. // j++;
  2262. // }
  2263. // }
  2264. // if (INADOUBLEQUOTE == YES)
  2265. // {
  2266. // printf("Error: Uneven double quote. The double quote that started on line %d is missing a single quote \".\n", DOUBLEQUOTEBEGANON);
  2267. // INADOUBLEQUOTE = NO;
  2268. // }
  2269. // }
  2270. //
  2271. // else if (array[i] == '[')
  2272. // {
  2273. // LeftBrackets++;
  2274. // EXTRABRACKETONLINE = LINE;
  2275. //
  2276. // i++;
  2277. // j++;
  2278. // if (LeftBrackets - RightBrackets > 1)
  2279. // {
  2280. // printf("Error: Uneven brackets. An extra [ was found on line %d.\n", EXTRABRACKETONLINE);
  2281. // }
  2282. // }
  2283. // else if (array[i] == ']')
  2284. // {
  2285. // RightBrackets++;
  2286. // EXTRABRACKETONLINE = LINE;
  2287. //
  2288. // i++;
  2289. // j++;
  2290. // if (RightBrackets - LeftBrackets > 0)
  2291. // {
  2292. // printf("Error: Uneven brackets. An extra ] was found on line %d.\n", EXTRABRACKETONLINE);
  2293. // }
  2294. // }
  2295. //
  2296. // else if (array[i] == '(')
  2297. // {
  2298. // LeftParanthesis++;
  2299. // EXTRAPARENTHESISONLINE = LINE;
  2300. //
  2301. // i++;
  2302. // j++;
  2303. // }
  2304. // else if (array[i] == ')')
  2305. // {
  2306. // RightParenthesis++;
  2307. // EXTRAPARENTHESISONLINE = LINE;
  2308. //
  2309. // i++;
  2310. // j++;
  2311. // if (RightParenthesis > LeftParanthesis)
  2312. // {
  2313. // printf("Error: Uneven Right Parenthesis. An extra ) was found on line %d.\n", EXTRAPARENTHESISONLINE);
  2314. // }
  2315. // }
  2316. //
  2317. // else if (array[i] == '{')
  2318. // {
  2319. // LeftBraces++;
  2320. // EXTRABRACESONLINE = LINE;
  2321. //
  2322. // i++;
  2323. // j++;
  2324. // }
  2325. // else if (array[i] == '}')
  2326. // {
  2327. // RightBraces++;
  2328. // EXTRABRACESONLINE = LINE;
  2329. //
  2330. // i++;
  2331. // j++;
  2332. // if (RightBraces > LeftBraces)
  2333. // {
  2334. // printf("Error: Uneven Right Braces. An extra } was found on line %d.\n", EXTRABRACESONLINE);
  2335. // }
  2336. // }
  2337. // else if (array[i] != '\0' && array[i] != EOF)
  2338. // {
  2339. // i++;
  2340. // j++;
  2341. // }
  2342. // else
  2343. // ;
  2344. // }
  2345. //
  2346. // if (LeftBraces > RightBraces)
  2347. // {
  2348. // printf("Error: Uneven Left Braces. An extra { was found on line %d.\n", EXTRABRACESONLINE);
  2349. // }
  2350. //
  2351. // output[j] = '\0'; //DONE
  2352. // printf("%s\n", output); //PRINT OUTPUT
  2353. //}
  2354. /*
  2355. error
  2356. error; error
  2357. error; / error
  2358. error; //noerror
  2359. error; /*noerror*/
  2360. //error;/*noerror
  2361. //*/
  2362. //error; /*error/
  2363. //error; /*error*8/
  2364. //error:
  2365. //*/
  2366. //#define MAXARRAYSIZE 20000
  2367. //main()
  2368. //{
  2369. // int c;
  2370. // char array[MAXARRAYSIZE];
  2371. // int i = 0;
  2372. // char output[MAXARRAYSIZE];
  2373. // int j = 0;
  2374. // char syntaxerror[MAXARRAYSIZE];
  2375. // int k = 0;
  2376. // int LeftBrackets = 0;
  2377. // int RightBrackets = 0;
  2378. // int EXTRABRACKETONLINE = 0;
  2379. // int RightParenthesis = 0;
  2380. // int LeftParanthesis = 0;
  2381. // int EXTRAPARENTHESISONLINE = 0;
  2382. // int RightBraces = 0;
  2383. // int LeftBraces = 0;
  2384. // int EXTRALEFTBRACEONLINE = 0;
  2385. // int EXTRARIGHTBRACEONLINE = 0;
  2386. // int STAR = NO;
  2387. // int UNBALANCEDCOMMENT = NO;
  2388. // int INACOMMENT = NO;
  2389. // int COMMENTDONE = NO;
  2390. // int COMMENTBEGANON = 0;
  2391. // int COMMENTENDEDON = 0;
  2392. // int LINE = 2362;
  2393. // int SYNTAXERROR = NO;
  2394. // int SYNTAXERRORONLINE = 0;
  2395. // int INASINGLEQUOTE = NO;
  2396. // int INADOUBLEQUOTE = NO;
  2397. // int SINGLEQUOTEBEGANON = 0;
  2398. // int DOUBLEQUOTEBEGANON = 0;
  2399. // int HEXSYNTAXERROR = NO;
  2400. // int HEXSYNTAXERRORBEGANON = 0;
  2401. // //octal (come back)
  2402. // while ((c = getchar()) != EOF)
  2403. // {
  2404. // array[i] = c;
  2405. // i++;
  2406. // }
  2407. // array[i] = '\0';
  2408. // i = 0;
  2409. // 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.
  2410. // while (array[i] != '\0' && array[i] != EOF)
  2411. // {
  2412. //
  2413. // if (array[i] == '\n')
  2414. // {
  2415. // LINE++; //LINE COUNTER
  2416. // if (LeftParanthesis > RightParenthesis)
  2417. // {
  2418. // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
  2419. // }
  2420. // RightBrackets = 0;
  2421. // LeftBrackets = 0;
  2422. // RightParenthesis = 0;
  2423. // LeftParanthesis = 0;
  2424. // }
  2425. // output[j] = array[i]; //STORES EVERY CHARACTER FROM array
  2426. //
  2427. // if (array[i] == ';') //THIS CHECKS FOR COMMENTS AFTER ;
  2428. // {
  2429. // i++;
  2430. // j++;
  2431. //
  2432. // output[j] = array[i]; //CHECKS EITHER // OR /* OR / OR WHITE SPACE OR NEWLINE . SIX DIFFERENT CASES.
  2433. // if (LeftParanthesis > RightParenthesis)
  2434. // {
  2435. // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d. \n", EXTRAPARENTHESISONLINE);
  2436. // }
  2437. // RightBrackets = 0;
  2438. // LeftBrackets = 0;
  2439. //
  2440. // 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
  2441. // {
  2442. // if (INACOMMENT == NO && array[i] != '/' && array[i] != '*' && array[i] != ' ' && array[i] != '\t') //CASE 6
  2443. // {
  2444. // while (array[i] != '/' && array[i] != '\n' && array[i] != '\0')
  2445. // {
  2446. // output[j] = array[i];
  2447. // syntaxerror[k] = array[i];
  2448. // SYNTAXERRORONLINE = LINE;
  2449. // k++;
  2450. // i++;
  2451. // j++;
  2452. // }
  2453. // syntaxerror[k] = ' ';
  2454. // k++;
  2455. // SYNTAXERROR = YES; //CASE 6 DONE
  2456. // }
  2457. //
  2458. // else if (array[i] == '/') //CASE 1 2 3 4 5
  2459. // {
  2460. // output[j] = array[i];
  2461. //
  2462. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  2463. //
  2464. // COMMENTBEGANON = LINE;
  2465. //
  2466. // if (array[i + 1] == '/') //CASE 4
  2467. // {
  2468. // UNBALANCEDCOMMENT = NO;
  2469. // INACOMMENT = YES;
  2470. // while (array[i] != '\n')
  2471. // {
  2472. // i++;
  2473. // j++;
  2474. // output[j] = array[i]; //CASE 4 DONE
  2475. // }
  2476. // INACOMMENT = NO;
  2477. // }
  2478. //
  2479. // else if (array[i + 1] == '*') //CASE 5
  2480. // {
  2481. // UNBALANCEDCOMMENT = YES;
  2482. // INACOMMENT = YES;
  2483. // COMMENTBEGANON = LINE;
  2484. // i++;
  2485. // j++;
  2486. // output[j] = array[i];
  2487. // i++;
  2488. // j++;
  2489. // while (INACOMMENT == YES && array[i] != '\0')
  2490. // {
  2491. // if (array[i] == '\n')
  2492. // {
  2493. // LINE++; //LINE COUNTER
  2494. // output[j] = array[i];
  2495. // i++;
  2496. // j++;
  2497. // if (LeftParanthesis > RightParenthesis)
  2498. // {
  2499. // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
  2500. // }
  2501. // RightBrackets = 0;
  2502. // LeftBrackets = 0;
  2503. // RightParenthesis = 0;
  2504. // LeftParanthesis = 0;
  2505. // }
  2506. // else if (array[i] == '*')
  2507. // {
  2508. // output[j] = array[i];
  2509. // i++;
  2510. // j++;
  2511. // STAR = YES;
  2512. // }
  2513. // else if (array[i] == '/' && STAR == YES)
  2514. // {
  2515. // output[j] = array[i];
  2516. // i++;
  2517. // j++;
  2518. // INACOMMENT = NO;
  2519. // UNBALANCEDCOMMENT = NO;
  2520. // COMMENTENDEDON = LINE;
  2521. // STAR = NO;
  2522. // }
  2523. // else
  2524. // {
  2525. // output[j] = array[i];
  2526. // i++;
  2527. // j++;
  2528. // STAR = NO;
  2529. // }
  2530. // }
  2531. // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
  2532. // {
  2533. // printf("Multi-line comment started on line %d and ended on %d.\n", COMMENTBEGANON, COMMENTENDEDON); //CASE 5 DONE
  2534. // }
  2535. // }
  2536. //
  2537. // else
  2538. // {
  2539. // syntaxerror[k] = array[i];
  2540. // output[j] = array[i];
  2541. // i++;
  2542. // j++;
  2543. // k++;
  2544. //
  2545. // while (array[i] != '\n' && array[i] != '/' && array[i] != '\0' && array[i] != EOF)
  2546. // {
  2547. // syntaxerror[k] = array[i]; // / a b
  2548. // output[j] = array[i];
  2549. // i++;
  2550. // j++;
  2551. // k++;
  2552. // SYNTAXERRORONLINE = LINE;
  2553. // }
  2554. // SYNTAXERROR = YES;
  2555. // }
  2556. // }
  2557. // else
  2558. // {
  2559. // ; //NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
  2560. // /*i++;
  2561. // j++;*/
  2562. // }
  2563. // }
  2564. //
  2565. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  2566. // {
  2567. // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
  2568. // output[j] = array[i];
  2569. //
  2570. // if (array[i] == '\0')
  2571. // {
  2572. // printf("\n%s\n", output);
  2573. // }
  2574. // if (array[i] == '\n')
  2575. // {
  2576. // LINE++;
  2577. // if (LeftParanthesis > RightParenthesis)
  2578. // {
  2579. // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
  2580. // }
  2581. // RightBrackets = 0;
  2582. // LeftBrackets = 0;
  2583. // RightParenthesis = 0;
  2584. // LeftParanthesis = 0;
  2585. // }
  2586. //
  2587. // i++;
  2588. // j++;
  2589. // UNBALANCEDCOMMENT = NO;
  2590. // }
  2591. //
  2592. // else if (UNBALANCEDCOMMENT == NO) //CASE 2 WHITESPACE DONE //CASE 3 NEWLINE DONE //CASE 4 // DONE //CASE 5 /**/ DONE
  2593. // {
  2594. // output[j] = array[i]; //SAVES /n THEN NEXT -- EXITS CHECKING AFTER ;
  2595. //
  2596. // if (array[i] == '\n')
  2597. // {
  2598. // LINE++;
  2599. // if (LeftParanthesis > RightParenthesis)
  2600. // {
  2601. // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
  2602. // }
  2603. // RightBrackets = 0;
  2604. // LeftBrackets = 0;
  2605. // RightParenthesis = 0;
  2606. // LeftParanthesis = 0;
  2607. // }
  2608. //
  2609. // i++;
  2610. // j++;
  2611. // }
  2612. // if (SYNTAXERROR == YES) //CASE 6 DONE
  2613. // {
  2614. // syntaxerror[k] = '\0';
  2615. // printf("Error: Syntax error. Text not in a comment on line %d. Code: %s\n", SYNTAXERRORONLINE, syntaxerror);
  2616. // syntaxerror[0] = '\0';
  2617. // k = 0;
  2618. // output[j] = array[i];
  2619. //
  2620. // if (array[i] == '\n')
  2621. // {
  2622. // if (LeftParanthesis > RightParenthesis)
  2623. // {
  2624. // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
  2625. // }
  2626. // LINE++;
  2627. // RightBrackets = 0;
  2628. // LeftBrackets = 0;
  2629. // RightParenthesis = 0;
  2630. // LeftParanthesis = 0;
  2631. // }
  2632. //
  2633. // i++;
  2634. // j++;
  2635. // SYNTAXERROR = NO;
  2636. // }
  2637. // } //; DONE
  2638. // else if (array[i] == '/') //3 CASES
  2639. // {
  2640. // output[j] = array[i];
  2641. //
  2642. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  2643. //
  2644. // COMMENTBEGANON = LINE;
  2645. //
  2646. // if (array[i + 1] == '/') //CASE 4
  2647. // {
  2648. // UNBALANCEDCOMMENT = NO;
  2649. // INACOMMENT = YES;
  2650. // while (array[i] != '\n')
  2651. // {
  2652. // i++;
  2653. // j++;
  2654. // output[j] = array[i]; //CASE 4 DONE
  2655. // }
  2656. // INACOMMENT = NO;
  2657. // }
  2658. //
  2659. // else if (array[i + 1] == '*') //CASE 3
  2660. // {
  2661. // UNBALANCEDCOMMENT = YES;
  2662. //
  2663. // INACOMMENT = YES;
  2664. //
  2665. // COMMENTBEGANON = LINE;
  2666. // i++;
  2667. // j++;
  2668. // output[j] = array[i];
  2669. // i++;
  2670. // j++;
  2671. // while (INACOMMENT == YES && array[i] != '\0')
  2672. // {
  2673. // if (array[i] == '\n')
  2674. // {
  2675. // LINE++; //LINE COUNTER
  2676. // output[j] = array[i];
  2677. // i++;
  2678. // j++;
  2679. // if (LeftParanthesis > RightParenthesis)
  2680. // {
  2681. // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
  2682. // }
  2683. // RightBrackets = 0;
  2684. // LeftBrackets = 0;
  2685. // RightParenthesis = 0;
  2686. // LeftParanthesis = 0;
  2687. // }
  2688. // else if (array[i] == '*')
  2689. // {
  2690. // output[j] = array[i];
  2691. // i++;
  2692. // j++;
  2693. // STAR = YES;
  2694. // }
  2695. // else if (array[i] == '/' && STAR == YES)
  2696. // {
  2697. // output[j] = array[i];
  2698. // i++;
  2699. // j++;
  2700. // INACOMMENT = NO;
  2701. // UNBALANCEDCOMMENT = NO;
  2702. // COMMENTENDEDON = LINE;
  2703. // STAR = NO;
  2704. // }
  2705. // else
  2706. // {
  2707. // output[j] = array[i];
  2708. // i++;
  2709. // j++;
  2710. // STAR = NO;
  2711. // }
  2712. // }
  2713. // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
  2714. // {
  2715. // printf("Multi-line comment started on line %d and ended on %d.\n", COMMENTBEGANON, COMMENTENDEDON);
  2716. // }
  2717. // }
  2718. // else
  2719. // ; //NEXT CHARACTER HANDLED IN THE UNBALANCED CODE BLOCK
  2720. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  2721. // {
  2722. // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
  2723. // output[j] = array[i];
  2724. //
  2725. // if (array[i] == '\n')
  2726. // {
  2727. // LINE++;
  2728. // if (LeftParanthesis > RightParenthesis)
  2729. // {
  2730. // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
  2731. // }
  2732. // RightBrackets = 0;
  2733. // LeftBrackets = 0;
  2734. // RightParenthesis = 0;
  2735. // LeftParanthesis = 0;
  2736. // }
  2737. //
  2738. // i++;
  2739. // j++;
  2740. // UNBALANCEDCOMMENT = NO;
  2741. // }
  2742. //
  2743. // else if (UNBALANCEDCOMMENT == NO) //CASE 2
  2744. // {
  2745. // output[j] = array[i]; //SAVES /n THEN NEXT
  2746. //
  2747. // if (array[i] == '\n')
  2748. // {
  2749. // LINE++;
  2750. // if (LeftParanthesis > RightParenthesis)
  2751. // {
  2752. // printf("Error: Uneven Left Parenthesis. An extra ( was found on line %d.\n", EXTRAPARENTHESISONLINE);
  2753. // }
  2754. // RightBrackets = 0;
  2755. // LeftBrackets = 0;
  2756. // RightParenthesis = 0;
  2757. // LeftParanthesis = 0;
  2758. // }
  2759. //
  2760. // i++;
  2761. // j++;
  2762. // }
  2763. // }
  2764. //
  2765. // 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
  2766. // {
  2767. // INASINGLEQUOTE = YES;
  2768. // SINGLEQUOTEBEGANON = LINE;
  2769. // i++;
  2770. // j++;
  2771. //
  2772. // while (INASINGLEQUOTE == YES && array[i] != '\n') //if hex number must be 0-9 A-F until a space is read.
  2773. // {
  2774. // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
  2775. // {
  2776. // INASINGLEQUOTE = NO;
  2777. // output[j] = array[i];
  2778. //
  2779. // i++;
  2780. // j++;
  2781. // }
  2782. // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
  2783. // {
  2784. // INASINGLEQUOTE = NO;
  2785. // output[j] = array[i];
  2786. //
  2787. // i++;
  2788. // j++;
  2789. // }
  2790. // else if (array[i] == 'x' && array[i - 1] == '\\' && array[i-2] != '\\')
  2791. // {
  2792. // output[j] = array[i];
  2793. //
  2794. // i++;
  2795. // j++;
  2796. // while (array[i] != ' ' && array[i] != '\'' && array[i] != '\n')
  2797. // {
  2798. // 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')
  2799. // {
  2800. // HEXSYNTAXERROR = YES;
  2801. // HEXSYNTAXERRORBEGANON = LINE;
  2802. // }
  2803. // output[j] = array[i];
  2804. //
  2805. // i++;
  2806. // j++;
  2807. // }
  2808. // }
  2809. // else
  2810. // {
  2811. //
  2812. // output[j] = array[i];
  2813. //
  2814. // i++;
  2815. // j++;
  2816. // }
  2817. // }
  2818. // if (INASINGLEQUOTE == YES)
  2819. // {
  2820. // printf("Error: Uneven single quote. The single quote that started on line %d is missing a single quote \'.\n", SINGLEQUOTEBEGANON);
  2821. // INASINGLEQUOTE = NO;
  2822. // }
  2823. // if (HEXSYNTAXERROR == YES)
  2824. // {
  2825. // printf("Error: Syntax error. The hexidecimal number on line %d is not acceptable.\n", HEXSYNTAXERRORBEGANON);
  2826. // HEXSYNTAXERROR = NO;
  2827. // }
  2828. // }
  2829. //
  2830. // else if (array[i] == '"' && array[i - 1] != '\\')
  2831. // {
  2832. // INADOUBLEQUOTE = YES;
  2833. // DOUBLEQUOTEBEGANON = LINE; //could use one variable QUOTEBEGANON
  2834. // i++;
  2835. // j++;
  2836. // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
  2837. // {
  2838. // if (array[i] == '"' && array[i - 1] != '\\')
  2839. // {
  2840. // INADOUBLEQUOTE = NO;
  2841. // output[j] = array[i];
  2842. //
  2843. // i++;
  2844. // j++;
  2845. // }
  2846. // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
  2847. // {
  2848. // INADOUBLEQUOTE = NO;
  2849. // output[j] = array[i];
  2850. //
  2851. // i++;
  2852. // j++;
  2853. // }
  2854. // else if (array[i] == 'x' && array[i - 1] == '\\' && array[i - 2] != '\\')
  2855. // {
  2856. // output[j] = array[i];
  2857. //
  2858. // i++;
  2859. // j++;
  2860. // while (array[i] != ' ' && array[i] != '\'' && array[i] != '\n')
  2861. // {
  2862. // 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')
  2863. // {
  2864. // HEXSYNTAXERROR = YES;
  2865. // HEXSYNTAXERRORBEGANON = LINE;
  2866. // }
  2867. // output[j] = array[i];
  2868. //
  2869. // i++;
  2870. // j++;
  2871. // }
  2872. // }
  2873. // else
  2874. // {
  2875. // output[j] = array[i];
  2876. //
  2877. // i++;
  2878. // j++;
  2879. // }
  2880. // }
  2881. // if (INADOUBLEQUOTE == YES)
  2882. // {
  2883. // printf("Error: Uneven double quote. The double quote that started on line %d is missing a double quote \".\n", DOUBLEQUOTEBEGANON);
  2884. // INADOUBLEQUOTE = NO;
  2885. // }
  2886. // if (HEXSYNTAXERROR == YES)
  2887. // {
  2888. // printf("Error: Syntax error. The hexidecimal number on line %d is not acceptable.\n", HEXSYNTAXERRORBEGANON);
  2889. // HEXSYNTAXERROR = NO;
  2890. // }
  2891. // }
  2892. //
  2893. // else if (array[i] == '[')
  2894. // {
  2895. // LeftBrackets++;
  2896. // EXTRABRACKETONLINE = LINE;
  2897. //
  2898. // i++;
  2899. // j++;
  2900. // if (LeftBrackets - RightBrackets > 1)
  2901. // {
  2902. // printf("Error: Uneven brackets. An extra [ was found on line %d.\n", EXTRABRACKETONLINE);
  2903. // }
  2904. // }
  2905. // else if (array[i] == ']')
  2906. // {
  2907. // RightBrackets++;
  2908. // EXTRABRACKETONLINE = LINE;
  2909. //
  2910. // i++;
  2911. // j++;
  2912. // if (RightBrackets - LeftBrackets > 0)
  2913. // {
  2914. // printf("Error: Uneven brackets. An extra ] was found on line %d.\n", EXTRABRACKETONLINE);
  2915. // }
  2916. // }
  2917. //
  2918. // else if (array[i] == '(')
  2919. // {
  2920. // LeftParanthesis++;
  2921. // EXTRAPARENTHESISONLINE = LINE;
  2922. //
  2923. // i++;
  2924. // j++;
  2925. // }
  2926. // else if (array[i] == ')')
  2927. // {
  2928. // RightParenthesis++;
  2929. // EXTRAPARENTHESISONLINE = LINE;
  2930. //
  2931. // i++;
  2932. // j++;
  2933. // if (RightParenthesis > LeftParanthesis)
  2934. // {
  2935. // printf("Error: Uneven Right Parenthesis. An extra ) was found on line %d.\n", EXTRAPARENTHESISONLINE);
  2936. // }
  2937. // }
  2938. //
  2939. // else if (array[i] == '{')
  2940. // {
  2941. // LeftBraces++;
  2942. // EXTRALEFTBRACEONLINE = LINE;
  2943. //
  2944. // i++;
  2945. // j++;
  2946. // }
  2947. // else if (array[i] == '}')
  2948. // {
  2949. // RightBraces++;
  2950. // EXTRARIGHTBRACEONLINE = LINE;
  2951. //
  2952. // i++;
  2953. // j++;
  2954. // if (RightBraces > LeftBraces)
  2955. // {
  2956. // printf("Error: Uneven Right Braces. An extra } was found on line %d.\n", EXTRARIGHTBRACEONLINE);
  2957. // }
  2958. // }
  2959. // else if (array[i] != '\0' && array[i] != EOF)
  2960. // {
  2961. // i++;
  2962. // j++;
  2963. // }
  2964. // else
  2965. // ;
  2966. // }
  2967. //
  2968. // if (LeftBraces > RightBraces)
  2969. // {
  2970. // printf("Error: Uneven Left Braces. An extra { was found on line %d.\n", EXTRALEFTBRACEONLINE);
  2971. // }
  2972. //
  2973. // output[j] = '\0'; //DONE
  2974. // printf("\n%s\n", output); //PRINT OUTPUT
  2975. //}
  2976. //
  2977. //void checkCommentsAfterSemicolon(char array[]); //line 0
  2978. //void checkComments(char array[]);
  2979. //void checkSingleQuotes(char array[]);
  2980. //void checkDoubleQuotes(char array[]);
  2981. //void checkHexidecimalEscapeSequences(char array[]);
  2982. //void checkBrackets(char array[]);
  2983. //void checkParenthesis(char array[]);
  2984. //void checkBraces(char array[]);
  2985. //
  2986. //#define MAXARRAYSIZE 50000
  2987. //main()
  2988. //{
  2989. // int c;
  2990. // char array[MAXARRAYSIZE];
  2991. // int i = 0;
  2992. // //octal (come back)
  2993. //
  2994. // while ((c = getchar()) != EOF)
  2995. // {
  2996. // array[i] = c;
  2997. // i++;
  2998. // }
  2999. // array[i] = '\0';
  3000. //
  3001. // printf("\n");
  3002. // //line 0
  3003. // checkCommentsAfterSemicolon(array);
  3004. //
  3005. // checkComments(array);
  3006. //
  3007. // checkSingleQuotes(array);
  3008. //
  3009. // checkDoubleQuotes(array);
  3010. //
  3011. // checkHexidecimalEscapeSequences(array); //line 34
  3012. //
  3013. // checkBrackets(array);
  3014. //
  3015. // checkParenthesis(array);
  3016. //
  3017. // printf("\ndone\n");
  3018. //}
  3019. //
  3020. //void checkCommentsAfterSemicolon(char array[])
  3021. //{
  3022. // int i = 0;
  3023. // char syntaxerror[MAXARRAYSIZE];
  3024. // int k = 0;
  3025. // int STAR = NO;
  3026. // int UNBALANCEDCOMMENT = NO;
  3027. // int INACOMMENT = NO;
  3028. // int COMMENTBEGANON = 0;
  3029. // int COMMENTENDEDON = 0;
  3030. // int LINE = 0;
  3031. // int SYNTAXERROR = NO;
  3032. // int SYNTAXERRORONLINE = 0;
  3033. // int INASINGLEQUOTE = NO;
  3034. // int INADOUBLEQUOTE = NO;
  3035. //
  3036. // while (array[i] != '\0' && array[i] != EOF)
  3037. // {
  3038. // if (array[i] == ';') //line 34
  3039. // {
  3040. // i++;
  3041. // 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
  3042. // {
  3043. // if (INACOMMENT == NO && array[i] != '/' && array[i] != ' ' && array[i] != '\t') //CASE 6
  3044. // {
  3045. // while (array[i] != '/' && array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
  3046. // {
  3047. // syntaxerror[k] = array[i];
  3048. // SYNTAXERRORONLINE = LINE;
  3049. // k++;
  3050. // i++;
  3051. // }
  3052. // syntaxerror[k] = ' ';
  3053. // k++;
  3054. // SYNTAXERROR = YES; //CASE 6 DONE
  3055. // }
  3056. //
  3057. // else if (array[i] == '/') //CASE 1 2 3 4 5
  3058. // {
  3059. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  3060. //
  3061. // COMMENTBEGANON = LINE;
  3062. //
  3063. // if (array[i + 1] == '/') //CASE 4
  3064. // {
  3065. // UNBALANCEDCOMMENT = NO;
  3066. // INACOMMENT = YES;
  3067. // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
  3068. // {
  3069. // i++;
  3070. // }
  3071. // INACOMMENT = NO;
  3072. // }
  3073. //
  3074. // else if (array[i + 1] == '*') //CASE 5
  3075. // {
  3076. // UNBALANCEDCOMMENT = YES;
  3077. // INACOMMENT = YES;
  3078. // COMMENTBEGANON = LINE;
  3079. // i++;
  3080. // i++;
  3081. // while (INACOMMENT == YES && array[i] != '\0' && array[i] != EOF)
  3082. // {
  3083. // if (array[i] == '\n')
  3084. // {
  3085. // LINE++; //LINE COUNTER
  3086. // i++;
  3087. // }
  3088. // else if (array[i] == '*')
  3089. // {
  3090. // i++;
  3091. // STAR = YES;
  3092. // }
  3093. // else if (array[i] == '/' && STAR == YES)
  3094. // {
  3095. // i++;
  3096. // INACOMMENT = NO;
  3097. // UNBALANCEDCOMMENT = NO;
  3098. // STAR = NO;
  3099. // }
  3100. // else
  3101. // {
  3102. // i++;
  3103. // STAR = NO;
  3104. // }
  3105. // }
  3106. // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
  3107. // {
  3108. // printf("Multi-line comment started on line %d and ended on %d.\n", COMMENTBEGANON, COMMENTENDEDON); //CASE 5 DONE
  3109. // /*test
  3110. // */
  3111. // }
  3112. // }
  3113. //
  3114. // else
  3115. // {
  3116. // printf("5\n");
  3117. // syntaxerror[k] = array[i];
  3118. // i++;
  3119. // k++;
  3120. //
  3121. // while (array[i] != '\n' && array[i] != '/' && array[i] != '\0' && array[i] != EOF)
  3122. // {
  3123. // syntaxerror[k] = array[i]; // / a b
  3124. // i++;
  3125. // k++;
  3126. // SYNTAXERRORONLINE = LINE;
  3127. // }
  3128. // SYNTAXERROR = YES;
  3129. // }
  3130. // }
  3131. // else
  3132. // i++;
  3133. // }
  3134. //
  3135. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  3136. // {
  3137. // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
  3138. //
  3139. // if (array[i] == '\0')
  3140. // {
  3141. // //printf("\n%s\n", output);
  3142. // printf("null\n");
  3143. // }
  3144. //
  3145. // if (array[i] == EOF)
  3146. // {
  3147. // printf("EOF\n");
  3148. // }
  3149. //
  3150. // if (array[i] == '\n')
  3151. // {
  3152. // LINE++;
  3153. // }
  3154. //
  3155. // i++;
  3156. // UNBALANCEDCOMMENT = NO;
  3157. // }
  3158. //
  3159. // else if (UNBALANCEDCOMMENT == NO) //CASE 2 WHITESPACE DONE //CASE 3 NEWLINE DONE //CASE 4 // DONE //CASE 5 /**/ DONE
  3160. // {
  3161. // if (array[i] == '\n')
  3162. // {
  3163. // LINE++;
  3164. // }
  3165. // i++;
  3166. // }
  3167. // if (SYNTAXERROR == YES) //CASE 6 DONE
  3168. // {
  3169. // syntaxerror[k] = '\0';
  3170. // printf("Error: Syntax error. Text not in a comment on line %d. Code: %s\n", SYNTAXERRORONLINE, syntaxerror);
  3171. // syntaxerror[0] = '\0';
  3172. // k = 0;
  3173. // if (array[i] == '\n')
  3174. // {
  3175. // LINE++;
  3176. // }
  3177. //
  3178. // i++;
  3179. // SYNTAXERROR = NO;
  3180. // }
  3181. // }
  3182. // else if (array[i] == '/') //3 CASES
  3183. // {
  3184. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  3185. //
  3186. // COMMENTBEGANON = LINE;
  3187. //
  3188. // if (array[i + 1] == '/') //CASE 4
  3189. // {
  3190. // UNBALANCEDCOMMENT = NO;
  3191. // INACOMMENT = YES;
  3192. // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
  3193. // {
  3194. // i++;
  3195. // }
  3196. // INACOMMENT = NO;
  3197. // }
  3198. //
  3199. // else if (array[i + 1] == '*') //CASE 3
  3200. // {
  3201. // UNBALANCEDCOMMENT = YES;
  3202. //
  3203. // INACOMMENT = YES;
  3204. //
  3205. // COMMENTBEGANON = LINE;
  3206. // i++;
  3207. // i++;
  3208. // while (INACOMMENT == YES && array[i] != '\0' && array[i] != EOF)
  3209. // {
  3210. // if (array[i] == '\n')
  3211. // {
  3212. // LINE++; //LINE COUNTER
  3213. // i++;
  3214. // }
  3215. // else if (array[i] == '*')
  3216. // {
  3217. // i++;
  3218. // STAR = YES;
  3219. // }
  3220. // else if (array[i] == '/' && STAR == YES)
  3221. // {
  3222. // i++;
  3223. // INACOMMENT = NO;
  3224. // UNBALANCEDCOMMENT = NO;
  3225. // COMMENTENDEDON = LINE;
  3226. // STAR = NO;
  3227. // }
  3228. // else
  3229. // {
  3230. // i++;
  3231. // STAR = NO;
  3232. // }
  3233. // }
  3234. // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
  3235. // {
  3236. // printf("Multi-line comment started on line %d and ended on %d.\n", COMMENTBEGANON, COMMENTENDEDON); //style
  3237. // }
  3238. // }
  3239. // else
  3240. // ; //NEXT CHARACTER (' ') IS HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
  3241. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  3242. // {
  3243. // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
  3244. //
  3245. // if (array[i] == '\n')
  3246. // {
  3247. // LINE++;
  3248. // }
  3249. //
  3250. // i++;
  3251. // UNBALANCEDCOMMENT = NO;
  3252. // }
  3253. //
  3254. // else if (UNBALANCEDCOMMENT == NO) //CASE 2
  3255. // {
  3256. //
  3257. // if (array[i] == '\n')
  3258. // {
  3259. // LINE++;
  3260. // }
  3261. // i++;
  3262. // }
  3263. // }
  3264. // 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
  3265. // {
  3266. // INASINGLEQUOTE = YES;
  3267. // i++;
  3268. //
  3269. // 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.
  3270. // {
  3271. // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
  3272. // {
  3273. // INASINGLEQUOTE = NO;
  3274. // i++;
  3275. // }
  3276. // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
  3277. // {
  3278. // INASINGLEQUOTE = NO;
  3279. // i++;
  3280. // }
  3281. // else
  3282. // {
  3283. // i++;
  3284. // }
  3285. // }
  3286. // if (INASINGLEQUOTE == YES)
  3287. // {
  3288. // INASINGLEQUOTE = NO;
  3289. // }
  3290. // }
  3291. // else if (array[i] == '"' && array[i - 1] != '\\')
  3292. // {
  3293. // INADOUBLEQUOTE = YES;
  3294. // i++;
  3295. // while (INADOUBLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //could use one variable INAQUOTE
  3296. // {
  3297. // if (array[i] == '"' && array[i - 1] != '\\')
  3298. // {
  3299. // INADOUBLEQUOTE = NO;
  3300. // i++;
  3301. // }
  3302. // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
  3303. // {
  3304. // INADOUBLEQUOTE = NO;
  3305. // i++;
  3306. // }
  3307. // else
  3308. // {
  3309. // i++;
  3310. // }
  3311. // }
  3312. // if (INADOUBLEQUOTE == YES)
  3313. // {
  3314. // INADOUBLEQUOTE = NO;
  3315. // }
  3316. // }
  3317. // else
  3318. // {
  3319. // if (array[i] == '\n')
  3320. // {
  3321. // LINE++;
  3322. // }
  3323. // i++;
  3324. // }
  3325. // }
  3326. //}
  3327. //
  3328. //void checkComments(char array[])
  3329. //{
  3330. // int i = 0;
  3331. // int STAR = NO;
  3332. // int UNBALANCEDCOMMENT = NO;
  3333. // int INACOMMENT = NO;
  3334. // int COMMENTBEGANON = 0;
  3335. // int COMMENTENDEDON = 0;
  3336. // int LINE = 0;
  3337. // int INASINGLEQUOTE = NO;
  3338. // int INADOUBLEQUOTE = NO;
  3339. //
  3340. // while (array[i] != '\0' && array[i] != EOF)
  3341. // {
  3342. // if (array[i] == '/') //3 CASES
  3343. // {
  3344. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  3345. //
  3346. // COMMENTBEGANON = LINE;
  3347. //
  3348. // if (array[i + 1] == '/') //CASE 4
  3349. // {
  3350. // UNBALANCEDCOMMENT = NO;
  3351. // INACOMMENT = YES;
  3352. // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
  3353. // {
  3354. // i++;
  3355. // }
  3356. // INACOMMENT = NO;
  3357. // }
  3358. //
  3359. // else if (array[i + 1] == '*') //CASE 3
  3360. // {
  3361. // UNBALANCEDCOMMENT = YES;
  3362. //
  3363. // INACOMMENT = YES;
  3364. //
  3365. // COMMENTBEGANON = LINE;
  3366. // i++;
  3367. // i++;
  3368. // while (INACOMMENT == YES && array[i] != '\0' && array[i] != EOF)
  3369. // {
  3370. // if (array[i] == '\n')
  3371. // {
  3372. // LINE++; //LINE COUNTER
  3373. // i++;
  3374. // }
  3375. // else if (array[i] == '*')
  3376. // {
  3377. // i++;
  3378. // STAR = YES;
  3379. // }
  3380. // else if (array[i] == '/' && STAR == YES)
  3381. // {
  3382. // i++;
  3383. // INACOMMENT = NO;
  3384. // UNBALANCEDCOMMENT = NO;
  3385. // COMMENTENDEDON = LINE;
  3386. // STAR = NO;
  3387. // }
  3388. // else
  3389. // {
  3390. // i++;
  3391. // STAR = NO;
  3392. // }
  3393. // }
  3394. // if (INACOMMENT == NO && UNBALANCEDCOMMENT == NO)
  3395. // {
  3396. // printf("Multi-line comment started on line %d and ended on %d.\n", COMMENTBEGANON, COMMENTENDEDON); //style
  3397. // }
  3398. // }
  3399. // else
  3400. // ; //NEXT CHARACTER (' ') IS HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
  3401. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  3402. // {
  3403. // printf("Error: Unbalanced comment on line %d. Missing / or *.\n", COMMENTBEGANON);
  3404. //
  3405. // if (array[i] == '\n')
  3406. // {
  3407. // LINE++;
  3408. // }
  3409. //
  3410. // i++;
  3411. // UNBALANCEDCOMMENT = NO;
  3412. // }
  3413. //
  3414. // else if (UNBALANCEDCOMMENT == NO) //CASE 2
  3415. // {
  3416. //
  3417. // if (array[i] == '\n')
  3418. // {
  3419. // LINE++;
  3420. // }
  3421. // i++;
  3422. // }
  3423. // }
  3424. // 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
  3425. // {
  3426. // INASINGLEQUOTE = YES;
  3427. // i++;
  3428. //
  3429. // 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.
  3430. // {
  3431. // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
  3432. // {
  3433. // INASINGLEQUOTE = NO;
  3434. // i++;
  3435. // }
  3436. // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
  3437. // {
  3438. // INASINGLEQUOTE = NO;
  3439. // i++;
  3440. // }
  3441. // else
  3442. // {
  3443. // i++;
  3444. // }
  3445. // }
  3446. // if (INASINGLEQUOTE == YES)
  3447. // {
  3448. // INASINGLEQUOTE = NO;
  3449. // }
  3450. // }
  3451. // else if (array[i] == '"' && array[i - 1] != '\\')
  3452. // {
  3453. // INADOUBLEQUOTE = YES;
  3454. // i++;
  3455. // while (INADOUBLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //could use one variable INAQUOTE
  3456. // {
  3457. // if (array[i] == '"' && array[i - 1] != '\\')
  3458. // {
  3459. // INADOUBLEQUOTE = NO;
  3460. // i++;
  3461. // }
  3462. // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
  3463. // {
  3464. // INADOUBLEQUOTE = NO;
  3465. // i++;
  3466. // }
  3467. // else
  3468. // {
  3469. // i++;
  3470. // }
  3471. // }
  3472. // if (INADOUBLEQUOTE == YES)
  3473. // {
  3474. // INADOUBLEQUOTE = NO;
  3475. // }
  3476. // }
  3477. // else
  3478. // {
  3479. // if (array[i] == '\n')
  3480. // {
  3481. // LINE++;
  3482. // }
  3483. // i++;
  3484. // }
  3485. // }
  3486. //}
  3487. //
  3488. //void checkSingleQuotes(char array[])
  3489. //{
  3490. // int i = 0;
  3491. // char syntaxerror[MAXARRAYSIZE];
  3492. // int k = 0;
  3493. // int STAR = NO;
  3494. // int UNBALANCEDCOMMENT = NO;
  3495. // int INACOMMENT = NO;
  3496. // int LINE = 0;
  3497. // int INASINGLEQUOTE = NO;
  3498. // int SINGLEQUOTEBEGANON = 0;
  3499. // int INADOUBLEQUOTE = NO;
  3500. //
  3501. // while (array[i] != '\0' && array[i] != EOF)
  3502. // {
  3503. // 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*/
  3504. // {
  3505. // INASINGLEQUOTE = YES;
  3506. // SINGLEQUOTEBEGANON = LINE;
  3507. // i++;
  3508. //
  3509. // 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.
  3510. // {
  3511. // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
  3512. // {
  3513. // INASINGLEQUOTE = NO;
  3514. // i++;
  3515. // }
  3516. // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
  3517. // {
  3518. // INASINGLEQUOTE = NO;
  3519. // i++;
  3520. // }
  3521. // else
  3522. // {
  3523. // i++;
  3524. // }
  3525. // }
  3526. // if (INASINGLEQUOTE == YES)
  3527. // {
  3528. // printf("Error: Uneven single quote. The single quote that started on line %d is missing a single quote \'.\n", SINGLEQUOTEBEGANON);
  3529. // INASINGLEQUOTE = NO;
  3530. // }
  3531. // }
  3532. // else if (array[i] == '"' && array[i - 1] != '\\')
  3533. // {
  3534. // INADOUBLEQUOTE = YES;
  3535. // i++;
  3536. // while (INADOUBLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //could use one variable INAQUOTE
  3537. // {
  3538. // if (array[i] == '"' && array[i - 1] != '\\')
  3539. // {
  3540. // INADOUBLEQUOTE = NO;
  3541. // i++;
  3542. // }
  3543. // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
  3544. // {
  3545. // INADOUBLEQUOTE = NO;
  3546. // i++;
  3547. // }
  3548. // else
  3549. // {
  3550. // i++;
  3551. // }
  3552. // }
  3553. // if (INADOUBLEQUOTE == YES)
  3554. // {
  3555. // INADOUBLEQUOTE = NO;
  3556. // }
  3557. // }
  3558. // else if (array[i] == '/') //3 CASES
  3559. // {
  3560. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  3561. //
  3562. // if (array[i + 1] == '/') //CASE 4
  3563. // {
  3564. // UNBALANCEDCOMMENT = NO;
  3565. // INACOMMENT = YES;
  3566. // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
  3567. // {
  3568. // i++;
  3569. // }
  3570. // INACOMMENT = NO;
  3571. // }
  3572. //
  3573. // else if (array[i + 1] == '*') //CASE 3
  3574. // {
  3575. // UNBALANCEDCOMMENT = YES;
  3576. // INACOMMENT = YES;
  3577. // i++;
  3578. // i++;
  3579. // while (INACOMMENT == YES && array[i] != '\0' && array[i] != EOF)
  3580. // {
  3581. // if (array[i] == '\n')
  3582. // {
  3583. // LINE++; //LINE COUNTER
  3584. // i++;
  3585. // }
  3586. // else if (array[i] == '*')
  3587. // {
  3588. // i++;
  3589. // STAR = YES;
  3590. // }
  3591. // else if (array[i] == '/' && STAR == YES)
  3592. // {
  3593. // i++;
  3594. // INACOMMENT = NO;
  3595. // UNBALANCEDCOMMENT = NO;
  3596. // STAR = NO;
  3597. // }
  3598. // else
  3599. // {
  3600. // i++;
  3601. // STAR = NO;
  3602. // }
  3603. // }
  3604. // }
  3605. // else
  3606. // {
  3607. // ;//NEXT CHARACTER IS HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
  3608. // /*i++;
  3609. // j++;*/
  3610. // }
  3611. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  3612. // {
  3613. // if (array[i] == '\n')
  3614. // {
  3615. // LINE++;
  3616. // }
  3617. // i++;
  3618. // UNBALANCEDCOMMENT = NO;
  3619. // }
  3620. //
  3621. // else if (UNBALANCEDCOMMENT == NO) //CASE 2
  3622. // {
  3623. // if (array[i] == '\n')
  3624. // {
  3625. // LINE++;
  3626. // }
  3627. // i++;
  3628. // }
  3629. // }
  3630. // else
  3631. // {
  3632. // if (array[i] == '\n')
  3633. // {
  3634. // LINE++;
  3635. // }
  3636. // i++;
  3637. // }
  3638. // }
  3639. //}
  3640. //
  3641. //void checkDoubleQuotes(char array[])
  3642. //{
  3643. // int i = 0;
  3644. // char syntaxerror[MAXARRAYSIZE];
  3645. // int k = 0;
  3646. // int STAR = NO;
  3647. // int UNBALANCEDCOMMENT = NO;
  3648. // int INACOMMENT = NO;
  3649. // int LINE = 0;
  3650. // int INADOUBLEQUOTE = NO;
  3651. // int DOUBLEQUOTEBEGANON = 0;
  3652. // int INASINGLEQUOTE = NO;
  3653. //
  3654. // while (array[i] != '\0' && array[i] != EOF)
  3655. // {
  3656. // if (array[i] == '"' && array[i - 1] != '\\')
  3657. // {
  3658. // INADOUBLEQUOTE = YES;
  3659. // DOUBLEQUOTEBEGANON = LINE; //could use one variable QUOTEBEGANON
  3660. // i++;
  3661. // while (INADOUBLEQUOTE == YES && array[i] != '\n' && array[i] != '\0' && array[i] != EOF) //could use one variable INAQUOTE
  3662. // {
  3663. // if (array[i] == '"' && array[i - 1] != '\\')
  3664. // {
  3665. // INADOUBLEQUOTE = NO;
  3666. // i++;
  3667. // }
  3668. // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
  3669. // {
  3670. // INADOUBLEQUOTE = NO;
  3671. // i++;
  3672. // }
  3673. // else
  3674. // {
  3675. // i++;
  3676. // }
  3677. // }
  3678. // if (INADOUBLEQUOTE == YES)
  3679. // {
  3680. // printf("Error: Uneven double quote. The double quote that started on line %d is missing a double quote \".\n", DOUBLEQUOTEBEGANON);
  3681. // INADOUBLEQUOTE = NO;
  3682. // }
  3683. // }
  3684. // 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
  3685. // {
  3686. // INASINGLEQUOTE = YES;
  3687. // i++;
  3688. //
  3689. // 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.
  3690. // {
  3691. // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
  3692. // {
  3693. // INASINGLEQUOTE = NO;
  3694. // i++;
  3695. // }
  3696. // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
  3697. // {
  3698. // INASINGLEQUOTE = NO;
  3699. // i++;
  3700. // }
  3701. // else
  3702. // {
  3703. // i++;
  3704. // }
  3705. // }
  3706. // if (INASINGLEQUOTE == YES)
  3707. // {
  3708. // INASINGLEQUOTE = NO;
  3709. // }
  3710. // }
  3711. // else if (array[i] == '/') //3 CASES
  3712. // {
  3713. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  3714. //
  3715. // if (array[i + 1] == '/') //CASE 4
  3716. // {
  3717. // UNBALANCEDCOMMENT = NO;
  3718. // INACOMMENT = YES;
  3719. // while (array[i] != '\n' && array[i] != '\0' && array[i] != EOF)
  3720. // {
  3721. // i++;
  3722. // }
  3723. // INACOMMENT = NO;
  3724. // }
  3725. //
  3726. // else if (array[i + 1] == '*') //CASE 3
  3727. // {
  3728. // UNBALANCEDCOMMENT = YES;
  3729. // INACOMMENT = YES;
  3730. // i++;
  3731. // i++;
  3732. // while (INACOMMENT == YES && array[i] != '\0' && array[i] != EOF)
  3733. // {
  3734. // if (array[i] == '\n')
  3735. // {
  3736. // LINE++; //LINE COUNTER
  3737. // i++;
  3738. // }
  3739. // else if (array[i] == '*')
  3740. // {
  3741. // i++;
  3742. // STAR = YES;
  3743. // }
  3744. // else if (array[i] == '/' && STAR == YES)
  3745. // {
  3746. // i++;
  3747. // INACOMMENT = NO;
  3748. // UNBALANCEDCOMMENT = NO;
  3749. // STAR = NO;
  3750. // }
  3751. // else
  3752. // {
  3753. // i++;
  3754. // STAR = NO;
  3755. // }
  3756. // }
  3757. // }
  3758. // else
  3759. // {
  3760. // ;//NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT BLOCK
  3761. // /*i++;
  3762. // j++;*/
  3763. // }
  3764. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  3765. // {
  3766. // if (array[i] == '\n')
  3767. // {
  3768. // LINE++;
  3769. // }
  3770. // i++;
  3771. // UNBALANCEDCOMMENT = NO;
  3772. // }
  3773. //
  3774. // else if (UNBALANCEDCOMMENT == NO) //CASE 2
  3775. // {
  3776. // if (array[i] == '\n')
  3777. // {
  3778. // LINE++;
  3779. // }
  3780. // i++;
  3781. // }
  3782. // }
  3783. // else
  3784. // {
  3785. // if (array[i] == '\n')
  3786. // {
  3787. // LINE++;
  3788. // }
  3789. // i++;
  3790. // }
  3791. // }
  3792. //}
  3793. //
  3794. //void checkHexidecimalEscapeSequences(char array[])
  3795. //{
  3796. // int i = 0;
  3797. // char syntaxerror[MAXARRAYSIZE];
  3798. // int k = 0;
  3799. // int STAR = NO;
  3800. // int UNBALANCEDCOMMENT = NO;
  3801. // int INACOMMENT = NO;
  3802. // int LINE = 0;
  3803. // int INASINGLEQUOTE = NO;
  3804. // int INADOUBLEQUOTE = NO;
  3805. // int HEXSYNTAXERROR = NO;
  3806. // int HEXSYNTAXERRORBEGANON = 0;
  3807. //
  3808. // while (array[i] != '\0' && array[i] != EOF)
  3809. // {
  3810. // 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
  3811. // {
  3812. // INASINGLEQUOTE = YES;
  3813. // i++;
  3814. //
  3815. // while (INASINGLEQUOTE == YES && array[i] != '\n') //if hex number must be 0-9 A-F until a space is read.
  3816. // {
  3817. // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
  3818. // {
  3819. // INASINGLEQUOTE = NO;
  3820. // i++;
  3821. // }
  3822. // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
  3823. // {
  3824. // INASINGLEQUOTE = NO;
  3825. // i++;
  3826. // }
  3827. // else if (array[i] == 'x' && array[i - 1] == '\\' && array[i - 2] != '\\')
  3828. // {
  3829. // i++;
  3830. // while (array[i] != ' ' && array[i] != '\'' && array[i] != '\n')
  3831. // {
  3832. // 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')
  3833. // {
  3834. // HEXSYNTAXERROR = YES;
  3835. // HEXSYNTAXERRORBEGANON = LINE;
  3836. // }
  3837. // i++;
  3838. // }
  3839. // }
  3840. // else
  3841. // {
  3842. // i++;
  3843. // }
  3844. // }
  3845. // if (INASINGLEQUOTE == YES)
  3846. // {
  3847. // INASINGLEQUOTE = NO;
  3848. // }
  3849. // if (HEXSYNTAXERROR == YES)
  3850. // {
  3851. // printf("Error: Syntax error. The hexidecimal number in the single quotes on line %d is not acceptable.\n", HEXSYNTAXERRORBEGANON);
  3852. // HEXSYNTAXERROR = NO;
  3853. // }
  3854. // }
  3855. // else if (array[i] == '"' && array[i - 1] != '\\')
  3856. // {
  3857. // INADOUBLEQUOTE = YES;
  3858. // i++;
  3859. // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
  3860. // {
  3861. // if (array[i] == '"' && array[i - 1] != '\\')
  3862. // {
  3863. // INADOUBLEQUOTE = NO;
  3864. // i++;
  3865. // }
  3866. // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
  3867. // {
  3868. // INADOUBLEQUOTE = NO;
  3869. // i++;
  3870. // }
  3871. // else if (array[i] == 'x' && array[i - 1] == '\\' && array[i - 2] != '\\')
  3872. // {
  3873. // i++;
  3874. // while (array[i] != ' ' && array[i] != '\'' && array[i] != '\n')
  3875. // {
  3876. // 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')
  3877. // {
  3878. // HEXSYNTAXERROR = YES;
  3879. // HEXSYNTAXERRORBEGANON = LINE;
  3880. // }
  3881. // i++;
  3882. // }
  3883. // }
  3884. // else
  3885. // {
  3886. // i++;
  3887. // }
  3888. // }
  3889. // if (INADOUBLEQUOTE == YES)
  3890. // {
  3891. // INADOUBLEQUOTE = NO;
  3892. // }
  3893. // if (HEXSYNTAXERROR == YES)
  3894. // {
  3895. // printf("Error: Syntax error. The hexidecimal number in the double quotes on line %d is not acceptable.\n", HEXSYNTAXERRORBEGANON);
  3896. // HEXSYNTAXERROR = NO;
  3897. // }
  3898. // }
  3899. // else if (array[i] == '/') //3 CASES
  3900. // {
  3901. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  3902. //
  3903. // if (array[i + 1] == '/') //CASE 4
  3904. // {
  3905. // UNBALANCEDCOMMENT = NO;
  3906. // INACOMMENT = YES;
  3907. // while (array[i] != '\n')
  3908. // {
  3909. // i++;
  3910. // }
  3911. // INACOMMENT = NO;
  3912. // }
  3913. //
  3914. // else if (array[i + 1] == '*') //CASE 3
  3915. // {
  3916. // UNBALANCEDCOMMENT = YES;
  3917. // INACOMMENT = YES;
  3918. // i++;
  3919. // i++;
  3920. // while (INACOMMENT == YES && array[i] != '\0')
  3921. // {
  3922. // if (array[i] == '\n')
  3923. // {
  3924. // LINE++; //LINE COUNTER
  3925. // i++;
  3926. // }
  3927. // else if (array[i] == '*')
  3928. // {
  3929. // i++;
  3930. // STAR = YES;
  3931. // }
  3932. // else if (array[i] == '/' && STAR == YES)
  3933. // {
  3934. // i++;
  3935. // INACOMMENT = NO;
  3936. // UNBALANCEDCOMMENT = NO;
  3937. // STAR = NO;
  3938. // }
  3939. // else
  3940. // {
  3941. // i++;
  3942. // STAR = NO;
  3943. // }
  3944. // }
  3945. // }
  3946. // else
  3947. // {
  3948. // ;//NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
  3949. // /*i++;
  3950. // j++;*/
  3951. // }
  3952. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  3953. // {
  3954. // if (array[i] == '\n')
  3955. // {
  3956. // LINE++;
  3957. // }
  3958. // i++;
  3959. // UNBALANCEDCOMMENT = NO;
  3960. // }
  3961. //
  3962. // else if (UNBALANCEDCOMMENT == NO) //CASE 2
  3963. // {
  3964. // if (array[i] == '\n')
  3965. // {
  3966. // LINE++;
  3967. // }
  3968. // i++;
  3969. // }
  3970. // }
  3971. // else
  3972. // {
  3973. // if (array[i] == '\n')
  3974. // {
  3975. // LINE++;
  3976. // }
  3977. // i++;
  3978. // }
  3979. // }
  3980. //}
  3981. //
  3982. //void checkBrackets(char array[])
  3983. //{
  3984. // int i = 0;
  3985. // int LeftBrackets = 0;
  3986. // int RightBrackets = 0;
  3987. // int EXTRALEFTBRACKETONLINE = 0;
  3988. // int EXTRARIGHTBRACKETONLINE = 0;
  3989. // int STAR = NO;
  3990. // int UNBALANCEDCOMMENT = NO;
  3991. // int INACOMMENT = NO;
  3992. // int LINE = 0;
  3993. // int INASINGLEQUOTE = NO;
  3994. // int INADOUBLEQUOTE = NO;
  3995. //
  3996. // while (array[i] != '\0' && array[i] != EOF)
  3997. // {
  3998. // if (array[i] == '[')
  3999. // {
  4000. // LeftBrackets++;
  4001. // EXTRALEFTBRACKETONLINE = LINE;
  4002. // i++;
  4003. // if (LeftBrackets - RightBrackets > 1)
  4004. // {
  4005. // printf("Error: Uneven brackets. An extra [ was found on line %d.\n", EXTRALEFTBRACKETONLINE);
  4006. // }
  4007. // }
  4008. // else if (array[i] == ']')
  4009. // {
  4010. // RightBrackets++;
  4011. // EXTRARIGHTBRACKETONLINE = LINE;
  4012. // i++;
  4013. // if (RightBrackets - LeftBrackets > 0)
  4014. // {
  4015. // printf("Error: Uneven brackets. An extra ] was found on line %d.\n", EXTRARIGHTBRACKETONLINE);
  4016. // }
  4017. // }
  4018. // 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
  4019. // {
  4020. // INASINGLEQUOTE = YES;
  4021. // i++;
  4022. //
  4023. // while (INASINGLEQUOTE == YES && array[i] != '\n') //if hex number must be 0-9 A-F until a space is read.
  4024. // {
  4025. // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
  4026. // {
  4027. // INASINGLEQUOTE = NO;
  4028. // i++;
  4029. // }
  4030. // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
  4031. // {
  4032. // INASINGLEQUOTE = NO;
  4033. // i++;
  4034. // }
  4035. // else
  4036. // {
  4037. // i++;
  4038. // }
  4039. // }
  4040. // if (INASINGLEQUOTE == YES)
  4041. // {
  4042. // INASINGLEQUOTE = NO;
  4043. // }
  4044. // }
  4045. // else if (array[i] == '"' && array[i - 1] != '\\')
  4046. // {
  4047. // INADOUBLEQUOTE = YES;
  4048. // i++;
  4049. // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
  4050. // {
  4051. // if (array[i] == '"' && array[i - 1] != '\\')
  4052. // {
  4053. // INADOUBLEQUOTE = NO;
  4054. // i++;
  4055. // }
  4056. // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
  4057. // {
  4058. // INADOUBLEQUOTE = NO;
  4059. // i++;
  4060. // }
  4061. // else
  4062. // {
  4063. // i++;
  4064. // }
  4065. // }
  4066. // if (INADOUBLEQUOTE == YES)
  4067. // {
  4068. // INADOUBLEQUOTE = NO;
  4069. // }
  4070. // }
  4071. // else if (array[i] == '/') //3 CASES
  4072. // {
  4073. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  4074. //
  4075. // if (array[i + 1] == '/') //CASE 4
  4076. // {
  4077. // UNBALANCEDCOMMENT = NO;
  4078. // INACOMMENT = YES;
  4079. // while (array[i] != '\n')
  4080. // {
  4081. // i++;
  4082. // }
  4083. // INACOMMENT = NO;
  4084. // }
  4085. //
  4086. // else if (array[i + 1] == '*') //CASE 3
  4087. // {
  4088. // UNBALANCEDCOMMENT = YES;
  4089. // INACOMMENT = YES;
  4090. // i++;
  4091. // i++;
  4092. // while (INACOMMENT == YES && array[i] != '\0')
  4093. // {
  4094. // if (array[i] == '\n')
  4095. // {
  4096. // LINE++; //LINE COUNTER
  4097. // i++;
  4098. // }
  4099. // else if (array[i] == '*')
  4100. // {
  4101. // i++;
  4102. // STAR = YES;
  4103. // }
  4104. // else if (array[i] == '/' && STAR == YES)
  4105. // {
  4106. // i++;
  4107. // INACOMMENT = NO;
  4108. // UNBALANCEDCOMMENT = NO;
  4109. // STAR = NO;
  4110. // }
  4111. // else
  4112. // {
  4113. // i++;
  4114. // STAR = NO;
  4115. // }
  4116. // }
  4117. // }
  4118. // else
  4119. // {
  4120. // ; //NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
  4121. // /*i++;
  4122. // j++;*/
  4123. // }
  4124. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  4125. // {
  4126. // if (array[i] == '\n')
  4127. // {
  4128. // LINE++;
  4129. // }
  4130. // i++;
  4131. // UNBALANCEDCOMMENT = NO;
  4132. // }
  4133. // else if (UNBALANCEDCOMMENT == NO) //CASE 2
  4134. // {
  4135. // if (array[i] == '\n')
  4136. // {
  4137. // LINE++;
  4138. // }
  4139. // i++;
  4140. // }
  4141. // }
  4142. // else
  4143. // {
  4144. // if (array[i] == '\n')
  4145. // {
  4146. // LINE++;
  4147. // LeftBrackets = 0;
  4148. // RightBrackets = 0;
  4149. // }
  4150. // i++;
  4151. // }
  4152. // }
  4153. //}
  4154. //
  4155. //void checkParenthesis(char array[])
  4156. //{
  4157. // int i = 0;
  4158. // int LeftParenthesis = 0;
  4159. // int RightParenthesis = 0;
  4160. // int EXTRALEFTPARENTHESISONLINE = 0;
  4161. // int EXTRARIGHTPARENTHESISONLINE = 0;
  4162. // int STAR = NO;
  4163. // int UNBALANCEDCOMMENT = NO;
  4164. // int INACOMMENT = NO;
  4165. // int LINE = 0;
  4166. // int INASINGLEQUOTE = NO;
  4167. // int INADOUBLEQUOTE = NO;
  4168. //
  4169. // while (array[i] != '\0' && array[i] != EOF)
  4170. // {
  4171. // if (array[i] == '(')
  4172. // {
  4173. // LeftParenthesis++;
  4174. // EXTRALEFTPARENTHESISONLINE = LINE;
  4175. //
  4176. // i++;
  4177. // }
  4178. // else if (array[i] == ')')
  4179. // {
  4180. // RightParenthesis++;
  4181. // EXTRARIGHTPARENTHESISONLINE = LINE;
  4182. //
  4183. // i++;
  4184. // if (RightParenthesis > LeftParenthesis)
  4185. // {
  4186. // printf("Error: Uneven Right Parenthesis ). An extra ) was found on line %d.\n", EXTRARIGHTPARENTHESISONLINE);
  4187. // }
  4188. // }
  4189. // 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
  4190. // {
  4191. // INASINGLEQUOTE = YES;
  4192. // i++;
  4193. //
  4194. // while (INASINGLEQUOTE == YES && array[i] != '\n') //if hex number must be 0-9 A-F until a space is read.
  4195. // {
  4196. // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
  4197. // {
  4198. // INASINGLEQUOTE = NO;
  4199. // i++;
  4200. // }
  4201. // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
  4202. // {
  4203. // INASINGLEQUOTE = NO;
  4204. // i++;
  4205. // }
  4206. // else
  4207. // {
  4208. // i++;
  4209. // }
  4210. // }
  4211. // if (INASINGLEQUOTE == YES)
  4212. // {
  4213. // INASINGLEQUOTE = NO;
  4214. // }
  4215. // }
  4216. // else if (array[i] == '"' && array[i - 1] != '\\')
  4217. // {
  4218. // INADOUBLEQUOTE = YES;
  4219. // i++;
  4220. // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
  4221. // {
  4222. // if (array[i] == '"' && array[i - 1] != '\\')
  4223. // {
  4224. // INADOUBLEQUOTE = NO;
  4225. // i++;
  4226. // }
  4227. // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
  4228. // {
  4229. // INADOUBLEQUOTE = NO;
  4230. // i++;
  4231. // }
  4232. // else
  4233. // {
  4234. // i++;
  4235. // }
  4236. // }
  4237. // if (INADOUBLEQUOTE == YES)
  4238. // {
  4239. // INADOUBLEQUOTE = NO;
  4240. // }
  4241. // }
  4242. // else if (array[i] == '/') //3 CASES
  4243. // {
  4244. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  4245. //
  4246. // if (array[i + 1] == '/') //CASE 4
  4247. // {
  4248. // UNBALANCEDCOMMENT = NO;
  4249. // INACOMMENT = YES;
  4250. // while (array[i] != '\n')
  4251. // {
  4252. // i++;
  4253. // }
  4254. // INACOMMENT = NO;
  4255. // }
  4256. //
  4257. // else if (array[i + 1] == '*') //CASE 3
  4258. // {
  4259. // UNBALANCEDCOMMENT = YES;
  4260. // INACOMMENT = YES;
  4261. // i++;
  4262. // i++;
  4263. // while (INACOMMENT == YES && array[i] != '\0')
  4264. // {
  4265. // if (array[i] == '\n')
  4266. // {
  4267. // LINE++; //LINE COUNTER
  4268. // i++;
  4269. // }
  4270. // else if (array[i] == '*')
  4271. // {
  4272. // i++;
  4273. // STAR = YES;
  4274. // }
  4275. // else if (array[i] == '/' && STAR == YES)
  4276. // {
  4277. // i++;
  4278. // INACOMMENT = NO;
  4279. // UNBALANCEDCOMMENT = NO;
  4280. // STAR = NO;
  4281. // }
  4282. // else
  4283. // {
  4284. // i++;
  4285. // STAR = NO;
  4286. // }
  4287. // }
  4288. // }
  4289. // else
  4290. // {
  4291. // ; //NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
  4292. // /*i++;
  4293. // j++;*/
  4294. // }
  4295. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  4296. // {
  4297. // if (array[i] == '\n')
  4298. // {
  4299. // LINE++;
  4300. // }
  4301. // i++;
  4302. // UNBALANCEDCOMMENT = NO;
  4303. // }
  4304. // else if (UNBALANCEDCOMMENT == NO) //CASE 2
  4305. // {
  4306. // if (array[i] == '\n')
  4307. // {
  4308. // LINE++;
  4309. // }
  4310. // i++;
  4311. // }
  4312. // }
  4313. // else
  4314. // {
  4315. // if (array[i] == '\n')
  4316. // {
  4317. // LINE++;
  4318. // if (LeftParenthesis > RightParenthesis)
  4319. // {
  4320. // printf("Error: Uneven Left Parenthesis (. An extra ( was found on line %d.\n", EXTRALEFTPARENTHESISONLINE);
  4321. // }
  4322. // LeftParenthesis = 0;
  4323. // RightParenthesis = 0;
  4324. // }
  4325. // i++;
  4326. // }
  4327. // }
  4328. //}
  4329. //
  4330. //void checkBraces(char array[])
  4331. //{
  4332. // int i = 0;
  4333. // int LeftBraces = 0;
  4334. // int RightBraces = 0;
  4335. // int EXTRALEFTBRACEONLINE = 0;
  4336. // int EXTRARIGHTBRACEONLINE = 0;
  4337. // int STAR = NO;
  4338. // int UNBALANCEDCOMMENT = NO;
  4339. // int INACOMMENT = NO;
  4340. // int LINE = 0;
  4341. // int INASINGLEQUOTE = NO;
  4342. // int INADOUBLEQUOTE = NO;
  4343. //
  4344. // while (array[i] != '\0' && array[i] != EOF)
  4345. // {
  4346. // if (array[i] == '{')
  4347. // {
  4348. // LeftBraces++;
  4349. // EXTRALEFTBRACEONLINE = LINE;
  4350. // i++;
  4351. // }
  4352. // else if (array[i] == '}')
  4353. // {
  4354. // RightBraces++;
  4355. // EXTRARIGHTBRACEONLINE = LINE;
  4356. // i++;
  4357. // if (RightBraces - LeftBraces > 0)
  4358. // {
  4359. // printf("Error: Uneven Right Braces. An extra } was found on line %d.\n", EXTRARIGHTBRACEONLINE);
  4360. // }
  4361. // }
  4362. // 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
  4363. // {
  4364. // INASINGLEQUOTE = YES;
  4365. // i++;
  4366. //
  4367. // while (INASINGLEQUOTE == YES && array[i] != '\n') //if hex number must be 0-9 A-F until a space is read.
  4368. // {
  4369. // if (array[i] == '\'' && array[i - 1] != '\\') // && array[i-2] == "\""
  4370. // {
  4371. // INASINGLEQUOTE = NO;
  4372. // i++;
  4373. // }
  4374. // else if (array[i] == '\'' && array[i - 1] == '\\' && array[i - 2] == '\\')
  4375. // {
  4376. // INASINGLEQUOTE = NO;
  4377. // i++;
  4378. // }
  4379. // else
  4380. // {
  4381. // i++;
  4382. // }
  4383. // }
  4384. // if (INASINGLEQUOTE == YES)
  4385. // {
  4386. // INASINGLEQUOTE = NO;
  4387. // }
  4388. // }
  4389. // else if (array[i] == '"' && array[i - 1] != '\\')
  4390. // {
  4391. // INADOUBLEQUOTE = YES;
  4392. // i++;
  4393. // while (INADOUBLEQUOTE == YES && array[i] != '\n') //could use one variable INAQUOTE
  4394. // {
  4395. // if (array[i] == '"' && array[i - 1] != '\\')
  4396. // {
  4397. // INADOUBLEQUOTE = NO;
  4398. // i++;
  4399. // }
  4400. // else if (array[i] == '"' && array[i - 1] == '\\' && array[i - 2] == '\\')
  4401. // {
  4402. // INADOUBLEQUOTE = NO;
  4403. // i++;
  4404. // }
  4405. // else
  4406. // {
  4407. // i++;
  4408. // }
  4409. // }
  4410. // if (INADOUBLEQUOTE == YES)
  4411. // {
  4412. // INADOUBLEQUOTE = NO;
  4413. // }
  4414. // }
  4415. // else if (array[i] == '/') //3 CASES
  4416. // {
  4417. // UNBALANCEDCOMMENT = YES; //CASE 1 DONE
  4418. //
  4419. // if (array[i + 1] == '/') //CASE 4
  4420. // {
  4421. // UNBALANCEDCOMMENT = NO;
  4422. // INACOMMENT = YES;
  4423. // while (array[i] != '\n')
  4424. // {
  4425. // i++;
  4426. // }
  4427. // INACOMMENT = NO;
  4428. // }
  4429. //
  4430. // else if (array[i + 1] == '*') //CASE 3
  4431. // {
  4432. // UNBALANCEDCOMMENT = YES;
  4433. // INACOMMENT = YES;
  4434. // i++;
  4435. // i++;
  4436. // while (INACOMMENT == YES && array[i] != '\0')
  4437. // {
  4438. // if (array[i] == '\n')
  4439. // {
  4440. // LINE++; //LINE COUNTER
  4441. // i++;
  4442. // }
  4443. // else if (array[i] == '*')
  4444. // {
  4445. // i++;
  4446. // STAR = YES;
  4447. // }
  4448. // else if (array[i] == '/' && STAR == YES)
  4449. // {
  4450. // i++;
  4451. // INACOMMENT = NO;
  4452. // UNBALANCEDCOMMENT = NO;
  4453. // STAR = NO;
  4454. // }
  4455. // else
  4456. // {
  4457. // i++;
  4458. // STAR = NO;
  4459. // }
  4460. // }
  4461. // }
  4462. // else
  4463. // {
  4464. // ; //NEXT CHARACTER HANDLED IN THE UNBALANCED COMMENT CODE BLOCK
  4465. // /*i++;
  4466. // j++;*/
  4467. // }
  4468. // if (UNBALANCEDCOMMENT == YES) //CASE 1
  4469. // {
  4470. // if (array[i] == '\n')
  4471. // {
  4472. // LINE++;
  4473. // }
  4474. // i++;
  4475. // UNBALANCEDCOMMENT = NO;
  4476. // }
  4477. // else if (UNBALANCEDCOMMENT == NO) //CASE 2
  4478. // {
  4479. // if (array[i] == '\n')
  4480. // {
  4481. // LINE++;
  4482. // }
  4483. // i++;
  4484. // }
  4485. // }
  4486. // else
  4487. // {
  4488. // if (array[i] == '\n')
  4489. // {
  4490. // LINE++;
  4491. // }
  4492. // i++;
  4493. // }
  4494. // }
  4495. // if (LeftBraces > RightBraces)
  4496. // {
  4497. // printf("Error: Uneven amount of Left Braces {. An extra left brace ({) was found on line %d.\n", EXTRALEFTBRACEONLINE);
  4498. // printf("Total number of extra left braces: %d\n", LeftBraces - RightBraces);
  4499. // }
  4500. //}
  4501. //
  4502. //main()
  4503. //{
  4504. /*unsigned int c = 0;
  4505. c--;
  4506. printf("%d", c);*/
  4507. //unsigned int c = 1; //It's about the interpretation that printf gives to the parameter you pass.
  4508. //while (c > 0)
  4509. // c++;
  4510. //c--;
  4511. //printf("%d", c);
  4512. //while (c > 0)
  4513. // c++;
  4514. //printf("%d", c); //It's about the interpretation that printf gives to the parameter you pass.
  4515. //}
  4516. //main()
  4517. //{
  4518. // unsigned char c = 0; //1 bytes 2^8 unsigned char is q byte on this machine
  4519. // c--;
  4520. // printf("%u", c);
  4521. //}
  4522. //main()
  4523. //{
  4524. // signed char c = 1; //1 bytes -2^7 to 2^7 - 1 signed char is q byte on this machine
  4525. // while (c > 0)
  4526. // c++;
  4527. // c--;
  4528. // 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.
  4529. // printf("\n");
  4530. // printf("%d", c);
  4531. //}
  4532. //main()
  4533. //{
  4534. // unsigned int c = 0; //4 bytes 2^32 unsigned int is 4 bytes on this machine
  4535. // c--;
  4536. // printf("%u", c);
  4537. //}
  4538. //main()
  4539. //{
  4540. // signed int c = 1; //4 bytes -2^32 to 2^32 - 1 signed int is 4 bytes on this machine
  4541. // while (c > 0)
  4542. // c++;
  4543. // c--;
  4544. // printf("%d", c);
  4545. //}
  4546. //Experiment
  4547. //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.
  4548. //main()
  4549. //{
  4550. // char zero = 0;
  4551. // char A = 65;
  4552. // printf("%c", zero); //prints NULL and not 0
  4553. // printf("\n");
  4554. // printf("%d", zero); //prints the decimal representation of an integer (char 0; a small integer)
  4555. // printf("\n");
  4556. // printf("%c", A); //prints A and not 65
  4557. // printf("\n");
  4558. // printf("%d", A); //prints the decimal representation of an integer (char 65; a small integer)
  4559. //}
  4560. //Experiment
  4561. //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.
  4562. //main()
  4563. //{
  4564. // char zero = 0;
  4565. // char A = 65;
  4566. // printf("%c %d\n", A - zero, A - zero);
  4567. // printf("%c %d\n", A - 0, A - 0); //
  4568. // printf("%c %d\n", A - '0', A - '0');
  4569. // zero = '0';
  4570. // A = 65;
  4571. // printf("%c %d\n", A - zero, A - zero);
  4572. // printf("%c %d\n", A - 0, A - 0); //
  4573. // printf("%c %d\n", A - '0', A - '0');
  4574. //}
  4575. //Experiment
  4576. //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).
  4577. //main()
  4578. //{
  4579. // char zero = getchar();
  4580. // char A = 65;
  4581. // printf("%c %d\n", A - zero, A - zero);
  4582. // printf("%c %d\n", A - 0, A - 0); //
  4583. // printf("%c %d\n", A - '0', A - '0');
  4584. // zero = '0';
  4585. // A = 65;
  4586. // printf("%c %d\n", A - zero, A - zero);
  4587. // printf("%c %d\n", A - 0, A - 0); //
  4588. // printf("%c %d\n", A - '0', A - '0');
  4589. //}
  4590. //Experiment
  4591. //Valueable result: getchar grabs '0' and '1' not integers 0 and 1. getchar() GRABS CHARACTERS AND NOT INTEGERS!
  4592. //main()
  4593. //{
  4594. // char zero = getchar();
  4595. // char A = 65;
  4596. // printf("%c %d\n", A - (zero - '0'), A - (zero - '0'));
  4597. // printf("%c %d\n", A - 0, A - 0); //
  4598. // printf("%c %d\n", A - '0', A - '0');
  4599. // zero = '0';
  4600. // A = 65;
  4601. // printf("%c %d\n", A - zero, A - zero);
  4602. // printf("%c %d\n", A - 0, A - 0); //
  4603. // printf("%c %d\n", A - '0', A - '0');
  4604. //
  4605. // printf("%c %d\n", A - (zero - '0'), A - (zero - '0'));
  4606. // printf("%c %d\n", A - 0, A - 0);
  4607. // printf("%c %d\n", A - '0', A - '0');
  4608. //}
  4609. //Experiment
  4610. //Valueable result: arithmetic can be used to effectively produce integers from getchar(), like A - (zero - '0')
  4611. //main()
  4612. //{
  4613. // char zero = getchar();
  4614. // char A = 65;
  4615. // printf("%c %d\n", A - (zero - '0'), A - (zero - '0'));
  4616. // printf("%c %d\n", A - 0, A - 0); //
  4617. // printf("%c %d\n", A - '0', A - '0');
  4618. // zero = 'A';
  4619. // A = 65;
  4620. // printf("%c %d\n", A - zero, A - zero);
  4621. // printf("%c %d\n", A - 0, A - 0); //
  4622. // printf("%c %d\n", A - '0', A - '0');
  4623. //}
  4624. //Experiment
  4625. //Valueable result: chacacter read by getchar display character that are defined by small integers and can be implemented into arithmetic
  4626. //unsigned and signed short and long (int), float, double, and long double
  4627. //main()
  4628. //{
  4629. // unsigned short int number = 1; //short is 2 bytes 2^16 = 65535
  4630. // while (number > 0)
  4631. // number++;
  4632. // number--;
  4633. // printf("%u", number);
  4634. //}
  4635. //main()
  4636. //{
  4637. // signed short int number = 1; //short is 2 bytes 2^16-1 to 2^16-1 - 1 = -32768 to 32767
  4638. // while (number > 0)
  4639. // number++;
  4640. // number--;
  4641. // printf("%d", number);
  4642. //}
  4643. //main()
  4644. //{
  4645. // unsigned long int number = 0; //long is 4 bytes 2^32 = 4.29e9
  4646. // /*while (number > 0)
  4647. // number++;*/
  4648. // number--;
  4649. // printf("%u", number);
  4650. //}
  4651. //main()
  4652. //{
  4653. // signed long int number = 1; //long is 4 bytes 2^32-1 = -4.29e9/2 to 4.29e9/2 - 1
  4654. // while (number > 0)
  4655. // number++;
  4656. // //number--;
  4657. // printf("%d", number);
  4658. //}
  4659. //main()
  4660. //{
  4661. // float number = 1;
  4662. // while (number > 0)
  4663. // number++;
  4664. // number--;
  4665. // printf("%f", number);
  4666. //}
  4667. //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
  4668. //main()
  4669. //{
  4670. // double number = 99999.1;
  4671. // while (number > 0)
  4672. // {
  4673. // number++;
  4674. // printf("%f\n", number); //fixed.point notation infinity and nan
  4675. // printf("%e\n", number); //standard form e+00
  4676. // 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
  4677. // printf("%F\n", number); //FIXED.POINT NOTATION INFINITY AND NAN
  4678. // printf("%E\n", number); //standard form E+00
  4679. // 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
  4680. // printf("-\n");
  4681. //
  4682. // /*
  4683. // 1000000.100000
  4684. // 1.000000e+06
  4685. // 1e+06
  4686. // 1000000.100000
  4687. // 1.000000E+06
  4688. // 1E+06
  4689. // -
  4690. // */
  4691. //
  4692. // /*
  4693. // 100000.100000
  4694. // 1.000001e+05
  4695. // 100000
  4696. // 100000.100000
  4697. // 1.000001E+05
  4698. // 100000
  4699. // -
  4700. // */
  4701. // }
  4702. //}
  4703. //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
  4704. //main()
  4705. //{
  4706. // long double number = 99999.1;
  4707. // while (number > 0)
  4708. // {
  4709. // number++;
  4710. // printf("%f\n", number); //fixed.point notation infinity and nan
  4711. // printf("%e\n", number); //standard form e+00
  4712. // 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
  4713. // printf("%F\n", number); //FIXED.POINT NOTATION INFINITY AND NAN
  4714. // printf("%E\n", number); //standard form E+00
  4715. // 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
  4716. // printf("-\n");
  4717. //
  4718. // /*
  4719. // 1000000.100000
  4720. // 1.000000e+06
  4721. // 1e+06
  4722. // 1000000.100000
  4723. // 1.000000E+06
  4724. // 1E+06
  4725. // -
  4726. // */
  4727. //
  4728. // /*
  4729. // 100000.100000
  4730. // 1.000001e+05
  4731. // 100000
  4732. // 100000.100000
  4733. // 1.000001E+05
  4734. // 100000
  4735. // -
  4736. // */
  4737. // //NOT DIFFERENT FROM DOUBLE
  4738. // }
  4739. //}
  4740. //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
  4741. //Experiment: Changing the maximum and minimum of long double in <float.h>. Thought: 12/1/2019 Tested: not yet
  4742. //main()
  4743. //{
  4744. // float number = 999999.1;
  4745. // while (number > 0)
  4746. // {
  4747. // number++;
  4748. // printf("%f\n", number); //fixed.point notation infinity and nan
  4749. // printf("%e\n", number); //standard form e+00
  4750. // 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
  4751. // printf("%F\n", number); //FIXED.POINT NOTATION INFINITY AND NAN
  4752. // printf("%E\n", number); //standard form E+00
  4753. // 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
  4754. // printf("-\n");
  4755. //
  4756. // /*
  4757. // 1000000.125000
  4758. // 1.000000e+06
  4759. // 1e+06
  4760. // 1000000.125000
  4761. // 1.000000E+06
  4762. // 1E+06
  4763. // -
  4764. // */
  4765. //
  4766. // /*
  4767. // 100000.101563
  4768. // 1.000001e+05
  4769. // 100000
  4770. // 100000.101563
  4771. // 1.000001E+05
  4772. // 100000
  4773. // -
  4774. // */
  4775. // //DIFFERENT THAN DOUBLE AND LONG DOUBLE IN BOTH 99999.1 + 1 and 999999.1
  4776. // }
  4777. //}
  4778. //
  4779. //main()
  4780. //{
  4781. // float fnumber1 = 99999.1;
  4782. // double dnumber1 = 99999.1;
  4783. // long double ldnumber1 = 99999.1;
  4784. //
  4785. // float fnumber2 = 999999.1;
  4786. // double dnumber2 = 999999.1;
  4787. // long double ldnumber2 = 999999.1;
  4788. //
  4789. // int i = 0;
  4790. // printf("%18d+1%18d+1\n", 99999, 999999);
  4791. // while (i < 1) //Float
  4792. // {
  4793. // printf("Float\n");
  4794. // fnumber1++;
  4795. // fnumber2++;
  4796. // i++;
  4797. // printf("%20f%20f\n\n", fnumber1, fnumber2);
  4798. // printf("%20e%20e\n\n", fnumber1, fnumber2);
  4799. // printf("%20g%20g\n\n", fnumber1, fnumber2);
  4800. // printf("%20F%20F\n\n", fnumber1, fnumber2);
  4801. // printf("%20E%20E\n\n", fnumber1, fnumber2);
  4802. // printf("%20G%20G\n\n", fnumber1, fnumber2);
  4803. // printf("\n");
  4804. // }
  4805. // i = 0;
  4806. //
  4807. // while (i < 1) //Double
  4808. // {
  4809. // printf("Double\n");
  4810. // dnumber1++;
  4811. // dnumber2++;
  4812. // i++;
  4813. // printf("%20f%20f\n\n", dnumber1, dnumber2);
  4814. // printf("%20e%20e\n\n", dnumber1, dnumber2);
  4815. // printf("%20g%20g\n\n", dnumber1, dnumber2);
  4816. // printf("%20F%20F\n\n", dnumber1, dnumber2);
  4817. // printf("%20E%20E\n\n", dnumber1, dnumber2);
  4818. // printf("%20G%20G\n\n", dnumber1, dnumber2);
  4819. // printf("\n");
  4820. // }
  4821. // i = 0;
  4822. //
  4823. // while (i < 1) //Long Double
  4824. // {
  4825. // printf("Long Double\n");
  4826. // ldnumber1++;
  4827. // ldnumber2++;
  4828. // i++;
  4829. // printf("%20f%20f\n\n", ldnumber1, ldnumber2);
  4830. // printf("%20e%20e\n\n", ldnumber1, ldnumber2);
  4831. // printf("%20g%20g\n\n", ldnumber1, ldnumber2);
  4832. // printf("%20F%20F\n\n", ldnumber1, ldnumber2);
  4833. // printf("%20E%20E\n\n", ldnumber1, ldnumber2);
  4834. // printf("%20G%20G\n\n", ldnumber1, ldnumber2);
  4835. // printf("\n");
  4836. // }
  4837. //}
  4838. //The % operator determines what is printed and how it is printed while the variable is unaffected. The float data type output variance is because
  4839. //Valuable result: truncation occurs from double to float and long double to float
  4840. //Valuable result: exponent notation (%g and %G) begins at 1,000,000
  4841.  
  4842. //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
  4843. //https://www.tutorialspoint.com/cprogramming/c_data_types.htm
  4844. //https://en.wikipedia.org/wiki/Printf_format_string
  4845. //Experiment: Changing the maximum and minimum of long double in <float.h>. Thought: 12/1/2019 Tested: not yet
  4846.  
  4847. //main()
  4848. //{
  4849. // printf("unsigned char: %u to %u\n", 0, UCHAR_MAX);
  4850. // printf("signed char: %d to %d\n", SCHAR_MIN, SCHAR_MAX);
  4851. // printf("char: %d to %d\n", CHAR_MIN, CHAR_MAX);
  4852. //
  4853. // printf("unsigned short int: %u to %u\n", 0, USHRT_MAX);
  4854. // printf("signed short int: %d to %d\n", SHRT_MIN, SHRT_MAX); //signed short
  4855. // printf("short: %d to %d\n", SHRT_MIN, SHRT_MAX); //short are the same
  4856. //
  4857. // printf("unsigned int: %u to %u\n", 0, UINT_MAX);
  4858. // printf("signed int: %d to %d\n", INT_MIN, INT_MAX); //signed int
  4859. // printf("int: %d to %d\n", INT_MIN, INT_MAX); //int are the same
  4860. //
  4861. // printf("unsigned long int: %u to %u\n", 0, ULONG_MAX);
  4862. // printf("signed long int: %d to %d\n", LONG_MIN, LONG_MAX); //signed long
  4863. // printf("long: %d to %d\n", LONG_MIN, LONG_MAX); //long are the same
  4864. //
  4865. // printf("unsigned long long int: %llu to %llu\n", 0, ULLONG_MAX);
  4866. // printf("signed long long int: %lld to %lld\n", LLONG_MIN, LLONG_MAX); //signed long long
  4867. // printf("long long: %lld to %lld\n", LLONG_MIN, LLONG_MAX); //long long are the same
  4868. //
  4869. // printf("float: %G to %G\n", FLT_MIN, FLT_MAX);
  4870. //
  4871. // printf("double: %G to %G\n", DBL_MIN, DBL_MAX);
  4872. //
  4873. // printf("long double: %G to %G\n", LDBL_MIN, LDBL_MAX);
  4874. //
  4875. // //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
  4876. // /*
  4877. // 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'
  4878. // 1>C:\Users\funca\source\repos\C\P1\P1.c(4863,9): message : consider using '%llu' in the format string
  4879. // 1>C:\Users\funca\source\repos\C\P1\P1.c(4863,9): message : consider using '%I64u' in the format string
  4880. // 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'
  4881. // 1>C:\Users\funca\source\repos\C\P1\P1.c(4864,9): message : consider using '%lld' in the format string
  4882. // 1>C:\Users\funca\source\repos\C\P1\P1.c(4864,9): message : consider using '%I64d' in the format string
  4883. // 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'
  4884. // 1>C:\Users\funca\source\repos\C\P1\P1.c(4864,9): message : consider using '%lld' in the format string
  4885. // 1>C:\Users\funca\source\repos\C\P1\P1.c(4864,9): message : consider using '%I64d' in the format string
  4886. // 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'
  4887. // 1>C:\Users\funca\source\repos\C\P1\P1.c(4865,9): message : consider using '%lld' in the format string
  4888. // 1>C:\Users\funca\source\repos\C\P1\P1.c(4865,9): message : consider using '%I64d' in the format string
  4889. // 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'
  4890. // 1>C:\Users\funca\source\repos\C\P1\P1.c(4865,9): message : consider using '%lld' in the format string
  4891. // 1>C:\Users\funca\source\repos\C\P1\P1.c(4865,9): message : consider using '%I64d' in the format string
  4892. // */
  4893. //
  4894. // /*
  4895. // unsigned char: 0 to 255
  4896. // signed char: -128 to 127
  4897. // char: -128 to 127
  4898. // unsigned short int: 0 to 65535
  4899. // signed short int: -32768 to 32767
  4900. // short: -32768 to 32767
  4901. // unsigned int: 0 to 4294967295
  4902. // signed int: -2147483648 to 2147483647
  4903. // int: -2147483648 to 2147483647
  4904. // unsigned long int: 0 to 4294967295
  4905. // signed long int: -2147483648 to 2147483647
  4906. // long: -2147483648 to 2147483647
  4907. // unsigned long long int: 18446744069414584320 to 27887162523385855
  4908. // signed long long int: -9223372036854775808 to 9223372036854775807
  4909. // long long: -9223372036854775808 to 9223372036854775807
  4910. // float: 1.17549E-38 to 3.40282E+38
  4911. // double: 2.22507E-308 to 1.79769E+308
  4912. // long double: 2.22507E-308 to 1.79769E+308
  4913. // */
  4914. //}
  4915. //
  4916. //main()
  4917. //{
  4918. // int c;
  4919. // int lim;
  4920. // char line[40];
  4921. // int i = 0;
  4922. // for (lim = 0; lim < 100; lim++)
  4923. // {
  4924. // if ((c = getchar()) != '\n')
  4925. // {
  4926. // if (c != EOF)
  4927. // line[i++] = c;
  4928. // }
  4929. // }
  4930. //}
  4931.  
  4932. //int htoi(char array[])
  4933. //{
  4934. // int c;
  4935. // int i;
  4936. // int n;
  4937. // int pp;
  4938. // for (i = 0; isdigit(array[i]) || array[i] >= 'A' && array[i] <= 'Z' || array[i] >= 'a' && array[i] <= 'z'; i++)
  4939. // {
  4940. // if (isdigit(array[i]))
  4941. // pp = array[i] - '0';
  4942. // else if (array[i] == 'A' || array[i] == 'a')
  4943. // pp = 10;
  4944. // else if (array[i] == 'B' || array[i] == 'b')
  4945. // pp = 11;
  4946. // else if (array[i] == 'C' || array[i] == 'c')
  4947. // pp = 12;
  4948. // else if (array[i] == 'D' || array[i] == 'd')
  4949. // pp = 13;
  4950. // else if (array[i] == 'E' || array[i] == 'e')
  4951. // pp = 14;
  4952. // else if (array[i] == 'F' || array[i] == 'f')
  4953. // pp = 15;
  4954. // n = n * 10 + pp;
  4955. // if (i == 0 && array[i] == '0')
  4956. // {
  4957. // i = 3;
  4958. // n = 0;
  4959. // }
  4960. // return n;
  4961. // }
  4962. //}
  4963.  
  4964. //void squeezedelete(char s1[], char s2[])
  4965. //{
  4966. // int i = 0;
  4967. // int j;
  4968. // int k = 0;
  4969. // while (s1[i] != '\0')
  4970. // {
  4971. // j = 0;
  4972. // while (s2[j] != '\0' && s1[i] != s2[j])
  4973. // {
  4974. // if (s2[j+1] == '\0')
  4975. // {
  4976. // s1[k++] = s1[i];
  4977. // }
  4978. // j++;
  4979. // }
  4980. // i++;
  4981. // }
  4982. //}
  4983.  
  4984. //void firstcommoncharacter(char s1[], char s2[])
  4985. //{
  4986. // int i;
  4987. // int j;
  4988. // int fcci = 0;
  4989. //
  4990. // while (s1[i] != '\0')
  4991. // {
  4992. // j = 0;
  4993. // while (s2[j++] != '\0')
  4994. // {
  4995. // if (s1[i] == s2[j])
  4996. // {
  4997. // return ++fcci;
  4998. // }
  4999. // fcci++;
  5000. // }
  5001. // if (s1[i + 1] == '\0')
  5002. // return -1;
  5003. // i++;
  5004. // }
  5005. //}
  5006.  
  5007. //unsigned setbits(unsigned x, int p, int n, unsigned y) //signed instead of unsigned for sign bit sign extension p.50
  5008. //{
  5009. // return ((x >> (p + 1 - n)) & (y & ~(~0 << n));
  5010. //}
  5011.  
  5012. //unsigned invert(unsigned x, int p, int n) //signed instead of unsigned for sign bit sign extension p.50
  5013. //{
  5014. // return x ^ ((~0 << p + 1 - n) >> n - 1); //arithmetic right shift, sign extension vital
  5015. //}
  5016.  
  5017. //unsigned rightrot(unsigned x, int n) //signed instead of unsigned for sign bit sign extension p.50
  5018. //{
  5019. // unsigned x2 = x;
  5020. // int size = bitsize(x); //function bitsize counts the number of bits in x. Example x = 0000 returns 4.
  5021. // return (x >> n) | ((~0 << size - 1) & (x2 << size - n));
  5022. //}
  5023.  
  5024. //unsigned bitcount_Faster(unsigned x)
  5025. //{
  5026. // return ~(x - 1);
  5027. //}
  5028.  
  5029. //void lower(char array[])
  5030. //{
  5031. // int i = 0;
  5032. // while (array[i] != '\0')
  5033. // {
  5034. // array[i] = (array[i] >= 'A' || array[i] <= 'Z') ? array[i] + 'a' - 'A' : array[i];
  5035. // i++;
  5036. // }
  5037. //}
  5038.  
  5039. //int binsearch(int x, char array[], int bottom, int top)
  5040. //{
  5041. // int low = bottom;
  5042. // int high = top - 1;
  5043. // int middle = (high + low) / 2;
  5044. //
  5045. // while (x != array[middle] && (high + middle) / 2 != middle && (low + middle) / 2 != middle)
  5046. // {
  5047. // if (x > array[middle])
  5048. // middle = (high + middle) / 2;
  5049. // else
  5050. // middle = (low + middle) / 2;
  5051. // }
  5052. // if (x == array[middle])
  5053. // return middle;
  5054. // else
  5055. // return -1;
  5056. //} //did not run them next to eachother was not interested in that moment
  5057.  
  5058. //void escape(char s[], char t[])
  5059. //{
  5060. // int i = 0;
  5061. // int j = 0;
  5062. // while (s[i] != '\0')
  5063. // {
  5064. // switch (s[i])
  5065. // {
  5066. // case '\n':
  5067. // t[j] = '\\';
  5068. // j++;
  5069. // t[j] = 'n';
  5070. // i++;
  5071. // break;
  5072. // case '\t':
  5073. // t[j] = '\\';
  5074. // j++;
  5075. // t[j] = 't';
  5076. // i++;
  5077. // break;
  5078. // default:
  5079. // t[j] = s[i];
  5080. // j++;
  5081. // i++;
  5082. // break;
  5083. // }
  5084. // }
  5085. //}
  5086.  
  5087. //void escapereversed(char s[], char t[])
  5088. //{
  5089. // int i = 0;
  5090. // int j = 0;
  5091. // while (s[i] != '\0')
  5092. // {
  5093. // switch (s[i])
  5094. // {
  5095. // case ('\\'):
  5096. // if (s[i + 1] == 'n')
  5097. // {
  5098. // t[j] = '\n';
  5099. // j++;
  5100. // i++;
  5101. // break;
  5102. // }
  5103. // else if (s[i + 1] == 't')
  5104. // {
  5105. // t[j] = '\t';
  5106. // j++;
  5107. // i++;
  5108. // break;
  5109. // }
  5110. // else
  5111. // {
  5112. // t[j] = s[i];
  5113. // j++;
  5114. // i++;
  5115. // break;
  5116. // }
  5117. // default:
  5118. // t[j] = s[i];
  5119. // j++;
  5120. // i++;
  5121. // break;
  5122. // }
  5123. // }
  5124. //}
  5125.  
  5126. //https://www.youtube.com/watch?v=qzXAVXddcPU
  5127.  
  5128. //void expand(char s1[], char s2[]);
  5129. //
  5130. //main()
  5131. //{
  5132. // int c;
  5133. // int i = 0;
  5134. // char s1[MAXARRAYSIZE];
  5135. // char s2[MAXARRAYSIZE];
  5136. // while ((c = getchar()) != EOF)
  5137. // s1[i++] = c;
  5138. // s1[i] = '\0';
  5139. // expand(s1, s2);
  5140. // printf("%s", s2);
  5141. //}
  5142. //
  5143. //void expand(char s1[], char s2[])
  5144. //{
  5145. // int INALETTEREXPANSION = NO;
  5146. // int INANUMBEREXPANSION = NO;
  5147. // int i = 0;
  5148. // int k;
  5149. // int j = 0;
  5150. // int nc = 0;
  5151. // int valk;
  5152. // int vali;
  5153. // int inc;
  5154. // while (s1[i] != '\0' && s1[i] != EOF)
  5155. // {
  5156. // switch (s1[i])
  5157. // {
  5158. // 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':
  5159. // 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':
  5160. // if (!INALETTEREXPANSION)
  5161. // {
  5162. // s2[j++] = s1[i];
  5163. // INALETTEREXPANSION = YES;
  5164. // }
  5165. // k = i + 1;
  5166. // nc = 1;
  5167. // while (!isalnum(s1[k]) && s1[k] != '-' && s1[k] != '\0' && s1[k] != EOF)
  5168. // nc++, k++;
  5169. // if (isdigit(s1[k]))
  5170. // {
  5171. // INALETTEREXPANSION = NO;
  5172. // i++;
  5173. // }
  5174. // else if (s1[k] == '-')
  5175. // {
  5176. // nc++, k++;
  5177. // while (!isalnum(s1[k]) && s1[k] != '\0' && s1[k] != EOF)
  5178. // nc++, k++;
  5179. // if (isalpha(s1[k]) && s1[k] > s1[i])
  5180. // {
  5181. // valk = s1[k];
  5182. // vali = s1[i];
  5183. // inc = 1;
  5184. // while (valk-- > vali)
  5185. // {
  5186. // s2[j++] = s1[i] + inc++;
  5187. // }
  5188. // i += nc;
  5189. // INALETTEREXPANSION = YES;
  5190. // }
  5191. // else if (isalpha(s1[k]) && s1[k] < s1[i])
  5192. // {
  5193. // valk = s1[k];
  5194. // vali = s1[i];
  5195. // inc = 1;
  5196. // while (valk++ < vali)
  5197. // {
  5198. // s2[j++] = s1[i] - inc++;
  5199. // }
  5200. // i += nc;
  5201. // INALETTEREXPANSION = YES;
  5202. // }
  5203. // else if (isalpha(s1[k]) && s1[k] == s1[i])
  5204. // {
  5205. // s2[j++] = s1[i];
  5206. // i += nc;
  5207. // }
  5208. // else
  5209. // {
  5210. // s2[j++] = '-';
  5211. // i += nc;
  5212. // INALETTEREXPANSION = NO;
  5213. // }
  5214. // }
  5215. // else if (isalpha(s1[k]))
  5216. // {
  5217. // INALETTEREXPANSION = NO;
  5218. // i += nc;
  5219. // }
  5220. // else
  5221. // i++;
  5222. // break;
  5223. // case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
  5224. // if (!INANUMBEREXPANSION)
  5225. // {
  5226. // s2[j++] = s1[i];
  5227. // INANUMBEREXPANSION = YES;
  5228. // }
  5229. // k = i + 1;
  5230. // nc = 1;
  5231. // while (!isalnum(s1[k]) && s1[k] != '-' && s1[k] != '\0' && s1[k] != EOF)
  5232. // nc++, k++;
  5233. // if (isalpha(s1[k]))
  5234. // {
  5235. // INANUMBEREXPANSION = NO;
  5236. // i++;
  5237. // }
  5238. // else if (s1[k] == '-')
  5239. // {
  5240. // nc++, k++;
  5241. // while (!isalnum(s1[k]) && s1[k] != '\0' && s1[k] != EOF)
  5242. // nc++, k++;
  5243. // if (isdigit(s1[k]) && s1[k] > s1[i])
  5244. // {
  5245. // valk = s1[k];
  5246. // vali = s1[i];
  5247. // inc = 1;
  5248. // while (valk-- > vali)
  5249. // {
  5250. // s2[j++] = s1[i] + inc++;
  5251. // }
  5252. // i += nc;
  5253. // INANUMBEREXPANSION = YES;
  5254. // }
  5255. // else if (isdigit(s1[k]) && s1[k] < s1[i])
  5256. // {
  5257. // valk = s1[k];
  5258. // vali = s1[i];
  5259. // inc = 1;
  5260. // while (valk++ < vali)
  5261. // {
  5262. // s2[j++] = s1[i] - inc++;
  5263. // }
  5264. // i += nc;
  5265. // INANUMBEREXPANSION = YES;
  5266. // }
  5267. // else if (isdigit(s1[k]) && s1[k] == s1[i])
  5268. // {
  5269. // s2[j++] = s1[i];
  5270. // i += nc;
  5271. // }
  5272. // else
  5273. // {
  5274. // s2[j++] = '-';
  5275. // i += nc;
  5276. // INANUMBEREXPANSION = NO;
  5277. // }
  5278. // }
  5279. // else if (isalpha(s1[k]))
  5280. // {
  5281. // INANUMBEREXPANSION = NO;
  5282. // i += nc;
  5283. // }
  5284. // else
  5285. // i++;
  5286. // break;
  5287. // default:
  5288. // s2[j++] = s1[i++];
  5289. // break;
  5290. // }
  5291. // }
  5292. // s2[j] = '\0';
  5293. //}
  5294.  
  5295. //void reverse(char s[])
  5296. //{
  5297. // char temp[MAXARRAYSIZE];
  5298. // int i = 0;
  5299. // int j = 0;
  5300. // int pointofreverse = 0;
  5301. //
  5302. // while (s[i] != '\0')
  5303. // {
  5304. // while (s[i] != '\n' && s[i] != '\0')
  5305. // {
  5306. // i++;
  5307. // }
  5308. // pointofreverse = i - 1;
  5309. // while (j < i)
  5310. // {
  5311. // temp[j++] = s[pointofreverse--];
  5312. // }
  5313. // temp[j] = s[i++];
  5314. // }
  5315. // temp[j] = '\0';
  5316. // s = temp; //new reverse on 5373
  5317. //}
  5318. //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.
  5319. //A solution can be to hold the positive number in a long integer.
  5320. //Learned ints are stored using binary number representation systems 127 = 01111111 -128 = 10000000. char is a int (56) representing a character 'A
  5321. //void itoa(int n, char s[])
  5322. //{
  5323. // int i;
  5324. // int sign;
  5325. // long long int holdthepositivenumber;
  5326. // if ((sign = n) < 0)
  5327. // holdthepositivenumber = -n; //n = -n;
  5328. // i = 0;
  5329. // do {
  5330. // s[i++] = n % 10 + '0';
  5331. // } while ((n /= 10) > 0);
  5332. // if (sign < 0)
  5333. // s[i++] = '-';
  5334. // s[i] = '\0';
  5335. // reverse(s);
  5336. //}
  5337. //void reverse(char s[]);
  5338. //void itob(int n, char s[], int b);
  5339. //int atoi(char s[]);
  5340. //main()
  5341. //{
  5342. // int c;
  5343. // char anumber[MAXARRAYSIZE];
  5344. // int number;
  5345. // int i = 0;
  5346. // int base;
  5347. // while ((c = getchar()) != '\n')
  5348. // anumber[i++] = c;
  5349. // anumber[i] = '\0', printf("%s\n", anumber);
  5350. // number = atoi(anumber), printf("%d\n", number);
  5351. // i = 0, anumber[0] = '\0';
  5352. // while ((c = getchar()) != '\n')
  5353. // anumber[i++] = c;
  5354. // anumber[i] = '\0', printf("%s\n", anumber);
  5355. // base = atoi(anumber), printf("%d\n", base);
  5356. // anumber[0] = '\0', itob(number, anumber, base), printf("%s\n", anumber);
  5357. //}
  5358. //void itob(int n, char s[], int b)
  5359. //{
  5360. // int i = 0;
  5361. // int nrc;
  5362. // while (n > 0)
  5363. // {
  5364. // if ((nrc = n % b) >= 10)
  5365. // s[i++] = (char) (nrc + 55);
  5366. // else
  5367. // s[i++] = (char) (nrc + '0');
  5368. // n /= b;
  5369. // }
  5370. // s[i] = '\0';
  5371. // reverse(s);
  5372. //}
  5373. //void reverse(char s[])
  5374. //{
  5375. // char temp[MAXARRAYSIZE];
  5376. // int i = 0;
  5377. // int j = 0;
  5378. // int pointofreverse = 0;
  5379. // while (s[i] != '\0' && s[i] != EOF)
  5380. // {
  5381. // while (s[i] != '\n' && s[i] != '\0' && s[i] != EOF)
  5382. // i++;
  5383. // pointofreverse = i - 1;
  5384. // while (j < i)
  5385. // temp[j++] = s[pointofreverse--];
  5386. // temp[j++] = s[i];
  5387. // if (s[i] != '\0')
  5388. // i++;
  5389. // }
  5390. // temp[j] = '\0';
  5391. // i = 0;
  5392. // while ((s[i] = temp[i]) != '\0')
  5393. // i++;
  5394. //}
  5395. //int atoi(char s[])
  5396. //{
  5397. // int sign;
  5398. // int i = 0;
  5399. // int n = 0;
  5400. // if (s[i] == '-')
  5401. // {
  5402. // sign = YES;
  5403. // i++;
  5404. // }
  5405. // while (s[i] != '\0')
  5406. // n = n * 10 + (s[i++] - '0');
  5407. // return n;
  5408. //}
  5409. //void reverse(char s[]);
  5410. //main()
  5411. //{
  5412. // int c;
  5413. // int i = 0;
  5414. // char array[MAXARRAYSIZE];
  5415. // while ((c = getchar()) != '!')
  5416. // array[i++] = c;
  5417. // array[i] = '\0';
  5418. // reverse(array);
  5419. // printf("%s", array);
  5420. //}
  5421. //void reverse(char s[])
  5422. //{
  5423. // char temp[MAXARRAYSIZE];
  5424. // int i = 0;
  5425. // int j = 0;
  5426. // int pointofreverse = 0;
  5427. // while (s[i] != '\0' && s[i] != EOF)
  5428. // {
  5429. // while (s[i] != '\n' && s[i] != '\0' && s[i] != EOF)
  5430. // i++;
  5431. // pointofreverse = i - 1;
  5432. // while (j < i)
  5433. // temp[j++] = s[pointofreverse--];
  5434. // temp[j++] = s[i];
  5435. // if (s[i] != '\0')
  5436. // i++;
  5437. // }
  5438. // temp[j] = '\0';
  5439. // i = 0;
  5440. // while ((s[i] = temp[i]) != '\0')
  5441. // i++;
  5442. //}
  5443.  
  5444. //void itoawithpadding(int n, char s[], int padding)
  5445. //{
  5446. // long long int carefulconversion;
  5447. // int sign = NO;
  5448. // int i = 0;
  5449. // if (n < 0)
  5450. // {
  5451. // n = -n;
  5452. // sign = YES;
  5453. // padding = padding - 1;
  5454. // }
  5455. // while (n > 0)
  5456. // {
  5457. // s[i++] = n % 10;
  5458. // n /= 10;
  5459. // padding--;
  5460. // }
  5461. // s[i++] = '-';
  5462. // while (padding-- > 0)
  5463. // {
  5464. // s[i++] = ' ';
  5465. // }
  5466. // s[i] = '\0'; //this one character more than the minimum width padding
  5467. // reverse(s);
  5468. //}
Advertisement
Add Comment
Please, Sign In to add comment