6 Replies - 716 Views - Last Post: 07 April 2012 - 04:08 PM Rate Topic: -----

#1 blackstab1337  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-April 12

Would somone provide help with my DOS text editor.

Posted 06 April 2012 - 05:25 AM

I have no idea where to start. this is my basis i guess.

#include <cstdlib>// Safe guard
#include <iostream>
#include <cmath> // Safe Guard again.
#include <string>
#include <fstream> // Open file i think.
using namespace std; // Using because there will be over 150 lines of code. dont want to continuously type std::
int main(void){
    char close;
    string filename;
    ofstream file;
    cout << "File name with .txt: ";
    cin >> filename;
   //Not going to use other functions ( I think thats the word) to write on screen atm. This is my 'skeleton' 
 cout << "Press any key then enter to close." << endl; // -.-/> *facepalm*
 
cin >> close;
 return 0;    //Quit
}



I am not asking for code, just what to use and help. To bide by the rules please dont provide my WHOLE text editor. would it be file.open(filename); and at end file.close();

Thanks guys. Hope to see some nice answers tomorrow. I have googled C++ DOS Text editor and havent found anything helpfull. please explain code. also im making a TBAG, (T)ext (B)ased (A)dventure (G)ame, =). Please reply (with helpfull code for OT) if you would like to see the source and i will release it, infact dont comment just use the poll :)

EDIT: Help with the poll -.-

Is This A Good Question/Topic? 0
  • +

Replies To: Would somone provide help with my DOS text editor.

#2 blackstab1337  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-April 12

Re: Would somone provide help with my DOS text editor.

Posted 06 April 2012 - 05:52 AM

BTW i need help with displaying the file on the screen correctly. and hello jim! i see youre reading my post =)
Was This Post Helpful? 0
  • +
  • -

#3 jimblumberg  Icon User is online

  • member icon


Reputation: 4099
  • View blog
  • Posts: 12,690
  • Joined: 25-December 09

Re: Would somone provide help with my DOS text editor.

Posted 06 April 2012 - 05:52 AM

If your compiler is compiling for the current standard C++11 then you can use the std::string to open the file, otherwise you will need to use the std::string.c_str() member function to pass a C-string to the ofstream.open() function. You should be thinking about using functions and classes to aid in creating your editor. Keep your functions small, doing as few things as possible. You may want to start your quest by reading the tutorials linked in my signature below. Also the following link has a decent basic file tutorial. Also writing a "complete" text editor is not an easy task and you will need to show much more code before you get much useful help. We will not give you "(with helpfull code for OT)", you must show some actual effort at accomplishing your objective, and have specific questions or problems with specific topics of your code.

Jim
Was This Post Helpful? 0
  • +
  • -

#4 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2118
  • View blog
  • Posts: 3,244
  • Joined: 21-June 11

Re: Would somone provide help with my DOS text editor.

Posted 06 April 2012 - 08:48 AM

View Postjimblumberg, on 06 April 2012 - 02:52 PM, said:

If your compiler is compiling for the current standard C++11


Are there even any C++11 compatible compilers that still target DOS?

@OP: Do you want to write a command-based text editor (like ed) or a visual text editor (like edit.com)? If it's the latter you won't get far with iostream. You'll have to use a non-standard library like conio.h.

Regarding your comment about using namespace std;: If you use individual using directives (i.e. using std::cout; etc.), you also won't have to type std:: all the time, but you greatly reduce the risk of naming conflicts.

This post has been edited by sepp2k: 06 April 2012 - 08:50 AM

Was This Post Helpful? 1
  • +
  • -

#5 Salem_c  Icon User is online

  • void main'ers are DOOMED
  • member icon

Reputation: 1689
  • View blog
  • Posts: 3,209
  • Joined: 30-May 10

Re: Would somone provide help with my DOS text editor.

Posted 06 April 2012 - 09:27 AM

I rather suspect that by "DOS", the OP means "Win32 console".

@OP, if your OS is anything after WindowsNT (2K,XP,Vista.....), then the thing you see when you open a console and see a C:\> prompt is NOT DOS. It is a console.

For one thing, it runs 32-bit programs, so you're not stuck with crappy 16-bit segments limiting you to 64K in any single data structure, or 640K memory in total.

If you're going to be messing with the screen at a per character level, then you need to be familiar with the console API. Here's a tutorial.
Was This Post Helpful? 1
  • +
  • -

#6 blackstab1337  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-April 12

Re: Would somone provide help with my DOS text editor.

Posted 07 April 2012 - 03:54 PM

Thanks guys. All i really need a bit of help is, is how to DISPLAY the txt file on screen. just read http://www.cplusplus...tutorial/files/
But wasnt too helpfull. would it be like they said in the tut ^^ of string line; myfile.getline(myfile, string); or something along the line. and yes i did mean console thanks!
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6066
  • View blog
  • Posts: 23,526
  • Joined: 23-August 08

Re: Would somone provide help with my DOS text editor.

Posted 07 April 2012 - 04:08 PM

Let me ask you a question. Can you explain what this (incorrect) code is supposed to do?

ifstream myfile; // Assuming this is the definition of myfile
string line; 
myfile.getline(myfile, string); // This line is incorrect; string is a type

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1