The library implements

The library implements a simple model of text input and output. A text stream consists of a sequence of lines; each line ends with a newline character. If the system doesn't operate that way, the library does whatever necessary to make it appear as if it does. For instance, the library might convert carriage return and linefeed to newline on input and back again on output. The simplest input mechanism is to read one character at a time from the standard input, normally the keyboard, with getchar: int getchar(void) getchar returns the next input character each time it is called, or EOF when it encounters end of file. The symbolic constant EOF is defined in . The value is typically -1, bus tests should be written in terms of EOF so as to be independent of the specific value. In many environments, a file may be substituted for the keyboard by using the < causes="" read="" characters="" from="" infile="" switching="" of="" input="" done="" such="" a="" way="" that="" prog="" itself="" is="" oblivious="" to="" in="" the="" string="">filename: if prog uses putchar, prog >outfile will write the standard output to outfile instead. If pipes are supported, prog | anotherprog puts the standard output of prog into the standard input of anotherprog. Output produced by printf also finds its way to the standard output. Calls to putchar and printf may be interleaved - output happens in the order in which the calls are made. Each source file that refers to an input/output library function must contain the line #include before the first reference. When the name is bracketed by <> a search is made for the header in a standard set of places (for example, on UNIX systems, typically in the directory /usr/include). Many programs read only one input stream and write only one output stream; for such programs, input and output with getchar, putchar, and printf may be entirely adequate, and is certainly enough to get started. This is particularly true if redirection is used to connect the output of one program to the input of the next. For example, consider the program lower, which converts its input to lower case: #include #include main() /* lower: convert input to lower case*/ { int c while ((c = getchar()) != EOF) putchar(tolower(c)); return 0; } The function tolower is defined in ; it converts an upper case letter to lower case, and returns other characters untouched. As we mentioned earlier, ``functions'' like getchar and putchar in and tolower in are often macros, thus avoiding the overhead of a function call per character. Regardless of how the functions are implemented on a given machine, programs that use them are shielded from knowledge of the character set.

Related Links :

No comments:

Post a Comment


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!