| | |
Removing numbers from a program.
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2007
Posts: 113
Reputation:
Solved Threads: 4
I started using the tutorial "Teach Yourself C++ in 21 days" yesterday, and I absolutely love it's clarity. However, there is one thing that perturbs me about it. All of the code written in the code is numbered. This is a great feature until I want to try running the code for myself and end up having to 70 numbers. Is there anyway to create a function to remove these numbers? Perhaps I could turn each line into a string and delete the first spaces of every string... or something along those lines. Below is a section of code that appears in the tutorial.
1: // Demonstrates declaration of a class and
2: // definition of an object of the class,
3:
4: #include <iostream.h> // for cout
5:
6: class Cat // declare the class object
7: {
8: public: // members which follow are public
9: int itsAge;
10: int itsWeight;
11: };
12:
13:
14: void main()
15: {
16: Cat Frisky;
17: Frisky.itsAge = 5; // assign to the member variable
18: cout << "Frisky is a cat who is " ;
19: cout << Frisky.itsAge << " years old.\n";
20:
1: // Demonstrates declaration of a class and
2: // definition of an object of the class,
3:
4: #include <iostream.h> // for cout
5:
6: class Cat // declare the class object
7: {
8: public: // members which follow are public
9: int itsAge;
10: int itsWeight;
11: };
12:
13:
14: void main()
15: {
16: Cat Frisky;
17: Frisky.itsAge = 5; // assign to the member variable
18: cout << "Frisky is a cat who is " ;
19: cout << Frisky.itsAge << " years old.\n";
20:
Last edited by zoner7; Dec 29th, 2007 at 2:39 am.
Yes, you could write a program that copies the sample files to a new file, removing the leading digits, colon and space from each line. This would be a good exercise. You would not necessarily need to handle each line as a string, just read characters until the first space, then copy characters to new file till newline encountered. Repeat till end of file.
Also, if you use Visual C++, in the edit window you can select columns of text by holding down the Alt key, then clicking and dragging the mouse. This makes manual removal of the numbering fairly quick and easy.
Also, if you use Visual C++, in the edit window you can select columns of text by holding down the Alt key, then clicking and dragging the mouse. This makes manual removal of the numbering fairly quick and easy.
Everyone's gotta believe in something. I believe I'll have another drink.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
thanks for the links...they are really useful...
but my problem is that i dont know what are commands to compile and run the cpp program..
ok see
steps are
1.save file in bin
2.run command prompt
3. type in
now i m in the same directory where the compiler and the program is saved...
now what next to compile my porgram named test.cpp
in java i know those commands they are
...
output
the line THIS IS A TEST PROGRAM in the third line is a command line argument..
i wanna know the cpp equivalent for this..
but my problem is that i dont know what are commands to compile and run the cpp program..
ok see
steps are
1.save file in bin
2.run command prompt
3. type in
cd c:\dev-cpp\binnow i m in the same directory where the compiler and the program is saved...
now what next to compile my porgram named test.cpp
in java i know those commands they are
C++ Syntax (Toggle Plain Text)
cd c:\program files\java\jdk1.5\bin c:\program files\java\jdk1.5\bin> javac filename.java c:\program files\java\jdk1.5\bin> java filename this is a test program
output
the line THIS IS A TEST PROGRAM in the third line is a command line argument..
i wanna know the cpp equivalent for this..
Last edited by rajatC; Dec 29th, 2007 at 3:58 am.
Life is about being happy...
•
•
Join Date: Dec 2007
Posts: 113
Reputation:
Solved Threads: 4
DEV C++ has an integrated compiler; no commands are necessary to compile anything, unless of course you are simply interested. To compiler using the integrated compiler, look on the upper-left of the IDE at the second toolbar. The compiler button is the first button from the left.
To compiler using the command prompt, here's a link. The last post explains what you are looking for.
To compiler using the command prompt, here's a link. The last post explains what you are looking for.
Last edited by zoner7; Dec 29th, 2007 at 2:56 pm.
•
•
Join Date: Dec 2007
Posts: 113
Reputation:
Solved Threads: 4
•
•
•
•
Yes, you could write a program that copies the sample files to a new file, removing the leading digits, colon and space from each line. This would be a good exercise. You would not necessarily need to handle each line as a string, just read characters until the first space, then copy characters to new file till newline encountered. Repeat till end of file.
Also, if you use Visual C++, in the edit window you can select columns of text by holding down the Alt key, then clicking and dragging the mouse. This makes manual removal of the numbering fairly quick and easy.
Invent the program which read a file that contains those codes and write a new file with no number at the beginning of the line. To do this, you should this article:
http://www.daniweb.com/forums/thread6542.html
http://www.daniweb.com/forums/thread6542.html
Yesterday is a history, tomorrow is a mystery, today is a gift.
Behind every smile is a tear.
Visal .In
Behind every smile is a tear.
Visal .In
•
•
•
•
thanks for the links...they are really useful...
•
•
•
•
but my problem is that i dont know what are commands to compile and run the cpp program..
ok see
steps are
1.save file in bin
2.run command prompt
3. type in cd c:\dev-cpp\bin
now i m in the same directory where the compiler and the program is saved...
now what next to compile my porgram named test.cpp
in java i know those commands they are
(Toggle Plain Text)
cd c:\program files\java\jdk1.5\bin
c:\program files\java\jdk1.5\bin> javac filename.java
c:\program files\java\jdk1.5\bin> java filename this is a test programcd c:\program files\java\jdk1.5\bin
c:\program files\java\jdk1.5\bin> javac filename.java
c:\program files\java\jdk1.5\bin> java filename this is a test program
...
output
the line THIS IS A TEST PROGRAM in the third line is a command line argument..
i wanna know the cpp equivalent for this..
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
•
•
•
•
I couldn't see any links posted in this thread before your post.
You've just hacked this thread for your own problem which is not at all related to what the OP of this thread is talking about. You should have started a new thread instead.
actually that's the problem with my net connection..it's too slow and i got confused between a lots of tabs opened in my web browser...by mistake i posted it in this
it belong to the thread http://www.daniweb.com/forums/thread102784.html
sorry...it wont happen again...because i m going to change it...
*change my connection
Life is about being happy...
•
•
•
•
sorry...
. I just mentioned it in case you had done it and you were not aware. Don't mind.. "You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
![]() |
Similar Threads
- Numbers in Turbo C++ (C++)
- Pascal calculator program (Pascal and Delphi)
- Removing duplicates (C)
- I need help removing Update.exe Spyware/Adware (Viruses, Spyware and other Nasties)
- Please, I need help removing NGPW36 (Viruses, Spyware and other Nasties)
- Help with the About Blank SpyWare (Viruses, Spyware and other Nasties)
- Aurora Trouble... please help I cant delet it (Viruses, Spyware and other Nasties)
- Program Output Display Tweak Help (Java)
- Cannot find server or DNS Error after a few minutes (Viruses, Spyware and other Nasties)
- IE/Trojan Problems - Desktop Trojan (Viruses, Spyware and other Nasties)
Other Threads in the C++ Forum
- Previous Thread: How to hide input from displaying on screen
- Next Thread: c++ compilation error
| Thread Tools | Search this Thread |
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






