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:

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.

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

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..

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.

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.

Well, I was able to remove the numbers quite easily using Visual C++, but you ignited my curiosity with that comment. How can I tell the program to read the characters?

thanks for the links...they are really useful...

I couldn't see any links posted in this thread before your post.

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'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.

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

sorry...

There's no need to be :). I just mentioned it in case you had done it and you were not aware. Don't mind..

This article has been dead for over six months. Start a new discussion instead.