Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include "text_editor.h"
  2. #include "stdafx.h"
  3. #include <iostream>
  4. #include <cstring>
  5. #include <fstream>
  6.  
  7. using namespace std;
  8.  
  9. void print(char *arr, ifstream &file)
  10. {
  11. int count = 0;
  12. while (!file.eof())
  13. {
  14. file.getline(arr, 1024);
  15. cout << arr << endl;
  16. count++;
  17. }
  18. }
  19.  
  20. void strcopy(char *des, const char *src)
  21. {
  22. int size = strlen(src);
  23. for(int i = 0 ;i<=size;++i)
  24. {
  25. des[i] = src[i];
  26. }
  27. des[size + 1] = '\0';
  28. }
  29.  
  30. char* readFile(ifstream &file)
  31. {
  32. char *res = NULL;
  33. char tmp[1025];
  34. file.getline(tmp, 1024);
  35. int len = strlen(tmp);
  36. res = new char[len + 1];
  37. strcopy(res, tmp);
  38. return res;
  39. }
  40.  
  41. Command makeCommand()
  42. {
  43. char cmd[12] = { 0, };
  44. cin >> cmd;
  45. if (!strcmp(cmd, "makeHeading"))
  46. {
  47. return makeHeading;
  48. }
  49. else if (!strcmp(cmd, "makeBold"))
  50. {
  51. return makeBold;
  52. }
  53. else if (!strcmp(cmd, "makeItalic"))
  54. {
  55. return makeItalic;
  56. }
  57. else if (!strcmp(cmd, "makeCombine"))
  58. {
  59. return makeCombine;
  60. }
  61. else if (!strcmp(cmd, "addLine"))
  62. {
  63. return addLine;
  64. }
  65. else if (!strcmp(cmd, "remove"))
  66. {
  67. return removeLine;
  68. }
  69. else if (!strcmp(cmd, "exit"))
  70. {
  71. return exitProgram;
  72. }
  73. else
  74. {
  75. cout << "Invalid command.Try again: ";
  76. makeCommand();
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement