C++ Programming |
- Style Note in C
- Assigning variables to one another
- Breaking out early
- What is Programming style
- Understanding Filename
Posted: 28 Apr 2013 09:27 AM PDT Some programmers complain about the use of global variables in a program. One complaint is that it is difficult to see what information is being passed to a function unless all that information is passed as parameters. Sometimes global variables are very useful however, and this problem need not be crippling. A way to make this clear is to write global variables in capital letters only, while |
Assigning variables to one another Posted: 28 Apr 2013 08:38 AM PDT Variables can be assigned to numbers: var = 10; and assigned to each other: var1 = var2; In either case the objects on either side of the = symbol must be of the same type. It is possible (though not usually sensible) to assign a floating point number to a character for instance. So int a, b = 1; a = b; is a valid statement, and: float x = 1.4; char ch; ch = x; is a valid statement, since |
Posted: 28 Apr 2013 07:15 AM PDT Suppose that a program is in the middle of some awkward process in a function which is not main(), perhaps two or three loops working together, for example, and suddenly the function finds its answer. This is where the beauty of the return statement becomes clear. The program can simply call return(value) anywhere in the function and control will jump out of any number of loops or whatever and |
Posted: 28 Apr 2013 07:11 AM PDT C is actually a free format language. This means that there are no rules about how it must be typed, when to start new lines, where to place brackets or whatever. This has both advantages and dangers. The advantage is that the user is free to choose a style which best suits him or her and there is freedom in the way in which a program can be structured. The disadvantage is that, unless a strict |
Posted: 28 Apr 2013 07:02 AM PDT The compiler uses a special convention for the file names, so that we do not confuse their contents. The name of a source program (the code which you write) is 'filename.c'. The compiler generates a file of object code from this called 'filename.o', as yet unlinked. The final program, when linked to libraries is called 'filename' on Unix-like operating systems, and 'filename.EXE' on Windows |
You are subscribed to email updates from C++ Programming To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
Post a Comment