|
 |
|
 |
12-20-2004, 12:07 PM
|
#1 (permalink)
|
|
Guest
|
Can anyone help me in this assignment plZ?
Hello everyone,,
Can anyone help me with this program please??
----------------------------------------------------------------------
This assignment requires you to write a simple text editor. Your editor will have the following commands:
e filename edits the filename if it exists
If it doesn’t exist, then you’ll be creating a new file.
i (insert mode) insert any number of lines after current line.
Ctrl- v stop inserting data (turn off insert mode)
l list the entire file without line numbers
n list the entire file with line numbers
d n delete the number n
c count the numbr of lines in the file
s save the file opened with the e command
p print the file
q quit the program prompting for save if the file has not been saved
Once your program begins, a prompt must appear on the screen. Commands can be entered following the prompt. A sample run of program is shown below:
> e welcome.cpp
> i
#include <iostream>
using namespace std;
void main ()
{
cout<<”Welcome to Etisalat College”<<endl;
}
^V
1) #include <iostream>
2) using namespace std;
3) void main ()
4) {
5) cout<<”Welcome to Etisalat College”<<endl;
6) }
> c
welcome.cpp has 6 lines
> s
saved welcome.cpp
> p
printing welcome.cpp
> q
================================================== =======
This is the program:
Code:
#include<iostream>
#include<fstream>
using namespace std;
int main ()
{
char letter;
ofstream printer (“USB001”, ios::out);ccout<<”+++++++Welcome to this editor program++++++++”<<endl;
cout<<”i: insert mode” <<endl;
cout<<””ctrl-v: turn off insert mode”<<endl;
cout<<”l: list the entire file without line numbers”<<endl;
cout<<”n: list the entire file with line numbers”<<endl;
cout<<”d n”: delete line number n”<<endl;
cout<<”c: count the number of lines in the file”<<endl;
cout<<”s: save the file opened with the e command”<<endl;
cout<<”q: quit the program prompting for save if the file has not been saved”<<endl;
cout<< ”<<”;
cin>>letter;
while (letter != ‘q’)
{
ifstream infile (“sample.txt”, ios::in);
switch (letter)
{
case ‘p’:
char a;
while (infile.get(a))
printer<<a;
cout<<”Printing”<<infile<<endl;
cout<< “<<”;
cin>>letter;
break;
case ‘s’:
cout<<”Your file is being saved”<<endl;
cout<< “<<”;
cin>>letter;
break;
case ‘n’ ;
int count;
count=1;
char c;
start:
cout<<count << “)”;
while (infile.get(c ) )
{
cout<<c;
if (c= = ‘\n’)
{
++count;
goto start;
}}
cout<<endl<< “<”;
cin>>letter;
break;
case ‘c’;
int counter;
counter= 1;
char d;
while (infile.get(d))
{
if (d= =’\n’)
{
++counter;
}}
if ( counter! =1)
cout<<”Sample.txt has “<<counter<<”lines”;
else if ((counter= =1) && (d= =’\0’))
cout<<”the file sample.txt contains no lines”;
else
cout<<”the file contains only 1 line”;
cout<<endl<< “<”;
cin>>letter;
break;
case’i’:
char in;
while (infile.get(in))
cout<<endl<< “<”;
cin>>letter;
break;
case”l”:
while (infile.get(in))
cout<<in;
cout<<endl<< “<”;
cin>>letter;
break;
default:
cout<<”invalid choice”<<endl;
cout<< ”<”;
cin>>letter;
break;
}}
return 0;
}
================================================== ======
Can anyone tell me how to do the "ctrl-v" and "delete" ???
and is there any other method other than using switch and cases??
ThanX ver much indeed 
Last edited by Valmont; 12-21-2004 at 11:42 AM.
|
|
|
|
12-20-2004, 12:28 PM
|
#2 (permalink)
|
|
[code][/code] enforcer
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
|
Quote:
|
Ctrl- v stop inserting data (turn off insert mode)
|
The ISO C++ standard does not know what this is. The standard doesn't know what a key is, the standard even doesn't know what a keyboard is. The standard even never heard of any device. I suspect you need to be more clear on this.
Quote:
n list the entire file with line numbers
d n delete the number n
|
Be more correct.
And finally use the [ code ] tags.
__________________
|
|
|
12-21-2004, 07:54 AM
|
#3 (permalink)
|
|
Guest
|
Quote:
|
Originally Posted by Valmont
The ISO C++ standard does not know what this is. The standard doesn't know what a key is, the standard even doesn't know what a keyboard is. The standard even never heard of any device. I suspect you need to be more clear on this.
Be more correct.
And finally use the [ code ] tags.
|
Holaaaa again ,,,,,,
MuahahahahahahahahaZ
maaaaaaaaaaan, You know nothing about programming or computer languages
Wahahahahahaha, You don't understand what these code means !!
Oh boy!!!
And above that you say that you're a programmer, and a super moderator in this forum
maaaaaaan, you're just a #%$#$#%#%##%#$#$#%#%$#.....toot toot toot
:th: Adiooooooooooooos :th:
|
|
|
|
12-21-2004, 09:21 AM
|
#4 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
|
Quote:
|
Originally Posted by VaMpIrE
Holaaaa again ,,,,,,
MuahahahahahahahahaZ
maaaaaaaaaaan, You know nothing about programming or computer languages
Wahahahahahaha, You don't understand what these code means !!
Oh boy!!!
|
Valmont knows about these commands, but they are OS dependent, nothing within the ANSI standard tells anything about them.
On some systems <ctrl>+v is end transmission, on other systems the correct one is <ctrl>+d on yet others it's <ctrl>+z so there is no uniq way of searching for this EOS (end of stream)
Since Valmont, as many otheres here, swear to folow the ANSI standard these terminating codes aren't uniq enough in order to tell how to end the read from a users input.
Quote:
|
Originally Posted by VaMpIrE
And above that you say that you're a programmer, and a super moderator in this forum
|
Valmont knows way more about programming within the C++ language, than any one you'd meet in the following year, and one sure way of setting a negative vibe about your person, is trying to piss off a moderator.
Quote:
|
Originally Posted by VaMpIrE
maaaaaaan, you're just a #%$#$#%#%##%#$#$#%#%$#.....toot toot toot
:th: Adiooooooooooooos :th:
|
Well, here is the real deal, one person points out a few things, the next thing you know, you get offended and start insulting that person....
Lets keep things clean here, there is no reason to mock people. I support Valmont in his points here, if I didn't, I would have provided an answer telling you how to do it, when I first saw Valmonts post.
But since you're beginning with that tone I won't even considder finding a solution for you..
|
|
|
12-21-2004, 11:50 AM
|
#5 (permalink)
|
|
[code][/code] enforcer
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
|
Quote:
|
Originally Posted by VaMpIrE
Holaaaa again ,,,,,,
MuahahahahahahahahaZ
maaaaaaaaaaan, You know nothing about programming or computer languages
Wahahahahahaha, You don't understand what these code means !!
Oh boy!!!
And above that you say that you're a programmer, and a super moderator in this forum
maaaaaaan, you're just a #%$#$#%#%##%#$#$#%#%$#.....toot toot toot
:th: Adiooooooooooooos :th:
|
Whatever it is that you think I am, you are out of options here. Leave and don't come back.
Toot.
__________________
|
|
|
12-21-2004, 06:34 PM
|
#6 (permalink)
|
|
Senior Grasshopper
Join Date: Jun 2003
Location: FL
Posts: 317
|
Trolls will be trolls... and bored 12 year olds..
-r
|
|
|
12-22-2004, 04:57 AM
|
#7 (permalink)
|
|
Guest
|
Please boot my potty mouth out of here.
Thank you, have nice day.
Last edited by Valmont; 12-22-2004 at 07:24 AM.
|
|
|
|
12-22-2004, 08:30 AM
|
#8 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,529
|
the topic should have been "can anyone do my homework for me" .. i can't believe this guy can flame when he's too lazy to even start his homework on his own. what a loser.
__________________
Mike
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 06:12 AM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|