hii, i am computer science student and i am doing win console application program "Project" by c++ compiler "mic visiual 6", the project is like a small data base which stores student names and thier grades and search for names, add, delete,edit and other things. i am asking if i can make it more friendly by putting colors or any special stuff. for example i read in a forum ( system("cls") ) which really helped me in my project and system("pause") too. any one know things like that plzzzz tell me. i need to know these stuff.
another thing.. i read that there is another systems like system("time") if any one know what these systems make plzz help me.:rolleyes:

Formatting Output
Formatting output is one of the most important aspects of developing user-friendly programs. C++ offers several conventions that allow a programmer to format output on the screen. The functions that deal with output format are in the standard include file "iomanip.h."

Two common I/O manipulators are setw and setprecision. Setw sets the width of the field allocated for the output. It takes the size of the field (in number of characters) as a parameter. For example, the code:

cout << setw(5) << "H";
generates the following output on the screen (each underscore represents a space):

_ _ _ _ H

The setprecision manipulator sets the total number of digits to be displayed when floating point numbers are output. For example, the code:

cout << setprecision(5) << 123.456;

generates the following output on the screen:

123.46

The setprecision manipulator can also set the number of decimal places displayed, but first you have to set an ios flag that specifies that it should behave this way. The flag is set with the following statement:

cout.setf(ios::fixed);

Once the flag has been set specifying that floating point output should be fixed, the number you pass as a parameter to setprecision is the number of decimal places displayed. For example, the code:

cout.setf(ios::fixed);
cout << setprecision(5) << 12.345678;

generates the following output on the screen:

12.34567

Pausing Output
A frequently encountered problem involves pausing the output of a program so that the output can be read before the output window closes. Use the Execute command on the Build menu to run your program. The Execute command will automatically place a "Press any key to continue..." prompt on the screen when your program terminates. When you have finished with the output, press a key to make the window close.

Clearing the Screen
To clear the entire output window of a program, you must use a system function found in the stdlib.h include file. First, include stdlib.h at the top of your program. Then, just insert the following call whenever you want to clear the screen:

system("CLS");

The program below is an example of how to use this method of clearing the screen.

#include <iostream.h>
#include <stdlib.h>

int main()

{
cout << "Text before the clear screen." << endl;
system("CLS");
cout << "Text following the clear screen." << endl;
return 0;
}

Sending Output to the Printer
How you print is now a function of your operating system. To print using Windows 95/98 or NT, you have to get your output to a print manager in the operating system.

To direct output to a printer, you must first open a file stream to send output to. You can do this using the same method that you use to send output to a file. First, declare a variable of type fstream. Then open the stream using the member function, open. Instead of opening the stream using the name of a file, use the name of your printer port, for example, "LPT1."

Once a file stream is open, you can print using the name of the stream variable followed by the << operator and the data you want to send to the printer. Be sure to close the stream when you no longer need to use it.

The example program below will send text to a printer on port LPT1.

#include <fstream.h>

int main()

{
  ofstream print; // stream variable declaration
  print.open("LPT1"); // open stream

  // Print Text (the character ‘\f’ will produce a form feed)
  print << "This text will print on the printer.\f";
  print.close(); // close stream
  return 0;
}

Important Note:
1-Blindly directing text to a printer port assumes some things are true.

It assumes that you have a printer attached to the specified port or that the port is being captured and redirected to a printer.
It assumes that the printer is capable of accepting plain text. For example, a PostScript printer will not print unless the data comes through a PostScript printer driver. The code above does not make use of any drivers.
another example this program traping function key F1 and F2

# include<iostream.h>
# include<conio.h>
void function_key();            //prototype of the function
void main()
{
            function_key();         //function call
}
void function_key()              //function body
{
               int ret;
               ret = getch();         //get the ASCII value of the key pressed

                            if (ret == 0)
                            {
                               ret = getch()+256;

                                              switch(ret)                   //switch between various values of 'ret'
                                              {                                                        
                                                  case 315:
                                                  cout<<" F1 pressed!\n\n";
                                                  break;
                                                  case 316:
                                                  cout<<"F2 pressed!\n";
                                                  break;
                                                  case 317:
                                                  cout<<"F3 pressed!\n";
                                                  break;
                                                  case 318:
                                                  cout<<"F4 pressed!\n";
                                                  break;
                                                  case 319:
                                                  cout<<"F5 pressed!\n";
                                                  break;
                                                  case 320:
                                                  cout<<"F6 pressed!\n";
                                                  break;
                                                  case 321:
                                                  cout<<"F7 pressed!\n";
                                                  break;
                                                  case 322:
                                                  cout<<"F8 pressed!\n";
                                                  break;
                                                  case 323:
                                                  cout<<"F9 pressed!\n";
                                                  break;
                                                  case 324:
                                                  cout<<"F10 pressed!\n";
                                                 break;
                                                 default:
                                                 cout<<"Non function key was pressed!\n";
                                                 break;
                                            }
                                    }
                       else
                                cout<<"Non Function Key pressed!\n";

}

Wow!
I really can use this stuff too.
Thank a lot. :)

You are most welcome.Now there is a full tut on file i/o in the C++ tutorial section :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.