Using cout.width() in C++
The default width of your output will be just enough space to print the number, character, or string in the output buffer. You can change this by using width(). Because width() is
Read tutorialTHE TUTORIAL LIBRARY
The default width of your output will be just enough space to print the number, character, or string in the output buffer. You can change this by using width(). Because width() is
Read tutorialThe input object cin has two additional methods that can come in rather handy: peek(), which looks at but does not extract the next character, and putback(), which inserts a charac
Read tutorialAt times you want to ignore the remaining characters on a line until you hit either end of line (EOL) or end of file (EOF). The member function ignore() serves this purpose. ignore
Read tutorialThe global object cin is responsible for input and is made available to your program when you include iostream.h. In most of the examples in this site, you used the overloaded extr
Read tutorialIn addition to asserting that something is true using the assert() macro, you may want to print the current value of pointers, variables, and strings. This can be very helpful in c
Read tutorialIt is important to note that assert() is not intended to handle runtime error conditions such as bad data, out-of-memory conditions, unable to open file, and so forth. assert() is
Read tutorialMany compilers offer an assert() macro. The assert() macro returns TRUE if its parameter evaluates TRUE and takes some kind of action if it evaluates FALSE. Many compilers will abo
Read tutorialEvery time you run your compiler, your preprocessor runs first. The preprocessor looks for preprocessor instructions, each of which begins with a pound symbol (#). The effect of ea
Read tutorialThe most popular library is almost certainly the string library, with perhaps the function strlen() called most often. strlen() returns the length of a null-terminated string. List
Read tutorialThe second most popular function in string.h probably was strcpy(), which copied one string to another. This may now be diminished somewhat as C-style null-terminated strings have
Read tutorialRelated to strcpy() and strncpy() are the standard functions strcat() and strncat(). The former concatenates one string to another; that is, it appends the string it takes as its s
Read tutorialThe standard library supplies the function time(), which takes a pointer to a time_t variable and fills it with the current time. It also provides ctime(), which takes the time_t v
Read tutorialOne example today. A better developer tomorrow.