Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "text_editor.h"
- #include "stdafx.h"
- #include <iostream>
- #include <cstring>
- #include <fstream>
- using namespace std;
- void print(char *arr, ifstream &file)
- {
- int count = 0;
- while (!file.eof())
- {
- file.getline(arr, 1024);
- cout << arr << endl;
- count++;
- }
- }
- void strcopy(char *des, const char *src)
- {
- int size = strlen(src);
- for(int i = 0 ;i<=size;++i)
- {
- des[i] = src[i];
- }
- des[size + 1] = '\0';
- }
- char* readFile(ifstream &file)
- {
- char *res = NULL;
- char tmp[1025];
- file.getline(tmp, 1024);
- int len = strlen(tmp);
- res = new char[len + 1];
- strcopy(res, tmp);
- return res;
- }
- Command makeCommand()
- {
- char cmd[12] = { 0, };
- cin >> cmd;
- if (!strcmp(cmd, "makeHeading"))
- {
- return makeHeading;
- }
- else if (!strcmp(cmd, "makeBold"))
- {
- return makeBold;
- }
- else if (!strcmp(cmd, "makeItalic"))
- {
- return makeItalic;
- }
- else if (!strcmp(cmd, "makeCombine"))
- {
- return makeCombine;
- }
- else if (!strcmp(cmd, "addLine"))
- {
- return addLine;
- }
- else if (!strcmp(cmd, "remove"))
- {
- return removeLine;
- }
- else if (!strcmp(cmd, "exit"))
- {
- return exitProgram;
- }
- else
- {
- cout << "Invalid command.Try again: ";
- makeCommand();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement