> Online tutorial

delline


 (Text mode): Deletes line in text window


 Declaration:
 void delline(void);

 Remarks:
delline deletes the line containing the cursor and moves all lines below it
one line up.

delline operates within the currently active text window.

 Return Value:
 None



 Example:

 #include <conio.h>

 int main(void)
 {
    clrscr();
    cprintf("The function DELLINE deletes the line containing the\r\n");
    cprintf("cursor and moves all lines below it one line up.\r\n");
    cprintf("DELLINE operates within the currently active text\r\n");
    cprintf("window.  Press any key to continue . . .");
    gotoxy(1,2);  /* Move the cursor to the second line and first column */
    getch();

    delline();
    getch();

    return 0;
 }

clrscr


 Clears text mode window

 Declaration:
void clrscr(void);

 Remarks:


clrscr clears the current text window and places the cursor in the upper
left-hand corner (at position 1,1).

 Return Value:
 None




 Example:

 #include <conio.h>

 int main(void)
 {
    int i;

    clrscr();
    for (i = 0; i < 20; i++)
       cprintf("%d\r\n", i);
    cprintf("\r\nPress any key to clear screen");
    getch();

    clrscr();
    cprintf("The screen has been cleared!");
    getch();

    return 0;
 }

clreol


 Clears to end of line in text window

 Declaration:

void <a href="http://gan.doubleclick.net/gan_click?lid=41000000035692252&pubid=21000000000397534">clreol</a>(void);

 Remarks:


clreol clears all characters from the cursor position to the end of the line
within the current text window, without moving the cursor.

 Return Value:

None


 Example:

 #include <conio.h>

 int main(void)

 {
    clrscr();
    cprintf("The function CLREOL clears all characters from the\r\n");
    cprintf("cursor position to the end of the line within the\r\n");
    cprintf("current text window, without moving the cursor.\r\n");
    cprintf("Press any key to continue . . .");
    gotoxy(14, 4);
    getch();

    clreol();
    getch();

    return 0;
 }

cgets


 Reads string from console

 Declaration:

char *cgets(char *str);

 Remarks:
cgets reads a string of characters from the console and stores the string
(and the string length) in the location *str.

Before you call cgets, set str[0] to the maximum length of the string to be
read.

cgets reads characters until it encounters a carriage-return/linefeed
combination (CR/LF), or until the maximum allowable number of characters
have been read.

If cgets reads a CR/LF, it replaces the CR/LF with a \0 (null terminator)
before storing the string.

On return, str[1] is set to the number of characters actually read.

The characters read start at str[2] and end with a null terminator, so str
must be at least (str[0] + 2) bytes long.

 Return Value:
   On success, returns a pointer to str[2].


 Example:

 #include <stdio.h>
 #include <conio.h>

 int main(void)
 {
    char buffer[83];
    char *p;

    /* There's space for 80 characters plus the NULL terminator */
    buffer[0] = 81;

    printf("Input some chars:");
    p = cgets(buffer);
    printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p);
    printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer);

    /* Leave room for 5 characters plus the NULL terminator */
    buffer[0] = 6;

    printf("Input some chars:");
    p = cgets(buffer);
    printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p);
    printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer);
    return 0;
 }

realloc



 realloc<ALLOC.H>

   realloc reallocates main memory

 Declaration:
 
   void far *farrealloc(void far *oldblock, unsigned long nbytes);

 Remarks:

realloc adjusts the size of the allocated block to size, copying the
contents to a new location if necessary.


 Return Value:


   On success, both functions return the address of the reallocated block,
    which might be different than the address of the original block.
   On failure (if the block can't be reallocated, or if size == 0 for
    realloc), the functions return null.



#include <stdio.h>
#include <alloc.h>
#include <string.h>

int main(void)
{
   char *str;

   /* allocate memory for string */
   str = (char *) malloc(10);

   /* copy "Hello" into string */
   strcpy(str, "Hello");

   printf("String is %s\n  Address is %p\n", str, str);
   str = (char *) realloc(str, 20);
   printf("String is %s\n  New address is %p\n", str, str);

   /* free memory */
   free(str);

   return 0;
}