954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

need help in creating simple line editor

hi! i'm trying to make a simple line editor...

i have two main questions in mind:
1.) what's the syntax to make the cursor appear at the middle, or at the bottom part of the screen...or how can you print something and make it appear at a certain position

2.) what's the syntax to load a text file using a c++ program...

please help...we haven't discussed it in class... :cry:

thanks!

potential
Newbie Poster
13 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 
what's the syntax to load a text file using a c++ program...

Try something like this!

#include <fstream>  //include this standard template library

char filename[16];  //declare a variable string this one is 16 characters long
string line;  //decalare a string variable

cout << "Enter the name of the program that you would like data for: ";
cin >> filename;

ifstream instream(filename);

if(instream.fail()) //This will check to see if  the file open fails for whatever reason
{
            cout << "Input file opening failed.\n";
	exit(1);
} 

while ( getline(instream, line) )  //this will read the file in line by line
coolmel55
Light Poster
40 posts since Sep 2004
Reputation Points: 10
Solved Threads: 1
 

1) Platform and implementation dependent. What compiler and OS are you using?

2) This is in any book on C++.

>please help...we haven't discussed it in class...
You'll be in big trouble if you wait until everything is discussed in class before you do your own research.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

i actually figured out the opening file part, but i'm still modifying the code.

but i can't find a useful book on how to make the cursor go to a certain part of the screen or something...all the good books are on loan...
i'm using bloodshed's dev-c++

thanks a lot! :D

potential
Newbie Poster
13 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

>i can't find a useful book on how to make the cursor go to a certain part of the screen or something
What part of "platform and implementation dependent" is difficult? If you're looking for a book that tells you how to do this, it's going to be very specialized and thus very difficult to find. I have six letters for you, G.O.O.G.L.E. A braindead search will still give you something to work with.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You