Friday, September 14, 2007

Re: [BLUG] C/C++

Quoting Pawsitive Results <pawsitiveresults@gmail.com>:

>
> And, for over a year now, I've suspected that, sooner or later, my
> irrational fear of command line text editors was going to bite me in
> the butt. It appears I was right.
>

Hi Ana,

If you have an irrational fear of the command line then try an example
to get you started.

Open up a command line terminal somewhere.

At the terminal type:

"ls learningCpp" <enter>

If it says "No such file or directory" then type

"mkdir learningCpp" <enter>

(otherwise choose a different directory name)

Follow this by

"cd learningCpp" <enter>

then

"emacs example.cpp" <enter>

An emacs window should open.

Then cut and paste the following into the emacs window

/////////START HERE////////////
#include <iostream>
using namespace std;

int main(){

for(int i=0;i<10;i++){
cout << "hello!!! " << i << endl;
}

return 0;

}
//////////END HERE//////////////

In the emacs window hold down the control key. While holding down the
control key type x then type s. That will save the file. Now go back
to the terminal.

In the terminal type

"g++ example.cpp -o example" <enter>

followed by

"./example" <enter>.

Assuming I haven't left anything out, then that will have edited the
program example.cpp, compiled it and then run it.

I'm just using emacs as an example since that's what my own limited
experience has provided me with.

Hope that helps.

Chad


_______________________________________________
BLUG mailing list
BLUG@linuxfan.com
http://mailman.cs.indiana.edu/mailman/listinfo/blug

No comments: