September 1998
Intermediate to advanced
848 pages
20h 13m
English
You aren't limited to the standard C library options for input and output. If you don't have these options or don't like them, you can prepare your own versions, building on getchar() and putchar(). Suppose you want a function like puts() that doesn't automatically add a newline. Listing 11.10 shows one way to do it.
/* put1.c -- prints a string without adding \n */
#include <stdio.h>
void put1(const char * string) /* string not altered */
{
while (*string != `\0')
putchar(*string++);
}
|
The char pointer string initially points to the first element of the called argument. Because this function doesn't change the string, use the const modifier. After the contents of that element ...
Read now
Unlock full access