Re: anal panic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

just some more comments:

> 
> (1) I'm not sure that "anal panic" is an appropriate subject,

I agree


> (3) You may want to consider an IDE to help smooth things along. Learning to program is hard enough without also having to jump the hurdles with windows, make files etc. My favorite IDE is merit-ware but not open-source (that means its free, but you should donate if you like it); email me personally if you want to know what it is.

I'm teaching programming (or, I used to teach; at different levels at the university), and my strong
recommendation is NOT TO USE ANY tool which is between you and the compiler!
These environments are just in the way, too many students using Delphi, ... still after three years
don't know what a program is (that's actually sad, but true! just mouse clicks into something, something
happens, and that's the "program").

Programming is like driving a car, and you have to feel it with your own hands! (literally; like in mathematics,
at the beginning you must do all calculations by yourself, only in this way appropriate brain structures
are built up).

> ofstream out;
> out.open("testfile.txt");
> out << "here is a line" << endl;
> A fully compliant piece of code would look like this (for the same result):
> #include <fstream> /* you must import this library */
> int main ( int argc, char *argv[] ) { /* you need all these warts for the entry point, this is C++, not C! */

since no argument from the command line is used, it's better to use

int main() {

> std::ofstream testfile("testfile.txt"); /* use the std:: namespace wart to get to the ofstream object; use the nice constructor syntax */
> testfile << "Here is a line of text\n"; /* although we could use std::endl, it is NOT a character and produces a wart in a text file; use the eol character \n instead */
> return 5001; /* return a value ... this doesn't matter that much at this point */

huuuhh?! a strange magical number?? if the main function is left without an explicit return statement,
then 0 is returned, and I think that's exactly what we want here, so I would leave out the
return statement;

Oliver


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux