Treceți la conținutul principal

c plus plus man fundamental de prg

manualul fundamental de programare


#include <stdio.h>

void main(void)
 {
   printf("Jamsa\'s C/C++ Programmer\'s Bible!");
 }

#include <stdio.h>

void main(void)
 {
   printf("Jamsa\'s C/C++ Programmer\'s Bible!);
 }

#include <stdio.h>

void main(void)
 {
   printf("Jamsa\'s C/C++ Programmer\'s Bible!");
 }

#include <stdio.h>

void main(void)
 {
   printf ("Jamsa\'s ");
   printf ("C/C++ Programmer\'s ");
   printf ("Bible!");
 }

#include <stdio.h>

void main(void)
 {
   printf ("This is line one.");
   printf ("This is the second line.");
 }

#include <stdio.h>

void main(void)
 {
   printf ("This is line one.\n");
   printf ("This is the second line.");
 }

#include <stdio.h>

void Main(void)
 {
   printf ("This program does not compile.");
 }
#include <stdio.h>

void main(void)
 {
   printf ("This is line one.");
   printf ("This is the second line.");
 }

#include <stdio.h>

void main(void)
 {
   print("This program does not link");
 }

// Program: COMMENT.C
// Written by: Kris Jamsa and Lars Klander
// Date written: 08-22-97

// Purpose: Illustrates the use of comments in a C program.

#include <stdio.h>

void main(void)
 {
   printf ("Jamsa\'s C/C++ Programmer\'s Bible!");  // Display a message
 }


/* Program: COMMENT.C
   Written by: Kris Jamsa and Lars Klander
   Date written: 08-22-97

   Purpose: Illustrates the use of comments in a C program. */

#include <stdio.h>

void main(void)
 {
   printf ("Jamsa\'s C/C++ Programmer\'s Bible!");  /* Display a message */
 }


#include <stdio.h> 
void main(void){printf("Jamsa\'s C/C++ Programmer\'s Bible!");}

void main(void)
 {
   printf ("Jamsa\'s C/C++ Programmer\'s Bible");
 }

#include <stdio.h>

void main(void)
 {
   // printf ("This line does not appear");

   /* This is a comment

      printf ("This line does not appear either");

   */
 }

#include <stdio.h>

void main(void)
 {
   int positive = 32767;
   int negative = -32768;

   printf("%d + 1 is %d\n", positive, positive+1);
   printf("%d - 1 is %d\n", negative, negative-1);
 }
#include <stdio.h>

void main(void)
 {
   float accurate = 0.123456790987654321;
   double more_accurate = 0.1234567890987654321;

   printf("Value of float\t %21.19f\n", accurate);
   printf("Value of double\t %21.19f\n", more_accurate);
 }
#include <stdio.h>

void main(void)
 {
   int age = 41;
   int height = 73;
   int weight = 165;

   printf("The user\'s age: %d weight: %d height: %d\n", age, weight, height);
   printf("%d plus %d equals %d\n", 1, 2, 1 + 2);
 }
#include <stdio.h>

void main(void)
 {
   int value = 255;

   printf("The decimal value %d in octal is %o\n", value, value);
   printf("The decimal value %d in hexadecimal is %x\n", value, value);
   printf("The decimal value %d in hexadecimal is %X\n", value, value);
 }

#include <stdio.h>

void main(void)
 {
   unsigned int value = 42000;

   printf("Displaying 42000 as unsigned %u\n", value);
   printf("Displaying 42000 as int %d\n", value);
 }


#include <stdio.h>

void main(void)
 {
   long int one_million = 1000000;

   printf ("One million is %ld\n", one_million);
   printf ("One million is %d\n", one_million);
 
 }

#include <stdio.h>

void main(void)
 {
   float price = 525.75;
   float sales_tax = 0.06; 

   printf("The item cost is %f\n", price);
   printf("Sales tax on the item is %f\n", price * sales_tax);
 }
#include <stdio.h>

void main(void)
 {
   printf("The letter is %c\n", 'A');
   printf("The letter is %c\n", 65);
 }

#include <stdio.h>

void main(void)
 {
   float pi = 3.14159;
   float radius = 2.0031;

   printf("The circle's area is %e\n", 2 * pi * radius);
   printf("The circle's area is %E\n", 2 * pi * radius);
 }

#include <stdio.h>

void main(void)
 {
   printf("Displaying 0.1234 yields %g\n", 0.1234);
   printf("Displaying 0.00001234 yields %g\n", 0.00001234);
 }

#include <stdio.h>

void main(void)
 {
   char title[255] = "Jamsa\'s C/C++ Programmer\'s Bible";

   printf("The name of this book is %s\n", title);
 }

#include <stdio.h>

void main(void)
 {
   int value;

   printf("The address of the variable value is %p\n", &value);
 }

#include <stdio.h>

void main(void)
 {
   int neg_int = -5;
   int pos_int = 5;  
   float neg_flt = -100.23;
   float pos_flt = 100.23;

   printf("The integer values are %+d and %+d\n", neg_int, pos_int);
   printf("The floating point values are %+f %+f\n", neg_flt, pos_flt);
 }

#include <stdio.h>

void main(void)
 {
   int value = 5;

   printf ("%1d\n", value);
   printf ("%2d\n", value);
   printf ("%3d\n", value);
   printf ("%4d\n", value);
 }
#include <stdio.h>

void main(void)
 {
   int value = 5;

   printf ("%01d\n", value);
   printf ("%02d\n", value);
   printf ("%03d\n", value);
   printf ("%04d\n", value);
 }
#include <stdio.h>

void main(void)
 {
   int value = 255;

   printf("The decimal value %d in octal is %#o\n", value, value);
   printf("The decimal value %d in hexadecimal is %#x\n", value, value);
   printf("The decimal value %d in hexadecimal is %#X\n", value, value);
 }

#include <stdio.h>

void main(void)
 {
   float value = 1.23456;

   printf ("%8.1f\n", value);
   printf ("%8.3f\n", value);
   printf ("%8.5f\n", value);
 }
#include <stdio.h>

void main(void)
 {
   float value = 1.23456;

   printf ("%12.1e\n", value);
   printf ("%12.3e\n", value);
   printf ("%12.5e\n", value);
 }
#include <stdio.h>

void main(void)
 {
   int int_value = 5;
   float flt_value = 3.33;

   printf("Right justified %5d value\n", int_value);
   printf("Left justified %-5d value\n", int_value);
   printf("Right justified %7.2f value\n", flt_value);
   printf("Left justified %-7.2f value\n", flt_value);
 }
#include <stdio.h>

void main(void)
 {
   int int_value = 5;
   
   printf("Left justifed with sign %-+3d\n", int_value);
 }

#include <stdio.h>

void main(void)
 {
   char *near_title = "Jamsa\'s C/C++ Programmer\'s Bible";
   char far *far_title = "Jamsa\'s C/C++ Programmer\'s Bible";

   printf("The book\'s title: %Ns\n", near_title);
   printf("The book\'s title: %Fs\n", far_title);
 }
#include <stdio.h>

void main(void)
 {
   int first_count;
   int second_count;

   printf("Jamsa%n\'s C/C++ Programmer\'s Bible%n\n", &first_count, &second_count);
   printf("First count %d Second count %d\n", first_count, second_count);
 }

#include <stdio.h>

void main(void)
 {
   int result;

   result = printf("Jamsa\'s C/C++ Programmer\'s Bible!\n");
   if (result == EOF)
     fprintf(stderr, "Error within printf\n");
 }
#include <stdio.h>

void main(void)
 {
   int seconds_in_an_hour;  
   float average;

   seconds_in_an_hour = 60 * 60;
   average = (5 + 10 + 15 + 20) / 4;
   printf("The number of seconds in an hour %d\n", seconds_in_an_hour);
   printf("The average of 5, 10, 15, and 20 is %f\n", average);
   printf("The number of seconds in 48 minutes is %d\n", seconds_in_an_hour - 12 * 60);
 }
#include <stdio.h>

void main(void)
 {
   int remainder;
   int result;

   result = 10 / 3;
   remainder = 10 % 3;
   printf("10 Divided by 3 is %d Remainder %d\n", result, remainder);
 }

#include <stdio.h>

void main(void)
 {
   int value = 0;

   while (value <= 100)
     {
       printf("%d\n", value);
       value++;
     }
 }

#include <stdio.h>

void main(void)
 { 
   int value = 1;
   
   printf("Using postfix %d\n", value++); 
   printf("Value after increment %d\n", value);
   value = 1;
   printf("Using prefix %d\n", ++value); 
   printf("Value after increment %d\n", value);
 }
#include <stdio.h>

void main(void)
 { 
   int value = 1;
   
   printf("Using postfix %d\n", value--); 
   printf("Value after decrement %d\n", value);
   value = 1;
   printf("Using prefix %d\n", --value); 
   printf("Value after decrement %d\n", value);
 }
#include <stdio.h>

void main(void)
 {
   printf("0 | 0 is %d\n", 0 | 0);
   printf("0 | 1 is %d\n", 0 | 1);
   printf("1 | 1 is %d\n", 1 | 1);
   printf("1 | 2 is %d\n", 1 | 2);
   printf("128 | 127 is %d\n", 128 | 127);
 }
#include <stdio.h>

void main(void)
 {
   printf("0 & 0 is %d\n", 0 & 0);
   printf("0 & 1 is %d\n", 0 & 1);
   printf("1 & 1 is %d\n", 1 & 1);
   printf("1 & 2 is %d\n", 1 & 2);
   printf("15 & 127 is %d\n", 15 & 127);
 }
#include <stdio.h>

void main(void)
 {
   printf("0 ^ 0 is %d\n", 0 ^ 0);
   printf("0 ^ 1 is %d\n", 0 ^ 1);
   printf("1 ^ 1 is %d\n", 1 ^ 1);
   printf("1 ^ 2 is %d\n", 1 ^ 2);
   printf("15 ^ 127 is %d\n", 15 ^ 127);
 }
#include <stdio.h>

void main(void)
 {
   int value = 0xFF;

   printf("The inverse of %X is %X\n", value, ~value);
 }
#include <stdio.h>

void main(void)
 {
   printf("Variables of type int use %d bytes\n", sizeof(int));
   printf("Variables of type float use %d bytes\n", sizeof(float));
   printf("Variables of type double use %d bytes\n", sizeof(double));
   printf("Variables of type unsigned use %d bytes\n", sizeof(unsigned));
   printf("Variables of type long use %d bytes\n", sizeof(long));
 }

#include <stdio.h>

void main(void)
 {
   unsigned u_val = 1;
   signed int value = -1;

   printf("%u (unsigned) shifted left 2 times is %u\n", u_val, u_val << 2);
   printf("%u (unsigned) shifted right 2 times is %u\n", u_val, u_val >> 2);
   u_val = 65535;
   printf("%u (unsigned) shifted left 2 times is %u\n", u_val, u_val << 2);
   printf("%u (unsigned) shifted right 2 times is %u\n", u_val, u_val >> 2);
   printf("%d (signed) shifted left 2 times is %d\n", value, value << 2);
   printf("%d (signed) shifted right 2 times is %d\n", value, value >> 2);
 }#include <stdio.h>
#include <stdlib.h>

void main(void)
 {
   unsigned value = 1;

   printf("%u rotated right once is %u\n", value, _rotr(value, 1));
   value = 5;
   printf("%u rotated right twice is %u\n", value, _rotr(value, 2));
   value = 65534;
   printf("%u rotated left twice is %u\n", value, _rotl(value, 2));
 }


#include <stdio.h>

void main(void)
 {
   int age = 21;
   int height = 73;

   if (age == 21)
     printf("User\'s age is 21\n");

   if (age != 21)
     printf("User\'s age is not 21\n");

   if (height == 73)
     printf("User\'s height is 73\n");

   if (height != 73)
     printf("User\'s height is not 73\n");
 }

#include <stdio.h>

void main(void)
{ 
int age = 10;
int user_has_dog = 0;   // 0 is false
if (age == 10)
{
printf("Dogs are important pets\n");
if (! user_has_dog)
printf("You should get a dalmatian\n");
}
printf("Happy is a dalmatian\n");
}
#include <stdio.h>

void main(void)
 { 
   int age = 10;
   int user_has_dog = 0;   // 0 is false

   if (age == 10)
     {
       printf("Dogs are important pets\n");
       if (! user_has_dog)
         printf("You should get a dalmatian\n");
     }
   printf("Happy is a dalmatian\n");
 }
#include <stdio.h>

void main(void)
 {
   int counter;

   for (counter = 1; counter <= 5; counter++)
    printf("%d ", counter);

   printf("\nStarting second loop\n");
   
   for (counter = 1; counter <= 10; counter++)
    printf("%d ", counter);

   printf("\nStarting third loop\n");

   for (counter = 100; counter <= 5; counter++)
    printf("%d ", counter);
 }
#include <stdio.h>

void main(void)
 {
   int counter;

   for (counter = 5; counter >= 1; counter--)
    printf("%d ", counter);

   printf("\nStarting second loop\n");
   
   for (counter = 10; counter >= 1; counter--)
    printf("%d ", counter);

   printf("\nStarting third loop\n");

   for (counter = 0; counter >= 1; counter--)
    printf("%d ", counter);
 }
#include <stdio.h>

void main(void)
 {
   int counter;

   for (counter = -100; counter <= 100; counter += 5)
    printf("%d ", counter);

   printf("\nStarting second loop\n");
   
   for (counter = 100; counter >= -100; counter -= 25)
    printf("%d ", counter);
 }
#include <stdio.h>

void main(void)
 {
   char letter;
   float percent;

   for (letter = 'A'; letter <= 'Z'; letter++)
     putchar(letter);

   for (letter = 'z'; letter >= 'a'; letter--)
     putchar(letter);

   putchar('\n');

   for (percent = 0.0; percent < 1.0; percent += 0.1)
     printf("%3.1f\n", percent);
 }
#include <stdio.h>

void main(void)
 {
   int i;
   int result = 0;
   int value = 1;

   for (i = 0; i < 100; i++)
    {
      printf("%d ", i);
      result = value * --i;   
    }
 
   printf("Result %d\n", result);
 }
#include <stdio.h>

void main(void)
 {
   int i, j;

   for (i = 0, j = 100; i <= 100; i++, j++)
     printf("i = %d j = %d\n", i, j);
 }

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

void main(void)
 {
   char letter;               // Letter typed by the user

   printf("Do you want to continue? (Y/N): ");

   letter = getch();                  // Get the letter
   letter = toupper(letter);          // Convert letter to uppercase
   
   while ((letter != 'Y') && (letter != 'N'))
     {
       putch(7);                        // Beep the speaker
       letter = getch();                // Get the letter
       letter = toupper(letter);         // Convert letter to uppercase
     }

   printf("\nYour response was %c\n", letter);
 }

#include <stdio.h>

void main(void) 
 {
   int counter = 1;  // Initialize the control variable

   while (counter <= 100)  // Test the control variable
     {
       printf("%d ", counter);  // Execute the statements

       counter++;    // Modify the control variable
     }
 }


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

void main(void)
 {
   char letter;
   
   do
 {
     printf("A Display directory listing\n");
     printf("B Change system time\n");
     printf("C Change system date\n");
     printf("Q Quit\n");
     printf("Choice: ");
     
     letter = getch();     
     letter = toupper(letter);

     if (letter == 'A')
       system("DIR");
     else if (letter == 'B')
       system("TIME");
     else if (letter == 'C')
       system("DATE");
    }
   while (letter != 'Q');
 }

#include <stdio.h>

void main(void)
 {
   int counter;

   printf("\nEven values\n");
   for (counter = 1; counter <= 100; counter++)
     {
       if (!(counter % 2))  // Even
         printf("%d ", counter);
     }

   printf("\nOdd values\n");
   counter = 0;
   while (counter <= 100) 
     {
       counter++;

       if (counter % 2) // Odd 
         printf("%d ", counter);
     }
 }

#include <stdio.h>

void main(void)
 {
   int counter;

   printf("\nEven values\n");
   for (counter = 1; counter <= 100; counter++)
     {
       if (counter % 2)  // Odd
         continue;

       printf("%d ", counter);
     }

   printf("\nOdd values\n");
   counter = 0;
   while (counter <= 100) 
     {
       counter++;

       if (! (counter % 2)) // Even 
         continue;

       printf("%d ", counter);
     }
 }

#include <stdio.h>

void main(void)
 {
   int counter;

   for (counter = 1; counter <= 100; counter++)
    {
      if (counter == 50)
        break;

      printf("%d ", counter);
    }

   printf("\nNext loop\n");

   for (counter = 100; counter >= 1; counter--)
    {
      if (counter == 50)
        break;

      printf("%d ", counter);
    }
 }   
 
#include <stdio.h>

void main(void)
 {
   int count = 1;

   label:
     printf("%d ", count++);
     
     if (count <= 100)
       goto label;
 }
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <stdlib.h>

void main(void)
 {
   char letter;
   
   do {
     printf("A Display directory listing\n");
     printf("B Change system time\n");
     printf("C Change system date\n");
     printf("Q Quit\n");
     printf("Choice: ");
     
     letter = getch();     
     letter = toupper(letter);

     switch (letter) {
       case 'A': system("DIR");
                 break;
       case 'B': system("TIME");
                 break;
       case 'C': system("DATE");
                 break;
     };
    }
   while (letter != 'Q');
 }

#include <stdio.h>

void main(void)
 {
   char letter;

   int vowel_count = 0;
   
   for (letter = 'A'; letter <= 'Z'; letter++)
     switch (letter) {
       case 'A':
       case 'E':
       case 'I':
       case 'O':
       case 'U': vowel_count++;
     }; 
 
   printf("The number of vowels is %d\n", vowel_count);
 }
#include <stdio.h>

void main(void)
 {
   char letter;
   int vowel_count = 0;
   int consonant_count = 0;   
   
   for (letter = 'A'; letter <= 'Z'; letter++)
     switch (letter) {
       case 'A':
       case 'E':
       case 'I':
       case 'O':
       case 'U': vowel_count++;
                 break;
       default: consonant_count++;
     }; 
 
   printf("The number of vowels is %d\n", vowel_count);
   printf("The number of vowels is %d\n", consonant_count);
 }
#define LINE 128
#define TITLE "Jamsa\'s C/C++ Programmer\'s Bible"
#define SECTION "Macros"

void main(void)
{
 char book[LINE];
 char library_name[LINE];

 printf("This book's title is %s\n", TITLE);
 printf(SECTION);
}#include <stdio.h>

void main(void)
 {
   printf("The file %s is under Beta testing\n", __FILE__);
 }
#include <stdio.h>

void main(void)
 {
   printf("Successfully reached line %d\n", __LINE__);

   // Other statements here
   
   printf("Successfully reached line %d\n", __LINE__);
 }
#include <stdio.h>

void main(void)
 {
   printf("File %s: Successfully reached line %d\n", 
     __FILE__, __LINE__);

   // Other statements here
   
#line 100 "FILENAME.C"

   printf("File %s: Successfully reached line %d\n", 
   __FILE__, __LINE__);
 }
#include <stdio.h>

void main(void)
 {
   printf("Beta Testing: Last compiled %s %s\n", __DATE__, 
     __TIME__);
 }
#include <stdio.h>

void main(void)
 {
 #ifdef __STDC__
  printf("ANSI C compliance\n");
 #else
  printf("Not in ANSI C mode\n");
 #endif
 }
#include <stdio.h>

void main(void)
 {
 #ifdef __cplusplus
  printf("Using C++\n");
 #else
  printf("Using C\n");
 #endif
 }
#include <stdio.h>

#define SUM(x, y) ((x) + (y))

void main(void)
 {
   printf("Adding 3 + 5 = %d\n", SUM(3, 5));
   printf("Adding 3.4 + 3.1 = %f\n", SUM(3.4, 3.1));
   printf("Adding -100 + 1000 = %d\n", SUM(-100, 1000));
 }

  
#include <stdio.h>

#define MIN(x, y) (((x) < (y)) ? (x): (y))
#define MAX(x, y) (((x) > (y)) ? (x): (y))

void main(void)
 {
   printf("Maximum of 10.0 and 25.0 is %f\n", MAX(10.0, 25.0));
   printf("Minimum of 3.4 and 3.1 is %f\n", MIN(3.4, 3.1));
 }

  
#include <stdio.h>

#define SQUARE(x) ((x) * (x))
#define CUBE(x) ((x) * (x) * (x))

void main(void)
 {
   printf("The square of 2 is %d\n", SQUARE(2));
   printf("The cube of 100 is %f\n", CUBE(100.0));
 }

#include <stdio.h>

void main(void)
 {
   char string[256];
   int i;

   for (i = 0; i < 26; i++)
     string[i] = 'A' + i;

   string[10] = NULL;

   printf ("The string contains %s\n", string);
 }
#include <stdio.h>

void main(void)
 {
   char string[256];
   int i;

   for (i = 0; i < 26; i++)
     string[i] = 'A' + i;

   string[i] = NULL;

   printf ("The string contains %s\n", string);
 }
#include <stdio.h>

void main(void)
 {
   char string[] = "\"Stop!\", he said.";

   printf(string);
 }
#include <stdio.h>

void main(void)
 {
   char string[256];  // String input by user
   int i;             // Index into the string

   printf("Type a string of characters and press Enter:\n");
   gets(string);

   // Display each string character until NULL is found
   for (i = 0; string[i] != NULL; i++)
     putchar(string[i]);
 
   printf("\nThe number of characters in the string is %d\n", i);
 }
#include <stdio.h>
#include <string.h>

void main(void)
 {
   char book_title[] = "Jamsa\'s C/C++ Programmer\'s Bible";

   printf("%s contains %d characters\n", book_title, strlen(book_title));
 }

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

void main(void)
 {
   char title[] = "Jamsa\'s C/C++ Programmer\'s Bible";
   char book[128];

   strcpy(book, title);
   printf("Book name %s\n", book);
 }

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

void main(void)
  {
    char name[64] = "Triggerhill\'s I'm so";
    strcat(name, " Happy");
    printf("Happy\'s full name is %s\n", name);
  }

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

void main(void)
 {
   char name[64] = "Bill";

   strncat(name, " and Hillary", 4);
   printf("Did you vote for %s?\n", name);
 }
#include <stdio.h>
#include <string.h>

void main(void)
 {
   char buffer[64] = "Jamsa\'s C/C++ Programmer\'s Bible";
   char target[64];

   int length;

   length = strxfrm(target, buffer, sizeof(buffer));

   printf("Length %d Target %s Buffer %s\n", length,
     target, buffer);
 }

#include <stdio.h>

int streql(char *str1, char *str2)
 {
   while ((*str1 == *str2) && (*str1))
     {
       str1++;
       str2++;
     }

   return((*str1 == NULL) && (*str2 == NULL));
 }

void main(void) 
 {
   printf("Testing Abc and Abc %d\n", streql("Abc", "Abc"));  
   printf("Testing abc and Abc %d\n", streql("abc", "Abc"));  
   printf("Testing abcd and abc %d\n", streql("abcd", "abc"));  
 }
#include <stdio.h>
#include <ctype.h>

int strieql(char *str1, char *str2)
 {
   while ((toupper(*str1) == toupper(*str2)) && (*str1))
     {
       str1++;
       str2++;
     }

   return((*str1 == NULL) && (*str2 == NULL));
 }

void main(void) 
 {
   printf("Testing Abc and Abc %d\n", strieql("Abc", "Abc"));  
   printf("Testing abc and Abc %d\n", strieql("abc", "Abc"));  
   printf("Testing abcd and abc %d\n", strieql("abcd", "abc"));  
 }
#include <stdio.h>
#include <string.h>

void main(void)
 { 
   printf(strlwr("Jamsa\'s C/C++ Programmer\'s Bible!\n"));
   printf(strupr("Jamsa\'s C/C++ Programmer\'s Bible!\n"));
 }
#include <stdio.h>
#include <string.h>

void main(void)
 {
   char title[64] = "Jamsa\'s C/C++ Programmer\'s Bible!";
   char *ptr;

   ptr = strchr(title, 'C');
     if (*ptr)
     printf("First occurrence of C is at offset %d\n",
       ptr - title);
   else
     printf("Character not found\n");
 }
#include <stdio.h>
#include <string.h>

void main(void)
 {
   char title[64] = "Jamsa\'s C/C++ Programmer\'s Bible!";
   char *ptr;

   if (ptr = strrchr(title, 'C'))
     printf("Rightmost occurrence of C is at offset %d\n",
       ptr - title);
   else
     printf("Character not found\n");
 }
#include <stdio.h>
#include <string.h>

void main(void)
 {
   printf("Comparing Abc with Abc %d\n", strcmp("Abc", "Abc"));
   printf("Comparing abc with Abc %d\n", strcmp("abc", "Abc"));
   printf("Comparing abcd with abc %d\n", strcmp("abcd", "abc"));
   printf("Comparing Abc with Abcd %d\n", strcmp("Abc", "Abcd"));
   printf("Comparing abcd with abce %d\n", strcmp("abcd", "abce"));
   printf("Comparing Abce with Abcd %d\n", strcmp("Abce", "Abcd"));
 }   


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


void main(void)
 {
   printf("Comparing 3 letters Abc with Abc %d\n", 
     strncmp("Abc", "Abc", 3));
   printf("Comparing 3 letters abc with Abc %d\n", 
     strncmp("abc", "Abc", 3));
   printf("Comparing 3 letters abcd with abc %d\n", 
     strncmp("abcd", "abc", 3));
   printf("Comparing 5 letters Abc with Abcd %d\n", 
     strncmp("Abc", "Abcd", 5));
   printf("Comparing 4 letters abcd with abcd %d\n", 
     strncmp("abcd", "abcd", 4));
 }   


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

void main(void)
 {
   printf("Comparing Abc with Abc %d\n", 
     stricmp("Abc", "Abc"));
   printf("Comparing abc with Abc %d\n", 
     stricmp("abc", "Abc"));
   printf("Comparing 3 letters abcd with ABC %d\n", 
     strncmpi("abcd", "ABC", 3));
   printf("Comparing 5 letters abc with Abcd %d\n", 
     strncmpi("abc", "Abcd", 5));
 }   


#include <stdio.h>
#include <stdlib.h>

void main(void)
 {
   int int_result;
   float float_result;
   long long_result;

   int_result = atoi("1234");
   float_result = atof("12345.678");
   long_result = atol("1234567L");

   printf("%d %f %ld\n", int_result, float_result, long_result);
 }
#include <stdio.h>
#include <string.h>
 
void main(void)
  {
    char *title;

    if ((title = strdup("Jamsa\'s C/C++ Programmer\'s Bible")))
      printf("Title: %s\n", title);
    else 
      printf("Error duplicating string");
   }
      
     
#include <stdio.h>
#include <string.h>

void main(void)
 {
   printf("Searching for Abc in AbcDef %d\n",
     strspn("AbcDef", "Abc"));
   
   printf("Searching for cbA in AbcDef %d\n",
     strspn("AbcDef", "cbA"));
   
   printf("Searching for Def in AbcAbc %d\n",
     strspn("AbcAbc", "Def"));
 }


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

void main(void)
 {
   printf("Looking for Abc in AbcDef %s\n",
    (strstr("AbcDef", "Abc")) ? "Found" : "Not found");
   printf("Looking for Abc in abcDef %s\n",
    (strstr("abcDef", "Abc")) ? "Found" : "Not found");
   printf("Looking for Abc in AbcAbc %s\n",
    (strstr("AbcAbc", "Abc")) ? "Found" : "Not found");
 }

#include <stdio.h>
#include <stdlib.h>

void main (void)
 {
   int int_value;
   float flt_value;
   long long_value;

   int_value = atoi("12345");
   flt_value = atof("33.45");
   long_value =atol("12BAD");

   printf("int %d float %5.2f long %ld\n", int_value,
     flt_value, long_value);
 }

#include <stdio.h>
#include <ctype.h>

void main(void)
 {
   char string[] = "Jamsa\'s C/C++ Programmer\'s Bible";
   int i;

   for (i = 0; string[i]; i++)
     putchar(toupper(string[i]));
   putchar('\n');

   for (i = 0; string[i]; i++)
     putchar(_toupper(string[i]));
   putchar('\n');
 }
#include <stdio.h>
#include <ctype.h>

void main(void)
 {
   char string[] = "Jamsa\'s C/C++ Programmer\'s Bible";
   int i;

   for (i = 0; string[i]; i++)
     putchar(tolower(string[i]));
   putchar('\n');

   for (i = 0; string[i]; i++)
     putchar(_tolower(string[i]));
   putchar('\n');
 }
#include <stdio.h>

void main(void)
 {
   int employee_number = 12345;
   char region[] = "SEA";
   char filename[64];

   sprintf(filename, "%s%d", region, employee_number);

   printf("Employee filename: %s\n", filename);
 }
#include <stdio.h>

void main(void)
 {
   int age;
   float salary;
   char string[] = "33 25000.00";

   sscanf(string, "%d %f\n", &age, &salary);

   printf("Age: %d Salary %f\n", age, salary);
 }

#include <stdio.h>

void hello_world(void)
 { 
   printf("Hello, world!\n");
 }

void main(void)
 {
   hello_world();
 }
#include <stdio.h>

void three_hellos(void)
 {
   int counter; // Variable

   for (counter = 1; counter <= 3; counter++)
     printf("Hello, world!\n");
 }

void main(void)
 {
   three_hellos();
 }

#include <stdio.h>

void hello_world(void)
 {
   printf("Hello, world!\n");
 }

void three_hellos(void)
 {
   int counter;

   for (counter = 1; counter <= 3; counter++)
     hello_world();
 }

void main(void)
 {
   three_hellos();
 }

#include <stdio.h>

void hello_world(void)
 {
   printf("Hello, world!\n");
 }

void hello_count(int message_count)
 {
   int counter;

   for (counter = 1; counter <= message_count; counter++)
     hello_world();
 }

void main(void)
 {
   printf("Display the message twice\n");
   hello_count(2);
   printf("Display the message five times\n");
   hello_count(5);
 }

#include <stdio.h>

int i_cube(int value)
 {
   return(value * value * value);
 }

void main(void)
 {
   printf("The cube of 3 is %d\n", i_cube(3));
   printf("The cube of 5 is %d\n", i_cube(5));
   printf("The cube of 7 is %d\n", i_cube(7));
 }
#include <stdio.h>

int i_cube(int);
float f_cube(float);

void main(void)
 {
   printf("The cube of 3 is %d\n", i_cube(3));
   printf("The cube of 3.7 is %f\n", f_cube(3.7));
 }

int i_cube(int value)
 {
   return(value * value * value);
 }

float f_cube(float value)
 {
   return(value * value * value);
 }
#include <stdio.h>

char *strcpy(char *destination, const char *source) 
 {
   char *start = destination;

   while (*destination++ = *source++)
     ;

   return(start);
 }

void main(void)
 {
   char title[64]; 
   
   strcpy(title, "Jamsa\'s C/C++ Programmer\'s Bible");
   printf(title);
 }

#include <stdio.h>

float average_value(int a, int b, int c)
 {
   return ((a + b + c) / 3.0);
 }
         
void main(void)
 {
   printf("The average of 100, 133, and 155 is %f\n",
     average_value(100, 133, 155));
 }

#include <stdio.h>

void local_values(void)
 {
   int a = 1, b = 2, c =3;

   printf("a contains %d b contains %d c contains %d\n", a, b, c);
 }

void main(void)
 {
  printf("a contains %d b contains %d c contains %d\n", a, b, c);
 }


#include <stdio.h>
#include <time.h>

float add_em(long int a, float b)
 {
    float result;

    result = a + b;

    return(result);
 }

 void main(void)
  {
    long int i;
    float result = 0;
    time_t start_time, stop_time;

    printf("Working...\n");
    time(&start_time);

    for (i = 1; i <= 100000L; i++)
      result += i;

    time(&stop_time);

    printf("Using loop %d seconds\n", stop_time - start_time);

    printf("Working...\n");
    time(&start_time);

    for (i = 1; i <= 100000L; i++)
      result = add_em(i, result);

    time(&stop_time);

    printf("Using function %d seconds\n", stop_time - start_time);
 }
#include <stdio.h>

int a = 1, b = 2, c = 3;  // Global variables

void global_values(void)
 {
   printf("a contains %d b contains %d c contains %d\n", a, b, c);
 }

void main(void)
 {
   global_values();
   printf("a contains %d b contains %d c contains %d\n", a, b, c);
 }
#include <stdio.h>

int a = 1, b = 2, c = 3;  // Global variables

void conflict_a(void)
 {
   int a = 100;

   printf("a contains %d b contains %d c contains %d\n", a, b, c);
 }

void main(void)
 {
   conflict_a();
   printf("a contains %d b contains %d c contains %d\n", a, b, c);
 }
#include <stdio.h>

void unknown_title(void)
 {
   printf("The book's title is %s\n", title);
 }

char title[] = "Jamsa\'s C/C++ Programmer\'s Bible";

void main(void)
 {
   printf("Title: %s\n", title);
 }

#include <stdio.h>

void display_and_change(int first, int second, int third)
 {
   printf("Original function values %d %d %d\n",
     first, second, third);

   first += 100; 
   second += 100;
   third += 100;

   printf("Ending function values %d %d %d\n", 
     first, second, third);
 }

void main(void)
 {
   int a = 1, b = 2, c = 3;

   display_and_change(a, b, c);

   printf("Ending values in main %d %d %d\n", a, b ,c);
 }
   
#include <stdio.h>

void main(void)
 {
  int a = 1, b = 2, c = 3;

   printf("The address of a is %x the value of a is %d\n", &a, a);
   printf("The address of b is %x the value of b is %d\n", &b, b);
   printf("The address of c is %x the value of c is %d\n", &c, c);
 }

#include <stdio.h>

void main(void)
 {
   int a = 1, b = 2;

   int *i_pointer;

   // Assign an address
   i_pointer = &a;

   // Change the value pointed to by i_pointer to 5
   *i_pointer = 5;

   // Display the value
   printf("Value pointed to by i_pointer is %d the variable a is %d\n",
     *i_pointer, a);

   // Assign the value
   b = *i_pointer;

   printf("Value of b is %d\n", b);
   printf("Value of i_pointer %x\n", i_pointer);
 }
#include <stdio.h>

void display_and_change(int *first, int *second, int *third)
 {
   printf("Original function values %d %d %d\n",
     *first, *second, *third);

   *first += 100; 
   *second += 100;
   *third += 100;

   printf("Ending function values %d %d %d\n", 
     *first, *second, *third);
 }

void main(void)
 {
   int a = 1, b = 2, c = 3;

   display_and_change(&a, &b, &c);

   printf("Ending values in main %d %d %d\n", a, b ,c);
 }
   
#include <stdio.h>

void change_first(int *first, int second)
 { 
   *first = second;  // Assign value of second to first
 }

void main(void) 
 {
   int a = 0, b = 5;

   change_first(&a, b);
   printf("Value of a %d value of b %d\n", a, b);
 }

#include <stdio.h>

void print_reportcard(int printer_number)
 {
   static int student_id = 100;

   printf("Printing report card for student %d\n", student_id);
   student_id++;

   // Other statements here
 }

 void main(void)
  {
    print_reportcard(1);
    print_reportcard(1);
    print_reportcard(1);
  }
#include <stdio.h>

int factorial(int value)
 {
   if (value == 1)
     return(1);
   else
     return(value * factorial(value-1));
 }

void main(void)
 {
   int i;

   for (i = 1; i <= 5; i++)
     printf("The factorial of %d is %d\n", i, factorial(i));
 }

#include <stdio.h>

void local_values(void)
 {
   int a = 1, b = 2, c = 3;

   printf("a contains %d b contains %d c contains %d\n", a, b, c);
 }

void main(void)
 {
   printf("a contains %d b contains %d c contains %d\n", a, b, c);
 }
#include <stdio.h>

void display_backward(char *string)
 {
   if (*string)
    { 
      display_backward(string+1);
      putchar(*string);
    }
 }

void main(void)
 {
   display_backward("ABCDE");
 }
#include <stdio.h>

int factorial(int value)
 {
   printf("In factorial with the value %d\n", value);

   if (value == 1)
    {
      printf("Returning the value 1\n");
      return(1);
    }
   else
    { 
      printf("Returning %d * factorial(%d)\n", 
         value, value-1);
      return(value * factorial(value-1));
    }
 }

void main(void)
 {
   printf("The factorial of 4 is %d\n", factorial(4));
 }

#include <stdio.h>
#include <time.h>

int string_length(const char *str)
 {
   int length = 0;
   
   while (*str++)
     length++;

   return(length);
 }

void main(void)
 {
   long int counter;

   time_t start_time, end_time;

   time(&start_time);

   for (counter = 0; counter < 100000L; counter++)
     string_length("Jamsa\'s C/C++ Programmer\'s Bible");

   time(&end_time);

   printf("Processing time %d\n", end_time - start_time);
 }

#include <stdio.h>
#include <time.h>

int string_length(const char *str)
 {
   if (*str)
     return(1 + string_length(str+1));
   else
     return(0);
 }

void main(void)
 {
   long int counter;

   time_t start_time, end_time;

   time(&start_time);

   for (counter = 0; counter < 100000L; counter++)
     string_length("Jamsa\'s C/C++ Programmer\'s Bible");
     
   time(&end_time);

   printf("Processing time %d\n", end_time - start_time);
 }

#include <stdio.h>

int factorial(int value)
 {
   int result = 1;
   int counter;

   for (counter = 2; counter <= value; counter++) 
     result *= counter;

   return(result);
 }

void main(void)
 {
   int i;

   for (i = 1; i <= 5; i++)
     printf("Factorial of %d is %d\n", i, factorial(i));
 }
#include <stdio.h>
#include <string.h>

void main(void)
 {
   char alphabet[] = "abcdefghijklmnopqrstuvwxyz";

   strupr(&alphabet[13]);

   printf(alphabet);
 }

#include <stdio.h>

void no_change(const char *string)
 { 
   while (*string)
     *string++ = toupper(*string);
 }


 void main(void) 
  {
    char title[] = "Jamsa\'s C/C++ Programmer\'s Bible";

    no_change(title);

    printf(title);
  }

#include <stdio.h>
#include <ctype.h>

void no_change(const char *string)
 { 
   char *alias = string;

   while (*alias)
     *alias++ = toupper(*alias);
 }


 void main(void) 
  {
    char title[] = "Jamsa's C/C++ Programmer's Bible";

    no_change(title);

    printf(title);
  }

#include <stdio.h>

int strlen(char str[])
 {
   int i = 0;

   while (str[i] != NULL)
     i++;

   return(i);
 }

void main(void)
 {
   printf("Length of ABC is %d\n", strlen("ABC"));
   printf("Length of Jamsa\'s C/C++ Programmer\'s Bible is %d\n",
     strlen("Jamsa\'s C/C++ Programmer\'s Bible"));
   printf("Length of a NULL string is %d\n", strlen(""));
 }

#include <stdio.h>

int tip_count = 1500;  // Global variable

void show_title(void)
 {
   printf("Jamsa\'s C/C++ Programmer\'s Bible");
 }

#include <stdio.h>

void main(void)
 {
   extern int tip_count;

   printf("The number of tips is %d\n", tip_count);
 }

#include <stdio.h>

void main(void)
 {
   extern int tip_count;
   extern char *title;

   void show_title(void);
   
   printf("The number of tips is %d\n", tip_count);
   printf("The book\'s title is %s\n", title);
   show_title();
 }
#include <stdio.h>

int tip_count = 1500;  // Global variable

static char title[] = "Jamsa\'s C/C++ Programmer\'s Bible";

void show_title(void)
 {
   printf(title);
 }

#include <stdio.h>

void swap_values(int *, int *);

void main(void)
 {
   int a = 1, b = 2;

   printf("Original values a %d b %d\n", a, b);
   swap_values(&a, &b);

   printf("Swapped values a %d b %d\n", a, b);
 }

#include <stdio.h>

int get_maximum(int, int);

void main(void)
 {
   int result;

   result = get_maximum(100, 200);

   printf("The larger value is %d\n", result);
 }
#include <stdio.h>

void beeper(int beep_count)
 {
   int count;

   for (count = 1; count <= beep_count; count++)
     putchar(7);
 }

void main(void)
 {
   int count;

   for (count = 1; count <= 3; count++)
     {
       printf("About to beep %d times\n", count);
       beeper(count);
     }
 }

#include <stdio.h>

void main(void)
 { 
   int value = 1500;

   if (value > 1499)
     {
       int value = 1;

       printf("Inner value is %d\n", value);
     }

   printf("Outer value is %d\n", value); 
 }
#include <stdio.h>
#include <stdarg.h>

int add_values(int value, ...)
 {
    va_list argument_ptr;
    int result = 0;

    if (value != 0)
      {
        result += value;
        va_start(argument_ptr, value);

        while ((value = va_arg(argument_ptr, int)) != 0)
          result += value;

        va_end(argument_ptr);
      }  
    return(result);
 }

void main(void)
 {
   printf("Sum of 3 is %d\n", add_values(3, 0));
   printf("Sum of 3 + 5 is %d\n", add_values(3, 5, 0));
   printf("Sum of 3 + 5 + 8 is %d\n", add_values(3, 5, 8, 0));
   printf("Sum of 3 + 5 + 8 + 9 is %d\n", add_values(3, 5, 8 , 9, 0));
 }
#include <stdio.h>
#include <stdarg.h>

double add_values(char *str, ...)
{
    va_list marker;
    
    double result = 0.0;

    va_start(marker, str);  // mark first additional argument

    while (*str)            // examine each character in the string
      {
 if (*str == '%')       // if not a %_ format specifier, skip it
   {
     switch (*(++str)) {
  case 'd': result += va_arg(marker, int);
     break;
  case 'f': result += va_arg(marker, double);
     break;
       }
   }
 str++;
      }

   va_end(marker);
   return(result);
 }
 

void main(void)
 { 
   double result;

   printf("Result %f\n", add_values("%f", 3.3));
   printf("Result %f\n", add_values("%f %f", 1.1, 2.2));
   printf("Result %f\n", add_values("%f %d %f", 1.1, 1, 2.2));
   printf("Result %f\n", add_values("%f %d %f %d", 1.1, 1, 2.2, 3));
 }
#include <stdio.h>
#include <ctype.h>

void main(void)
 {
   int letter;

   printf("Type Y or N to continue and press Enter\n");

   do
   {
     letter = toupper(getchar());
   }
   while ((letter != 'Y') && (letter != 'N'));
   printf("You typed %c\n", ((letter == 'Y') ? 'Y': 'N'));
 }

#include <stdio.h>

void main(void)
 {
   int letter;

   for (letter = 'A'; letter <= 'Z'; letter++)
     putchar(letter);
 }

#include <stdio.h>

void main(void)
 {
   int letter;

   do {
     letter = getchar();
     putchar(letter);
   } while (letter != '\n');
 }

#include <stdio.h>

void main(void)
 {
   char string[128];

   int index = 0;
   int letter;

   printf("Type in a string and press Enter\n");
   while ((letter = getchar()) != '\n')
     string[index++] = letter;

   string[index] = NULL;

   printf("The string was: %s\n", string);
 }

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

void main(void)
 {
   int letter;

   printf("Do you want to continue? (Y/N): ");
   do 
     {
       letter = getche();
       letter = toupper(letter);
     }
   while ((letter != 'Y') && (letter != 'N'));

   if (letter == 'Y')
     printf("\nYour response was Yes\n");
   else 
     printf("\nWhy not?\n");
 }
#include <stdio.h>
#include <conio.h>
#include <ctype.h>

void main(void)
 {
   int letter;

   printf("Type in a string of characters and press Enter\n");

   do { 
     letter = getch();
     letter = toupper(letter);
     putch(letter);
   } while (letter != '\r');
 }

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


void main(void)
 {
   int letter;
   int count;

   time_t start_time, stop_time;
   
   time(&start_time);
   for (count = 0; count < 1000; count++)
    for (letter = 'A'; letter <= 'Z'; letter++)
     putchar(letter);
   time(&stop_time);

   printf("\n\nTime required for putchar %d seconds\n", 
     stop_time-start_time);
   printf("Press any key...\n");
   getch();

   time(&start_time);
   for (count = 0; count < 1000; count++)
    for (letter = 'A'; letter <= 'Z'; letter++)
     putch(letter);
   time(&stop_time);

   printf("\n\nTime required for putch %d seconds\n", 
     stop_time-start_time);
 }

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

void main(void)
 {
   int letter;
   int done = 0;
   int uppercase_found = 0;

   do {
     letter = getch();

     if (islower(letter))
       putchar(letter);
     else
       {
         if (isupper(letter))
           {
             ungetch(letter);
             uppercase_found = 1;
             putchar('\n');
           }
         done = 1;
       }
   } while (! done);  

   if (uppercase_found)
     do {
       letter = getch();
       putchar(letter);
     } while (letter != '\r');
 }

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

void main(void)
 {
   int count;

   time_t start_time, stop_time;
   
   time(&start_time);
   for (count = 0; count < 1001; count++)
     printf("Jamsa\'s C/C++ Programmer\'s Bible\n");
   time(&stop_time);

   printf("\n\nTime required for printf %d seconds\n",
     stop_time-start_time);
   printf("Press any key...\n");
   getch();

   time(&start_time);
   for (count = 0; count < 1001; count++)
     cprintf("Jamsa\'s C/C++ Programmer\'s Bible\r\n");

   time(&stop_time);

   printf("\n\nTime required for cprintf %d seconds\n",
     stop_time-start_time);
 }

#include <conio.h>

void main(void)
 {
   int a, b, c;

   cprintf("Type 3 integer values and press Enter\r\n");
   cscanf("%d %d %d", &a, &b, &c);
   cprintf("The values entered were %d %d %d\r\n", a, b, c);
 }
#include <stdio.h>
#include <conio.h>
#include <time.h>

void main(void)
 {
   int count;

   time_t start_time, stop_time;
   
   time(&start_time);
   for (count = 0; count < 1001; count++)
     printf("Jamsa\'s C/C++ Programmer\'s Bible\n");
   time(&stop_time);

   printf("\n\nTime required for printf %d seconds\n",
     stop_time-start_time);
   printf("Press any key...\n");
   getch();

   time(&start_time);
   for (count = 0; count < 1001; count++)
     puts("Jamsa\'s C/C++ Programmer\'s Bible");

   time(&stop_time);

   printf("\n\nTime required for puts %d seconds\n",
     stop_time-start_time);
 }

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

void main(void)
 {
   int count;

   time_t start_time, stop_time;
   
   time(&start_time);
   for (count = 0; count < 1500; count++)
     puts("Jamsa\'s C/C++ Programmer\'s Bible");
   time(&stop_time);

   printf("\n\nTime required for puts %d seconds\n",
     stop_time-start_time);
   printf("Press any key...\n");
   getch();

   time(&start_time);
   for (count = 0; count < 1500; count++)
     cputs("Jamsa\'s C/C++ Programmer\'s Bible\r\n");
   
   time(&stop_time);

   printf("\n\nTime required for cputs %d seconds\n", 
     stop_time-start_time);
 }

#include <stdio.h>

void main(void)
 {
   char string[256];

   printf("Type in a string of characters and press Enter\n");
   gets(string);

   printf("The string was %s\n", string);
 }

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

void main(void)
 { 
   char buffer[256];

   buffer[0] = 253;  // Number of characters that can be read

   printf("Type in a string and press Enter\n");
   cgets(buffer);

   printf("\n\nThe number of characters read was %d\n", 
     buffer[1]);

   printf("The string read: %s\n", &buffer[2]);
 }
#include <conio.h>

void main(void)
 {
   clrscr();
 }

#include <conio.h>

void main(void)
 {
   int line;
  
   clrscr();

   for (line = 1; line < 25; line++)
    cprintf("This is line %d\r\n", line);

   cprintf("Press a key to Continue: ");
   getch();

   gotoxy(1, 12);

   for (line = 12; line < 15; line++)
     delline();

   gotoxy(1, 25);
 }


#include <conio.h>

void main(void)
 {
   clrscr();

   gotoxy(1, 5);
   cprintf("Output at row 5 column 1\n");

   gotoxy(20, 10);
   cprintf("Output at row 10 column 20\n");
 }


#include <conio.h>

void main(void)
 {
   int row, column;

   clrscr();

   cprintf("This is line 1\r\n");
   cprintf("Line 2 is a little longer\r\n");
   cprintf("This is the last line");

   row = wherey();
   column = wherex();

   cprintf("\r\nThe cursor position was row %d column %d\n",
     row, column);
 }

#include <conio.h>

void main(void)
 {
   int line;
  
   clrscr();

   for (line = 1; line < 25; line++)
    cprintf("This is line %d\r\n", line);

   cprintf("Press a key to Continue: ");
   getch();

   gotoxy(1, 12);

   insline();
   cprintf("This is new text!!!");
   gotoxy(1, 25);
 }


#include <conio.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>

void main(void)
 {
   char buffer[8000];
   int handle;

   if ((handle = creat("SAVESCR.DAT", S_IWRITE)) == -1) 
    cprintf("Error opening SAVESCRN.DAT\r\n");
   else
     {
       gettext(1, 1, 80, 25, buffer);
       write(handle, buffer, sizeof(buffer));
       close(handle);
     }
 }

#include <conio.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <stdlib.h>
#include <dos.h>

void main(void)
 {
   char buffer[128];
   int row, column;    
   
   clrscr();
   cprintf("Jamsa\'s C/C++ Programmer\'s Bible\r\n");
   gettext(1, 1, 23, 1, buffer);

   while (! kbhit())
    {
      clrscr();
      row = 1 + random(24);
      column = 1 + random(58);
      puttext(column, row, column+22, row, buffer);
      delay(2000);
    }
 }

#include <conio.h>

void main(void)
 {
   struct text_info text;

   gettextinfo(&text);

   cprintf("Screen coordinates %d,%d to %d,%d\r\n",
     text.wintop, text.winleft, text.winbottom, text.winright);

   cprintf("Text attribute %d Normal attribute %d\r\n",
     text.attribute, text.normattr);

   cprintf("Screen height %d width %d\r\n", text.screenheight,
     text.screenwidth);

   cprintf("Cursor position was row %d column %d\r\n",
     text.cury, text.curx);
 }

#include <conio.h>

void main(void)
 {
  int color;

  for (color = 1; color < 16; color++)
   {
     textattr(color);
     cprintf("This is color %d\r\n", color);
   }

  textattr(128 + 15);
  cprintf("This is blinking\r\n");
 }

#include <conio.h>

void main(void)
 {
   union TextColor {
     struct {
      unsigned char foreground:4;
      unsigned char background:3;
      unsigned char blinking:1;
     } color_bits;
     unsigned char value;
   } colors;
   colors.color_bits.foreground = BLUE;
   colors.color_bits.background = RED;
   colors.color_bits.blinking = 1;

   textattr(colors.value);

   clrscr();
   cprintf("This is the new text colors\n");
 }

#include <conio.h>

void main(void)
 {
  int color;

  for (color = 1; color < 16; color++)
   {
     textcolor(color);
     cprintf("This is color %d\r\n", color);
   }

  textcolor(128 + 15);
  cprintf("This is blinking\r\n");
 }

#include <conio.h>

void main(void)
 {
   int color;

   for (color = 0; color < 8; color++)
    { 
     textbackground(color);
     cprintf("This is color %d\r\n", color);
     cprintf("Press any key to continue\r\n");
     getch();
    }
 }

#include <conio.h>

void main(void)
 {
   clrscr();

   highvideo();
   cprintf("This text is high video\r\n");

   lowvideo();
   cprintf("This text is low video\r\n");

   normvideo();
   cprintf("This text is normal video\r\n");
 }

#include <conio.h>

void main(void)
 {
   int i;

   clrscr();
   for (i = 1; i <= 5; i++)
     cprintf("This is line %d\r\n", i);

   cprintf("Press any key\n\r");
   getch();   

   movetext(1, 1, 30, 6, 45, 18);
   gotoxy(1, 24);
 }

#include <conio.h>

void main(void)
 {
   int i, j;

   window(1, 1, 40, 12);

   for (i = 0; i < 15; i++)
    {
      for (j = 0; j < 50; j++)
       cprintf("%d", j);
      cprintf("\r\n");
    }
 }


#include <stdio.h>
#include <stdlib.h>

void main(void)
 {
   printf("The absolute value of %d is %d\n", 5, abs(5));
   printf("The absolute value of %d is %d\n", 0, abs(0));
   printf("The absolute value of %d is %d\n", -5, abs(-5));
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   double radians;

   for (radians = -0.5; radians <= 0.5; radians += 0.2)
     printf("%f %f\n", radians, acos(radians));
 }

#include <stdio.h>
#include <math.h>

void main(void)
 {
   double radians;

   for (radians = -0.5; radians <= 0.5; radians += 0.2)
     printf("%f %f\n", radians, asin(radians));
 }

#include <stdio.h>
#include <math.h>

void main(void)
 {
   double radians;

   for (radians = -0.5; radians <= 0.5; radians += 0.2)
     printf("%f %f\n", radians, atan(radians));
 }

#include <stdio.h>
#include <math.h>

void main(void)
 {
   struct complex complex_number;

   complex_number.x = 10;
   complex_number.y = 5;

   printf("Absolute value of 10,5 is %f\n", 
     cabs(complex_number));
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   printf("The value %f ceil %f\n", 1.9, ceil(1.9)); 
   printf("The value %f ceil %f\n", 2.1, ceil(2.1));
 }

#include <stdio.h>
#include <math.h>

void main(void)
 {
   printf("cosine of pi/2 is %6.4f\n", cos(3.14159/2.0));
   printf("cosine of pi is %6.4f\n", cos(3.14159));
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   double radians;

   for (radians = -0.5; radians <= 0.5; radians += 0.2)
     printf("%f %f\n", radians, cosh(radians));
 }

#include <stdio.h>
#include <math.h>

void main(void)
 {
   double radians;

   for (radians = 0.0; radians < 3.1; radians += 0.1)
     printf("Sine of %f is %f\n", radians, sin(radians));
 }
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void main(void)
 {
   double radians;
   double result;

   for (radians = 0.0; radians < 3.1; radians += 0.1)
     if (((result = sinh(radians)) == HUGE_VAL) && 
       (errno == ERANGE))
       printf("Overflow error\n");
     else
       printf("Sine of %f is %f\n", radians, result);
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   double pi = 3.14159265;

   printf("Tangent of pi is %f\n", tan(pi));
   printf("Tangent of pi/4 is %f\n", tan(pi / 4.0));
 }
#include <stdio.h>
#include <stdlib.h>

void main(void)
 {
   div_t result;

   result = div(11, 3);

   printf("11 divided by 3 is %d Remainder %d\n",
     result.quot, result.rem);
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   double value;

   for (value = 0.0; value <= 1.0; value += 0.1)
     printf("exp(%f) is %f\n", value, exp(value));
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   float value;

   for (value = -1.0; value <= 1.0; value += 0.1)
     printf("Value %f fabs %f\n", value, fabs(value));
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   double numerator = 10.0;
   double denominator = 3.0;

   printf("fmod(10, 3) is %f\n", fmod(numerator,
    denominator));
 }

#include <stdio.h>
#include <math.h>

void main(void)
 {
   double value = 1.2345;

   double mantissa; 
   int exponent;

   mantissa = frexp(value, &exponent);

   printf("Mantissa %f Exponent %d Value %f\n", 
     mantissa, exponent, mantissa * pow(2.0, 1.0 * exponent));
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   printf("3 * 2 raised to the 4 is %f\n", 
    ldexp(3.0, 4));
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   printf("Natural log of 256.0 is %f\n", log(256.0));
 }

#include <stdio.h>
#include <math.h>

void main(void)
 {
   printf("Log10 of 100 is %f\n", log10(100.0));
   printf("Log10 of 10000 is %f\n", log10(10000.0));
 }
#include <stdio.h>
#include <stdlib.h>

void main(void)
 {
   printf("Maximum of %f and %f is %f\n", 
     10.0, 25.0, max(10.0, 25.0));
   printf("Minimum of %f and %f is %f\n", 
     10.0, 25.0, min(10.0, 25.0));
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   double value = 1.2345;
   double int_part;
   double fraction;

   fraction = modf(value, &int_part);

   printf("Value %f Integer part %f Fraction %f\n",
     value, int_part, fraction);
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   int power;

   for (power = -2; power <= 2; power++)
     printf("10 raised to %d is %f\n", power,
       pow(10.0, power));
 }
#include <stdio.h>
#include <math.h>

void main(void)
 {
   printf("10 raised to -1 is %f\n", pow10(-1));
   printf("10 raised to 0 is %f\n", pow10(0));
   printf("10 raised to 1 is %f\n", pow10(1));
   printf("10 raised to 2 is %f\n", pow10(2));
}
#include <stdio.h>
#include <stdlib.h>

void main(void)
 {
   int i;

   printf("Values from rand\n");
   for (i = 0; i < 100; i++)
     printf("%d ", rand());

   printf("Values from random(100))\n");
   for (i = 0; i < 100; i++)
     printf("%d ", random(100));
 }

#include <stdio.h>
#include <stdlib.h>

void main(void)
 {
   int i;

   printf("Values from random\n");
   for (i = 0; i < 10; i++)
     printf("%f\n", random(100/100);

   printf("Values from random(-5) to random(5)/n");
   for (i = 0; i < 100; i++)
     printf("%d\n", random(10)-5);
 }

#include <stdio.h>
#include <time.h>
#include <stdlib.h>

void main(void)
 {
   int i;

   srand(100);
   printf("Values from rand\n");
   for (i = 0; i < 5; i++)
     printf("%d ", rand());

   printf("\nSame 5 numbers\n");
   srand(100);
   for (i = 0; i < 5; i++)
     printf("%d ", rand());

   randomize();
   printf("\nDifferent 5 numbers\n");
   for (i = 0; i < 5; i++)
     printf("%d ", rand());
 }

#include <stdio.h>
#include <math.h>

void main(void)
 { 
   double value;

   for (value = 0.0; value < 10.0; value += 0.1)
     printf("Value %f sqrt %f\n", value, sqrt(value));
 }

#include <stdio.h>
#include <math.h>

void main(void)
 {
   printf("Sqrt of -1 is %f\n", sqrt(-1.0));
 }

int matherr(struct exception *error)
 {
   switch (error->type) {
     case DOMAIN: printf("Domain error\n");
                  break;
     case PLOSS:  printf("Partial precision loss error\n");
                  break; 
     case OVERFLOW: printf("Overflow error\n");
                    break;
     case SING:   printf("Error in singularity\n");
                  break;
     case TLOSS:  printf("Total precision loss error\n");
                  break;
     case UNDERFLOW: printf("Underflow error\n");
                     break;
   };
   printf("Error occurred in %s values %f\n",
     error->name, error->arg1);
   error->retval = 1;
   return(1);
  }


    
#include <stdio.h>
#include <dir.h>

void main(void)
 {
   printf("The current drive is %c\n", getdisk() + 'A');
 }
#include <stdio.h>
#include <dir.h>

void main(void)
 {
   int drive_count;

   drive_count = setdisk(3);
   printf("The number of available drives is %d\n", drive_count);
 }
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

void main(void)
 {
    char szBuffer[MAX_PATH+100];
    UINT nDrive, AvailDrive = 0;
    int dwLogicalDrives = GetLogicalDrives();
    DWORD Success;

    printf("Number of logical drives: %d\n", dwLogicalDrives);
     for (nDrive = 0; nDrive < 32; nDrive++)
       {
        if (dwLogicalDrives & (1 << nDrive))
          { // Is drive available?
            AvailDrive++;
            // Get disk information.
            wsprintf(szBuffer, "%c:\\", nDrive+'A', '\0');
            // Print out information.
           if(SetCurrentDirectory(szBuffer))
              printf("%s Is Now Current\n", szBuffer);
          else
              printf("Could not set %s as the current drive\n", szBuffer);
          }
       }
      printf("Number of drives available: %d\n", AvailDrive);

 }
#include <stdio.h>
#include <dos.h>

void main(void)
 {
   struct dfree diskinfo;
   long disk_space;

   getdfree(3, &diskinfo);
   disk_space = (long) diskinfo.df_avail * (long) diskinfo.df_bsec * (long) diskinfo.df_sclus;

   printf("Available disk space %ld\n", disk_space);
 }
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

void main(void)
 {
    char szBuffer[MAX_PATH+100];
    UINT nRow = 0;
    UINT nDrive = 0;
    DWORD dwLogicalDrives = GetLogicalDrives();

     for ( nDrive = 0; nDrive<32; nDrive++ )
       {
        if ( dwLogicalDrives & (1 << nDrive) )
          { // Is drive available?
           UINT  uType;                 // type of drive.
            DWORD dwBytesPerSector = 0;  // bytes per sector
            DWORD dwSectorsPerCluster=0; // sectors per cluster
            DWORD dwTotalClusters = 0;   // total clusters
            DWORD dwFreeClusters = 0;    // free clusters
            DWORD dwVolumeSerialNumber=0;// volume ser number
            DWORD dwMaxNameLength=0;     // max component length
            DWORD dwFileSystemFlags=0;   // file system flags
            DWORD dwFreeSpace = 0;       // free space
            DWORD dwTotalSpace = 0;      // total space
            char szFileSysName[129];     // name of file system
            char szLabel[129];           // name of volume

            // Get disk information.
            wsprintf( szBuffer, "%c:\\", nDrive+'A' );
            uType = GetDriveType(szBuffer);
            GetDiskFreeSpace(szBuffer, &dwBytesPerSector,
                  &dwSectorsPerCluster, &dwFreeClusters, &dwTotalClusters);
            GetVolumeInformation(szBuffer, szLabel, sizeof( szLabel ) - 1,
                                 &dwVolumeSerialNumber, &dwMaxNameLength,
                                 &dwFileSystemFlags, szFileSysName,
                                 sizeof( szFileSysName ) - 1 );
            dwFreeSpace = dwBytesPerSector * dwSectorsPerCluster * dwFreeClusters;
            dwTotalSpace = dwBytesPerSector * dwSectorsPerCluster * dwTotalClusters;

            // Print out information.
            wsprintf(&szBuffer[3], " Label: %s, System: %s, Long Names: %s ",
                     szLabel, szFileSysName, (dwMaxNameLength == 255) ? "TRUE" : "FALSE" );
            printf("%s\n", szBuffer);
            wsprintf(szBuffer, " Type: %s, Disk Space: %ld, Free: %ld",
                  (uType == DRIVE_REMOVABLE) ? "FLOPPY" :
                              ((uType == DRIVE_FIXED) ?  "HARD DISK" :
                              ((uType == DRIVE_REMOTE) ? "NETWORK" :
                              ((uType == DRIVE_CDROM) ?  "CDROM" :
                              ((uType == DRIVE_RAMDISK) ? "RAMDISK" :
                              ((uType == 1) ? "DOES NOT EXIST" :
                              "UNKNOWN DRIVE TYPE" ))))), dwTotalSpace, dwFreeSpace );
            printf("%s\n", szBuffer);
          }
         }
}
#include <stdio.h>
#include <dos.h>

void main(void)
 {
   struct fatinfo fat;

   getfatd(&fat);

   printf("Sectors per cluster %d\n", fat.fi_sclus);
   printf("Clusters per disk %u\n", fat.fi_nclus);
   printf("Bytes per cluster %d\n", fat.fi_bysec);
   printf("Disk type %x\n", fat.fi_fatid & 0xFF);
 }

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

void main(void)
 {
    char szBuffer[MAX_PATH+100];
    DWORD dwLogicalDrives = GetLogicalDrives();

     for ( nDrive = 0; nDrive<32; nDrive++ )
       {
        if ( dwLogicalDrives & (1 << nDrive) )
          { // Is drive available?
           UINT  uType;                 // type of drive.

            // Get disk information.
            wsprintf( szBuffer, "%c:\\", nDrive+'A' );
            uType = GetDriveType(szBuffer);

            // Print out information.
            wsprintf(&szBuffer[3], " Id: %u, Type: %s ", uType,
                    (uType == DRIVE_REMOVABLE) ? "FLOPPY" :
                              ((uType == DRIVE_FIXED) ?  "HARD DISK" :
                              ((uType == DRIVE_REMOTE) ? "NETWORK" :
                              ((uType == DRIVE_CDROM) ?  "CDROM" :
                              ((uType == DRIVE_RAMDISK) ? "RAMDISK" :
                              ((uType == 1) ? "DOES NOT EXIST" :
                              "UNKNOWN DRIVE TYPE" ))))));
            printf("%s\n", szBuffer);
          }
         }
}
#include <stdio.h>
#include <dos.h>
#include <alloc.h>

void main(void)
 {
   struct fatinfo fat;
   long sector, total_sectors;
   void *buffer;

   getfat(3, &fat);
   total_sectors = fat.fi_nclus * fat.fi_sclus;

   if ((buffer = malloc(fat.fi_bysec)) == NULL)
     printf("Error allocating sector buffer\n");
   else
     for (sector = 0; sector < total_sectors; sector++)
       if (absread(2, 1, sector, buffer) == -1) 
        { 
          printf("\n\007Error reading sector %ld press Enter\n", 
            sector);
          getchar();
        }
       else
         printf("Reading sector %ld\r", sector);
 }

#include <stdio.h>
#include <bios.h>

void main(void)
 {
   char buffer[8192];

   // Try reading head 1, track 1, sector 1
   if (biosdisk(2, 0, 1, 1, 1, 1, buffer))
     printf("Error accessing drive\n");
   else
     printf("Drive ready\n");
 }
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

void main(void)
 {
    char szBuffer[MAX_PATH+100];
    UINT nDrive = 0;
    DWORD dwLogicalDrives = GetLogicalDrives();

  if ( dwLogicalDrives & (1 << nDrive) )
     { // Is drive available?
        UINT  uType;                 // type of drive.

        // Get disk information.
        wsprintf( szBuffer, "%c:\\", nDrive+'A' );
        uType = GetDriveType(szBuffer);

        // Print out information.
        wsprintf(&szBuffer[3], " Type: %s, ",
                  (uType == DRIVE_REMOVABLE) ? "FLOPPY" :
                              ((uType == DRIVE_FIXED) ?  "HARD DISK" :
                              ((uType == DRIVE_REMOTE) ? "NETWORK" :
                              ((uType == DRIVE_CDROM) ?  "CDROM" :
                              ((uType == DRIVE_RAMDISK) ? "RAMDISK" :
                              ((uType == 1) ? "DOES NOT EXIST" :
                              "UNKNOWN DRIVE TYPE" ))))));
        printf("%s\n", szBuffer);
      }
     else
      {
       wsprintf(szBuffer, "%c:\\", nDrive+'A');
       printf("%s not available", szBuffer);
      }
}
#include <stdio.h>

void main(void)
 {
   FILE *input, *output;
   int letter;

   if ((input = fopen("\\CONFIG.SYS", "r")) == NULL)
     printf("Error opening \\CONFIG.SYS\n");
   else if ((output = fopen("\\CONFIG.TST", "w")) == NULL)
     printf("Error opening \\CONFIG.TST\n");
   else
     { 
       // Read and write each character in the file
       while ((letter = fgetc(input)) != EOF)
         fputc(letter, output);
       fclose(input);     // Close the input file
       fclose(output);    // Close the output file
     }
 }
#include <stdio.h>

void main(void)
 {
   FILE *input;
   int letter;

   if ((input = fopen("\\CONFIG.SYS", "r")) == NULL)
     printf("Error opening \\CONFIG.SYS\n");
   else
     { 
       printf("Current position is byte %d\n\n", ftell(input));
         // Read and write each character in the file
       while ((letter = fgetc(input)) != EOF)
         fputc(letter, stdout);
       printf("\nCurrent position is byte %d\n", ftell(input));
       fclose(input);     // Close the input file
     }
 }
#include <stdio.h>
#include <fcntl.h> //contains the _fmode declaration

void main(void)
{
 if (_fmode == O_TEXT)
  printf("Text mode translations\n");
 else 
  printf("Binary mode translations\n");
}
#include <windows.h>  
#include "Task_Man.h" 


#if defined (WIN32)
 #define IS_WIN32 TRUE
#else
 #define IS_WIN32 FALSE
#endif

#define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
#define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
#define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32

HINSTANCE hInst;   // current instance

LPCTSTR lpszAppName  = "MyApp";
LPCTSTR lpszTitle    = "EnumWindows()"; 

BOOL RegisterWin95( CONST WNDCLASS* lpwc );

int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                      LPTSTR lpCmdLine, int nCmdShow)
{
   MSG      msg;
   HWND     hWnd; 
   WNDCLASS wc;

   // Register the main application window class.
   //............................................
   wc.style         = CS_HREDRAW | CS_VREDRAW;
   wc.lpfnWndProc   = (WNDPROC)WndProc;       
   wc.cbClsExtra    = 0;                      
   wc.cbWndExtra    = 0;                      
   wc.hInstance     = hInstance;              
   wc.hIcon         = LoadIcon( hInstance, lpszAppName ); 
   wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
   wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
   wc.lpszMenuName  = lpszAppName;              
   wc.lpszClassName = lpszAppName;              

   if ( IS_WIN95 )
   {
      if ( !RegisterWin95( &wc ) )
         return( FALSE );
   }
   else if ( !RegisterClass( &wc ) )
      return( FALSE );

   hInst = hInstance; 

   // Create the main application window.
   //....................................
   hWnd = CreateWindow( lpszAppName, 
                        lpszTitle,    
                        WS_OVERLAPPEDWINDOW, 
                        CW_USEDEFAULT, 0, 
                        CW_USEDEFAULT, 0,  
                        NULL,              
                        NULL,              
                        hInstance,         
                        NULL               
                      );

   if ( !hWnd ) 
      return( FALSE );

   ShowWindow( hWnd, nCmdShow ); 
   UpdateWindow( hWnd );         

   while( GetMessage( &msg, NULL, 0, 0) )   
   {
      TranslateMessage( &msg ); 
      DispatchMessage( &msg );  
   }

   return( msg.wParam ); 
}


BOOL RegisterWin95( CONST WNDCLASS* lpwc )
{
   WNDCLASSEX wcex;

   wcex.style         = lpwc->style;
   wcex.lpfnWndProc   = lpwc->lpfnWndProc;
   wcex.cbClsExtra    = lpwc->cbClsExtra;
   wcex.cbWndExtra    = lpwc->cbWndExtra;
   wcex.hInstance     = lpwc->hInstance;
   wcex.hIcon         = lpwc->hIcon;
   wcex.hCursor       = lpwc->hCursor;
   wcex.hbrBackground = lpwc->hbrBackground;
   wcex.lpszMenuName  = lpwc->lpszMenuName;
   wcex.lpszClassName = lpwc->lpszClassName;

   // Added elements for Windows 95.
   //...............................
   wcex.cbSize = sizeof(WNDCLASSEX);
   wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName, 
                            IMAGE_ICON, 16, 16,
                            LR_DEFAULTCOLOR );
   
   return RegisterClassEx( &wcex );
}


BOOL CALLBACK EnumWndProc( HWND hWnd, LPARAM lParam )
{
static char szWindowName[71];
static char szClassName[31];
static char szAddString[101];

    // Get the window name and class name
    //...................................
    GetWindowText( hWnd, szWindowName, 70 );
    GetClassName( hWnd, szClassName, 30 );

    // Build a string and add it to the list box.
    //...........................................
    wsprintf( szAddString, "%s - %s", szClassName, szWindowName );

    SendMessage( (HWND)lParam, LB_INSERTSTRING, (WPARAM)-1,
                 (LPARAM)(LPTSTR)szAddString );

    return( TRUE );
}


LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static HWND hListBox;

   switch( uMsg )
   {
      case WM_CREATE : 
               hListBox = CreateWindow( "LISTBOX", "",
                                       WS_CHILD | WS_BORDER |
                                       WS_VISIBLE | LBS_STANDARD,
                                       10, 10, 250, 100,
                                       hWnd, (HMENU) 101,  
                                       hInst, NULL );
               break;

      case WM_COMMAND :
              switch( LOWORD( wParam ) )
              {
                 case IDM_TEST :
                        // Enumerate all top-level windows currently running 
                        // and add their class names and window names to the
                        // hListBox.
                        //...................................................
                        EnumWindows((WNDENUMPROC)EnumWndProc,
                                    (LPARAM)(HANDLE)hListBox );
                        break;

                 case IDM_ABOUT :
                        DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
                        break;

                 case IDM_EXIT :
                        DestroyWindow( hWnd );
                        break;
              }
              break;
      
      case WM_DESTROY :
              PostQuitMessage(0);
              break;

      default :
            return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
   }

   return( 0L );
}


LRESULT CALLBACK About( HWND hDlg,           
                        UINT message,        
                        WPARAM wParam,       
                        LPARAM lParam)
{
   switch (message) 
   {
       case WM_INITDIALOG: 
               return (TRUE);

       case WM_COMMAND:                              
               if (   LOWORD(wParam) == IDOK         
                   || LOWORD(wParam) == IDCANCEL)    
               {
                       EndDialog(hDlg, TRUE);        
                       return (TRUE);
               }
               break;
   }

   return (FALSE); 
}
#define IDM_EXIT           100
#define IDM_TEST           200
#define IDM_ABOUT          301

LRESULT CALLBACK WndProc  (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About    (HWND, UINT, WPARAM, LPARAM);
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
# ** DO NOT EDIT **

# TARGTYPE "Win32 (x86) Application" 0x0101
# TARGTYPE "Win32 (MIPS) Application" 0x0501

!IF "$(CFG)" == ""
CFG=Win32 (80x86) Debug
!MESSAGE No configuration specified.  Defaulting to Win32 (80x86) Debug.
!ENDIF 

!IF "$(CFG)" != "Win32 (80x86) Release" && "$(CFG)" != "Win32 (80x86) Debug" &&\
 "$(CFG)" != "Win32 (MIPS) Debug" && "$(CFG)" != "Win32 (MIPS) Release"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this makefile
!MESSAGE by defining the macro CFG on the command line.  For example:
!MESSAGE 
!MESSAGE NMAKE /f "Task_Man.mak" CFG="Win32 (80x86) Debug"
!MESSAGE 
!MESSAGE Possible choices for configuration are:
!MESSAGE 
!MESSAGE "Win32 (80x86) Release" (based on "Win32 (x86) Application")
!MESSAGE "Win32 (80x86) Debug" (based on "Win32 (x86) Application")
!MESSAGE "Win32 (MIPS) Debug" (based on "Win32 (MIPS) Application")
!MESSAGE "Win32 (MIPS) Release" (based on "Win32 (MIPS) Application")
!MESSAGE 
!ERROR An invalid configuration is specified.
!ENDIF 

################################################################################
# Begin Project
# PROP Target_Last_Scanned "Win32 (80x86) Debug"

!IF  "$(CFG)" == "Win32 (80x86) Release"

# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "WinRel"
# PROP BASE Intermediate_Dir "WinRel"
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "WinRel"
# PROP Intermediate_Dir "WinRel"
OUTDIR=.\WinRel
INTDIR=.\WinRel

ALL : $(OUTDIR)/Task_Man.exe $(OUTDIR)/Task_Man.bsc

$(OUTDIR) : 
    if not exist $(OUTDIR)/nul mkdir $(OUTDIR)

MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /win32
MTL_PROJ=/nologo /D "NDEBUG" /win32 
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "WIN32" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "WIN32" /D\
 "_MBCS" /FR$(INTDIR)/ /Fp$(OUTDIR)/"Task_Man.pch" /Fo$(INTDIR)/ /c 
CPP_OBJS=.\WinRel/

.c{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

.cpp{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

.cxx{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

RSC=rc.exe
# ADD BASE RSC /l 0x1 /d "NDEBUG"
# ADD RSC /l 0x1
RSC_PROJ=/l 0x1 /fo$(INTDIR)/"Task_Man.res" 
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
# SUBTRACT BSC32 /Iu
BSC32_FLAGS=/nologo /o$(OUTDIR)/"Task_Man.bsc" 
BSC32_SBRS= \
 $(INTDIR)/Task_Man.sbr

$(OUTDIR)/Task_Man.bsc : $(OUTDIR)  $(BSC32_SBRS)
    $(BSC32) @<<
  $(BSC32_FLAGS) $(BSC32_SBRS)
<<

LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /NOLOGO /MACHINE:I386 /SUBSYSTEM:windows,4.0
# ADD LINK32 version.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /MACHINE:I386 /SUBSYSTEM:windows,4.0
LINK32_FLAGS=version.lib kernel32.lib user32.lib gdi32.lib winspool.lib\
 comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\
 odbc32.lib odbccp32.lib /NOLOGO /INCREMENTAL:no /PDB:$(OUTDIR)/"Task_Man.pdb"\
 /MACHINE:I386 /OUT:$(OUTDIR)/"Task_Man.exe" /SUBSYSTEM:windows,4.0  
DEF_FILE=
LINK32_OBJS= \
 $(INTDIR)/Task_Man.res \
 $(INTDIR)/Task_Man.obj

$(OUTDIR)/Task_Man.exe : $(OUTDIR)  $(DEF_FILE) $(LINK32_OBJS)
    $(LINK32) @<<
  $(LINK32_FLAGS) $(LINK32_OBJS)
<<

!ELSEIF  "$(CFG)" == "Win32 (80x86) Debug"

# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "WinDebug"
# PROP BASE Intermediate_Dir "WinDebug"
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "WinDebug"
# PROP Intermediate_Dir "WinDebug"
OUTDIR=.\WinDebug
INTDIR=.\WinDebug

ALL : $(OUTDIR)/Task_Man.exe $(OUTDIR)/Task_Man.bsc

$(OUTDIR) : 
    if not exist $(OUTDIR)/nul mkdir $(OUTDIR)

MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /win32
MTL_PROJ=/nologo /D "_DEBUG" /win32 
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "WIN32" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "WIN32" /D\
 "_MBCS" /FR$(INTDIR)/ /Fp$(OUTDIR)/"Task_Man.pch" /Fo$(INTDIR)/\
 /Fd$(OUTDIR)/"Task_Man.pdb" /c 
CPP_OBJS=.\WinDebug/

.c{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

.cpp{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

.cxx{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

RSC=rc.exe
# ADD BASE RSC /l 0x1 /d "_DEBUG"
# ADD RSC /l 0x1
RSC_PROJ=/l 0x1 /fo$(INTDIR)/"Task_Man.res" 
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# SUBTRACT BASE BSC32 /Iu
# ADD BSC32 /nologo
# SUBTRACT BSC32 /Iu
BSC32_FLAGS=/nologo /o$(OUTDIR)/"Task_Man.bsc" 
BSC32_SBRS= \
 $(INTDIR)/Task_Man.sbr

$(OUTDIR)/Task_Man.bsc : $(OUTDIR)  $(BSC32_SBRS)
    $(BSC32) @<<
  $(BSC32_FLAGS) $(BSC32_SBRS)
<<

LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /NOLOGO /DEBUG /MACHINE:I386 /SUBSYSTEM:windows,4.0
# ADD LINK32 version.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /DEBUG /MACHINE:I386 /SUBSYSTEM:windows,4.0
LINK32_FLAGS=version.lib kernel32.lib user32.lib gdi32.lib winspool.lib\
 comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\
 odbc32.lib odbccp32.lib /NOLOGO /INCREMENTAL:yes /PDB:$(OUTDIR)/"Task_Man.pdb"\
 /DEBUG /MACHINE:I386 /OUT:$(OUTDIR)/"Task_Man.exe" /SUBSYSTEM:windows,4.0  
DEF_FILE=
LINK32_OBJS= \
 $(INTDIR)/Task_Man.res \
 $(INTDIR)/Task_Man.obj

$(OUTDIR)/Task_Man.exe : $(OUTDIR)  $(DEF_FILE) $(LINK32_OBJS)
    $(LINK32) @<<
  $(LINK32_FLAGS) $(LINK32_OBJS)
<<

!ELSEIF  "$(CFG)" == "Win32 (MIPS) Debug"

# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 1
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Win32__M"
# PROP Intermediate_Dir "Win32__M"
OUTDIR=.\Win32__M
INTDIR=.\Win32__M

ALL : $(OUTDIR)/GENERIC.exe $(OUTDIR)/GENERIC.bsc ".\$(MTL_TLBS)"\
 ".\$(MTL_TLBS)"

$(OUTDIR) : 
    if not exist $(OUTDIR)/nul mkdir $(OUTDIR)

MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /win32
MTL_PROJ=/nologo /D "_DEBUG" /win32 
RSC=rc.exe
# ADD BASE RSC /l 0x1 /d "_DEBUG"
# ADD RSC /l 0x1 /d "_DEBUG"
RSC_PROJ=/l 0x1 /fo$(INTDIR)/"GENERIC.res" /d "_DEBUG" 
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /MD /W3 /GX /Zi /YX /Od /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL"\
 /D "_MBCS" /FR$(INTDIR)/ /Fp$(OUTDIR)/"GENERIC.pch" /Fo$(INTDIR)/\
 /Fd$(OUTDIR)/"GENERIC.pdb" /c 
CPP_OBJS=.\Win32__M/

.c{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

.cpp{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

.cxx{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o$(OUTDIR)/"GENERIC.bsc" 
BSC32_SBRS= \
 $(INTDIR)/generic.sbr

$(OUTDIR)/GENERIC.bsc : $(OUTDIR)  $(BSC32_SBRS)
    $(BSC32) @<<
  $(BSC32_FLAGS) $(BSC32_SBRS)
<<

LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib odbc32.lib oleaut32.lib uuid.lib /NOLOGO /SUBSYSTEM:windows,4.0 /DEBUG /MACHINE:MIPS
# ADD LINK32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib odbc32.lib oleaut32.lib uuid.lib /NOLOGO /SUBSYSTEM:windows,4.0 /DEBUG /MACHINE:MIPS
LINK32_FLAGS=user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib\
 shell32.lib odbc32.lib mfc30d.lib mfco30d.lib mfcd30d.lib oleaut32.lib uuid.lib\
  /NOLOGO /SUBSYSTEM:windows,4.0 /PDB:$(OUTDIR)/"GENERIC.pdb" /DEBUG /MACHINE:MIPS\
 /OUT:$(OUTDIR)/"GENERIC.exe" 
DEF_FLAGS=
DEF_FILE=
LINK32_OBJS= \
 $(INTDIR)/generic.res \
 $(INTDIR)/generic.obj

$(OUTDIR)/GENERIC.exe : $(OUTDIR)  $(DEF_FILE) $(LINK32_OBJS)
    $(LINK32) @<<
  $(LINK32_FLAGS) $(DEF_FLAGS) $(LINK32_OBJS)
<<

!ELSEIF  "$(CFG)" == "Win32 (MIPS) Release"

# PROP BASE Use_MFC 2
# PROP BASE Use_Debug_Libraries 0
# PROP Use_MFC 2
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Win32__0"
# PROP Intermediate_Dir "Win32__0"
OUTDIR=.\Win32__0
INTDIR=.\Win32__0

ALL : $(OUTDIR)/GENERIC.exe $(OUTDIR)/GENERIC.bsc ".\$(MTL_TLBS)"\
 ".\$(MTL_TLBS)"

$(OUTDIR) : 
    if not exist $(OUTDIR)/nul mkdir $(OUTDIR)

MTL=MkTypLib.exe
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /win32
MTL_PROJ=/nologo /D "NDEBUG" /win32 
RSC=rc.exe
# ADD BASE RSC /l 0x1 /d "NDEBUG"
# ADD RSC /l 0x1 /d "NDEBUG"
RSC_PROJ=/l 0x1 /fo$(INTDIR)/"GENERIC.res" /d "NDEBUG" 
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
# ADD CPP /nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /c
CPP_PROJ=/nologo /MD /W3 /GX /YX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D\
 "_MBCS" /FR$(INTDIR)/ /Fp$(OUTDIR)/"GENERIC.pch" /Fo$(INTDIR)/ /c 
CPP_OBJS=.\Win32__0/

.c{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

.cpp{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

.cxx{$(CPP_OBJS)}.obj:
   $(CPP) $(CPP_PROJ) $<  

BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o$(OUTDIR)/"GENERIC.bsc" 
BSC32_SBRS= \
 $(INTDIR)/generic.sbr

$(OUTDIR)/GENERIC.bsc : $(OUTDIR)  $(BSC32_SBRS)
    $(BSC32) @<<
  $(BSC32_FLAGS) $(BSC32_SBRS)
<<

LINK32=link.exe
# ADD BASE LINK32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib odbc32.lib oleaut32.lib uuid.lib /NOLOGO /SUBSYSTEM:windows,4.0 /MACHINE:MIPS
# ADD LINK32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib odbc32.lib oleaut32.lib uuid.lib /NOLOGO /SUBSYSTEM:windows,4.0 /MACHINE:MIPS
LINK32_FLAGS=user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib\
 shell32.lib odbc32.lib mfc30.lib mfco30.lib mfcd30.lib oleaut32.lib uuid.lib\
  /NOLOGO /SUBSYSTEM:windows,4.0 /PDB:$(OUTDIR)/"GENERIC.pdb" /MACHINE:MIPS\
 /OUT:$(OUTDIR)/"GENERIC.exe" 
DEF_FLAGS=
DEF_FILE=
LINK32_OBJS= \
 $(INTDIR)/generic.res \
 $(INTDIR)/generic.obj

$(OUTDIR)/GENERIC.exe : $(OUTDIR)  $(DEF_FILE) $(LINK32_OBJS)
    $(LINK32) @<<
  $(LINK32_FLAGS) $(DEF_FLAGS) $(LINK32_OBJS)
<<

!ENDIF 

################################################################################
# Begin Group "Source Files"

################################################################################
# Begin Source File

SOURCE=.\Task_Man.rc
DEP_ENUMW=\
 .\GENERIC.ICO\
 .\Task_Man.h

!IF  "$(CFG)" == "Win32 (80x86) Release"

$(INTDIR)/Task_Man.res :  $(SOURCE)  $(DEP_ENUMW) $(INTDIR)
   $(RSC) $(RSC_PROJ)  $(SOURCE) 

!ELSEIF  "$(CFG)" == "Win32 (80x86) Debug"

$(INTDIR)/Task_Man.res :  $(SOURCE)  $(DEP_ENUMW) $(INTDIR)
   $(RSC) $(RSC_PROJ)  $(SOURCE) 

!ELSEIF  "$(CFG)" == "Win32 (MIPS) Debug"

!ELSEIF  "$(CFG)" == "Win32 (MIPS) Release"

!ENDIF 

# End Source File
################################################################################
# Begin Source File

SOURCE=.\Task_Man.c
DEP_ENUMWN=\
 .\Task_Man.h

!IF  "$(CFG)" == "Win32 (80x86) Release"

$(INTDIR)/Task_Man.obj :  $(SOURCE)  $(DEP_ENUMWN) $(INTDIR)

!ELSEIF  "$(CFG)" == "Win32 (80x86) Debug"

$(INTDIR)/Task_Man.obj :  $(SOURCE)  $(DEP_ENUMWN) $(INTDIR)

!ELSEIF  "$(CFG)" == "Win32 (MIPS) Debug"

!ELSEIF  "$(CFG)" == "Win32 (MIPS) Release"

!ENDIF 

# End Source File
# End Group
# End Project
################################################################################
#include "windows.h"
#include "Task_Man.h"

MYAPP                ICON    DISCARDABLE     "GENERIC.ICO"

MYAPP MENU DISCARDABLE 
BEGIN
    POPUP "&File"
    BEGIN
        MENUITEM "E&xit",                             IDM_EXIT
    END
    MENUITEM "&Test!",                                IDM_TEST
    POPUP "&Help"
    BEGIN
        MENUITEM "&About Task_Man()...",   IDM_ABOUT
    END
END


ABOUTBOX DIALOG 22, 17, 171, 43
STYLE DS_MODALFRAME | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU
CAPTION "Task_Man()"
FONT 8, "MS Sans Serif"
{
   CONTROL "MyApp", -1, "STATIC", SS_ICON | WS_CHILD | WS_VISIBLE, 3, 2, 16, 16
   CONTROL "Generic Application", -1, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 28, 4, 100, 8
   CONTROL "OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 116, 26, 50, 14
}


#include <stdio.h>
#include <dos.h>
#include <stdlib.h>

void main(void)
{
 struct fcbs
 {
  char drive;
  char filename[8];
  char extension[3];
  int current_block;
  int record_size;
 };
 typedef struct fcbs fcb;
 struct program_segment_prefix
 {
  char near *int20;
  char near *next_paragraph_segment;
  char reserved_1;
  char dos_dispatcher[5];
  char far *terminate_vector;
  char far *ctrlc_vector;
  char near *parent_psp;
  unsigned char file_table[20];
  char near *environment_block_segment;
  char far *stack_storage;
  int handles_available;
  char far *file_table_address;
  char far *shares_previous_psp;
  char reserved_2[20];
  char dos_int21_retf[3];
  char reserved_3[9];
  fcb fcb1;
  fcb fcb2;
  char reserved_4[4];
  char command_tail[128];
 } far *psp;
 int i;

 psp = (struct program_segment_prefix far *) ((long) _psp << 16);
 for (i = 0; i < 20; i++)
  printf("Entry %d contains %x\n", i, psp->file_table[i]);
}

#include <stdio.h>
#include <dos.h>
#include <stdlib.h>

void main(void)
{
 union REGS inregs, outregs;
 struct SREGS segs;
 int i, j;
 int structure_size;
 struct SystemTableEntry
 {
  struct SystemTableEntry far *next; //Next SFT entry
  unsigned file_count;    //Files in table
  unsigned handle_count;    //Handles to this file
  unsigned open_mode;     //File open mode
  char file_attribute;    //Attribute byte
  unsigned local_remote;    //Bit 15 set means remote
  unsigned far *DPD;     //Drive parameter block
  unsigned starting_cluster;   
  unsigned time_stamp;
  unsigned date_stamp;
  long file_size;
  long current_offset;
  unsigned relative_cluster;
  long directory_sector_number;
  char directory_entry_offset;
  char filename_ext[11];    //No period, space padded
           //Ignore SHARE fields for example
 } far *table_ptr, far *file;
 long far *system_table;
 
 //Get DOS version
 inregs.x.ax = 0x3001;
 intdos (&inregs, &outregs);
 if (outregs.h.al < 3)
 {
  printf("This program requires DOS version 3 or later\n");
  exit (1);
 }
 else if (outregs.h.al == 3)
  structure_size = 0x35;
 else if (outregs.h.al >= 4)
  structure_size = 0x3B;
 //Get the list of losts pointer
 inregs.h.ah = 0x52;
 intdosx (&inregs, &outregs, &segs);
 //The pointer to the system file table is at offset 4
 system_table = MK_FP(segs.es, outregs.x.bx + 4);
 table_ptr = (struct SystemTableEntry far *) *system_table;
 do
 {
  printf("%d entries in table\n", table_ptr->file_count);
  for (i = 0; i < table_ptr->file_count; i++)
  {
   file = MK_FP(FP_SEG(table_ptr), FP_OFF(table_ptr) +
    (i * structure_size));
   if (file->handle_count)
   {
    for (j = 0; j < 8; j++)
     if (file->filename_ext[j] != ' ')
      putchar(file->filename_ext[j]);
     else 
      break;
     if (file->filename_ext[8] != ' ')
      putchar('.');
     for (j = 8; j < 11; j++)
      if (file->filename_ext[j] != ' ')
       putchar(file->filename_ext[j]);
      printf (" %ld bytes %x attribute %d references\n",
       file->file_size, file->file_attribute,
       file->handle_count);
   }
  }
  table_ptr = table_ptr->next;
 } while (FP_OFF(table_ptr) != 0xFFFF);
}

#include <stdio.h>

void main(void)
 {
 FILE *input;

 if ((input = fopen("\\CONFIG.SYS", "r")) == NULL)
  printf("Error opening \\CONFIG.SYS\N");
 else
    {
  printf("Handle for CONFIG.SYS %d\n", input->fd);
  printf("Handle for stdin %d\n", stdin->fd);
  printf("Handle for stdout %d\n", stdout->fd);
  printf("Handle for stderr %d\n", stderr->fd);
  printf("Handle for stdaux %d\n", stdaux->fd);
  printf("Handle for stdprn %d\n", stdprn->fd);
  fclose(input);
  }
 }
#include <stdio.h>

void main(void)
 {
   FILE *fp;

   int pages = 800;
   float price = 49.95;

   if (fp = fopen("FPRINTF.DAT", "w"))
     {
       fprintf(fp, "Book Title: Jamsa\'s C & C++ Programmer\'s Bible\n");
       fprintf(fp, "Pages: %d\n", pages);
       fprintf(fp, "Price: $%5.2f\n", price);
       fclose(fp);
     }
   else 
     printf("Error opening FPRINTF.DAT\n");
 }
#include <stdio.h>

void main(int argc, char *argv[])
 {
  if (argc < 3)
    printf("Must specify a source and target filename\n");
  else if (rename(argv[1], argv[2]))
    printf("Error renaming file\n");
 }
#include <stdio.h>

void main(int argc, char *argv[])
 {
   while (*++argv)
     if (remove(*argv))
       printf("Error removing %s\n", *argv);
 }
#include <stdio.h>

void main(int argc, char *argv[])
 {
   while (*++argv)
     if (unlink(*argv))
       printf("Error removing %s\n", *argv);
 }
#include <stdio.h>
#include <io.h>

void main(int argc, char *argv[])
 {
   int access_mode;

   access_mode = access(argv[1], 0);
   
   if (access_mode)
     printf("File %s does not exist\n");
   else    
     {
       access_mode = access(argv[1], 2);

       if (access_mode)
         printf("File cannot be written\n");
       else
         printf("File can be written\n");

       access_mode = access(argv[1], 4);

       if (access_mode)
         printf("File cannot be read\n");
       else
         printf("File can be read\n");
       
       access_mode = access(argv[1], 6);

       if (access_mode)
         printf("File cannot be read/write\n");
       else
         printf("File can be read/write\n");
     }
 }
#include <stdio.h>
#include <sys\stat.h>
#include <io.h>

void main(int argc, char *argv[])
 {
   if (chmod(argv[1], S_IREAD))
     printf("Error setting %s\n", argv[1]);
 }

#include <stdio.h>
#include <dos.h>
#include <io.h>

void main(int argc, char *argv[])
 {
   int attributes;

   if ((attributes = _chmod(argv[1], 0)) == -1)
     printf("Error accessing %s\n", argv[1]);
   else
     {
         if (attributes & FA_ARCH)
           printf("Archive ");

         if (attributes & FA_DIREC)
           printf("Directory ");
         
         if (attributes & FA_HIDDEN)
           printf("Hidden ");
         
         if (attributes & FA_LABEL)
           printf("Volume label ");
         
         if (attributes & FA_RDONLY)
           printf("Readonly ");

         if (attributes & FA_SYSTEM)
           printf("System ");
     }
 }
#include <stdio.h>
#include <stdlib.h>

void main(int argc, char *argv[])
 {
   FILE *fp;

   char line[256]; 

   if (fp = fopen(argv[1], "r"))
     {
       while (fgets(line, sizeof(line), fp))
         {
           if (ferror(fp))
             {
               fprintf(stderr, "Error reading from %s\n", argv[1]);
               exit(1);
             }
           else 
             {
               fputs(line, stdout);
               if (ferror(fp))
                 {
                   fprintf(stderr, "Error writing to stdout\n");
                   exit(1);
                 }
             }
         }
     }
   else 
     printf("Error opening %s\n", argv[1]);
 }
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>

void main(int argc, char *argv[])
 {
   int file_handle;

   long file_size;

   if ((file_handle = open(argv[1], O_RDONLY)) == -1)
     printf("Error opening the file %d\n", argv[1]);
   else
     {
       file_size = filelength(file_handle);
       printf("The file size in bytes is %ld\n", file_size);
       close(file_handle);
     }
 }
#include <stdio.h>
#include <io.h>

void main(int argc, char *argv[])
 {
   FILE *stream;

   int handle;

   long file_length;

   if (stream = fopen(argv[1], "r"))
     {
        // Some statements
        handle = fileno(stream);
        file_length = filelength(handle);
        printf("The file length is %ld\n", file_length);
        fclose(stream);
     }
   else
     printf("Error opening %s\n", argv[1]);
 }
#include <stdio.h>

void main(void)
 {
   char buffer[64];

   int counter;

   for (counter = 0; counter < 5; counter++)
     printf("Temporary filename %s\n", tmpnam(buffer));
 }
#include <stdio.h>

void main(void)
 {
   char buffer[64];

   int counter;

   printf("Temporary filename %s\n", tempnam(buffer, "Bible"));
 }
#include <stdio.h>
#include <dir.h>

void main(int argc, char *argv[])
 {
   char *path;

   if (path = searchpath(argv[1]))
     printf("Pathname: %s\n", path); 
   else
     printf("File not found\n");
 }
#include <stdio.h>
#include <stdlib.h>

void main(int argc, char *argv[])
 {
   char path[128];
   
   _searchenv(argv[1], "LIB", path);

   if (path[0])
     printf("Pathname: %s\n", path); 
   else
     printf("File not found\n");
 }
#include <stdio.h>
#include <stdlib.h>
#include <dir.h>
#include <errno.h>

void main(int argc, char *argv[])
  {
    char directory[MAXPATH];

    if (argc == 1)  // Display the current directory
      {
        getcwd(directory, MAXPATH);
        puts(directory);
      }
    else if ((chdir(argv[1])) && (errno == ENOENT))
      puts("Invalid directory");
  }
          

// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1995 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.

#ifndef __AFXRES_H__
#define __AFXRES_H__

#ifdef REZ  // Mac resource compiler (mrc) defines REZ
#define RC_INVOKED
#endif

#ifdef RC_INVOKED
#ifndef _INC_WINDOWS
#define _INC_WINDOWS
 #include "winres.h"           // extract from windows header
#endif
#endif

#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, off)
#endif

#ifdef APSTUDIO_INVOKED
#define APSTUDIO_HIDDEN_SYMBOLS
#endif

/////////////////////////////////////////////////////////////////////////////
// MFC resource types (see Technical note TN024 for implementation details)

#ifndef RC_INVOKED
#define RT_DLGINIT  MAKEINTRESOURCE(240)
#define RT_TOOLBAR  MAKEINTRESOURCE(241)
#endif

/////////////////////////////////////////////////////////////////////////////

#ifdef APSTUDIO_INVOKED
#undef APSTUDIO_HIDDEN_SYMBOLS
#endif

/////////////////////////////////////////////////////////////////////////////
// General style bits etc

// Tab Control styles
#ifndef TCS_MULTILINE // new in later versions of Win32
#define TCS_MULTILINE       0x0200
#endif

// ControlBar styles
#define CBRS_ALIGN_LEFT     0x1000L
#define CBRS_ALIGN_TOP      0x2000L
#define CBRS_ALIGN_RIGHT    0x4000L
#define CBRS_ALIGN_BOTTOM   0x8000L
#define CBRS_ALIGN_ANY      0xF000L

#define CBRS_BORDER_LEFT    0x0100L
#define CBRS_BORDER_TOP     0x0200L
#define CBRS_BORDER_RIGHT   0x0400L
#define CBRS_BORDER_BOTTOM  0x0800L
#define CBRS_BORDER_ANY     0x0F00L

#define CBRS_TOOLTIPS       0x0010L
#define CBRS_FLYBY          0x0020L
#define CBRS_FLOAT_MULTI    0x0040L
#define CBRS_BORDER_3D      0x0080L
#define CBRS_HIDE_INPLACE   0x0008L
#define CBRS_SIZE_DYNAMIC   0x0004L
#define CBRS_SIZE_FIXED     0x0002L
#define CBRS_FLOATING       0x0001L

#define CBRS_ORIENT_HORZ    (CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM)
#define CBRS_ORIENT_VERT    (CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT)
#define CBRS_ORIENT_ANY     (CBRS_ORIENT_HORZ|CBRS_ORIENT_VERT)

#define CBRS_ALL            0xFFFFL


// the CBRS_ style is made up of an alignment style and a draw border style
//  the alignment styles are mutually exclusive
//  the draw border styles may be combined
#define CBRS_NOALIGN        0x00000000L
#define CBRS_LEFT           (CBRS_ALIGN_LEFT|CBRS_BORDER_RIGHT)
#define CBRS_TOP            (CBRS_ALIGN_TOP|CBRS_BORDER_BOTTOM)
#define CBRS_RIGHT          (CBRS_ALIGN_RIGHT|CBRS_BORDER_LEFT)
#define CBRS_BOTTOM         (CBRS_ALIGN_BOTTOM|CBRS_BORDER_TOP)

/////////////////////////////////////////////////////////////////////////////
// Standard window components

// Mode indicators in status bar - these are routed like commands
#define ID_INDICATOR_EXT                0xE700  // extended selection indicator
#define ID_INDICATOR_CAPS               0xE701  // cap lock indicator
#define ID_INDICATOR_NUM                0xE702  // num lock indicator
#define ID_INDICATOR_SCRL               0xE703  // scroll lock indicator
#define ID_INDICATOR_OVR                0xE704  // overtype mode indicator
#define ID_INDICATOR_REC                0xE705  // record mode indicator
#define ID_INDICATOR_KANA               0xE706  // kana lock indicator

#define ID_SEPARATOR                    0   // special separator value

#ifndef RC_INVOKED  // code only
// Standard control bars (IDW = window ID)
#define AFX_IDW_CONTROLBAR_FIRST        0xE800
#define AFX_IDW_CONTROLBAR_LAST         0xE8FF

#define AFX_IDW_TOOLBAR                 0xE800  // main Toolbar for window
#define AFX_IDW_STATUS_BAR              0xE801  // Status bar window
#define AFX_IDW_PREVIEW_BAR             0xE802  // PrintPreview Dialog Bar
#define AFX_IDW_RESIZE_BAR              0xE803  // OLE in-place resize bar

// Note: If your application supports docking toolbars, you should
//  not use the following IDs for your own toolbars.  The IDs chosen
//  are at the top of the first 32 such that the bars will be hidden
//  while in print preview mode, and are not likely to conflict with
//  IDs your application may have used succesfully in the past.

#define AFX_IDW_DOCKBAR_TOP             0xE81B
#define AFX_IDW_DOCKBAR_LEFT            0xE81C
#define AFX_IDW_DOCKBAR_RIGHT           0xE81D
#define AFX_IDW_DOCKBAR_BOTTOM          0xE81E
#define AFX_IDW_DOCKBAR_FLOAT           0xE81F

// Macro for mapping standard control bars to bitmask (limit of 32)
#define AFX_CONTROLBAR_MASK(nIDC)   (1L << (nIDC - AFX_IDW_CONTROLBAR_FIRST))

// parts of Main Frame
#define AFX_IDW_PANE_FIRST              0xE900  // first pane (256 max)
#define AFX_IDW_PANE_LAST               0xE9ff
#define AFX_IDW_HSCROLL_FIRST           0xEA00  // first Horz scrollbar (16 max)
#define AFX_IDW_VSCROLL_FIRST           0xEA10  // first Vert scrollbar (16 max)

#define AFX_IDW_SIZE_BOX                0xEA20  // size box for splitters
#define AFX_IDW_PANE_SAVE               0xEA21  // to shift AFX_IDW_PANE_FIRST
#endif //!RC_INVOKED

#ifndef APSTUDIO_INVOKED

// common style for form views
#define AFX_WS_DEFAULT_VIEW             (WS_CHILD | WS_VISIBLE | WS_BORDER)

#endif //!APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////
// Standard app configurable strings

// for application title (defaults to EXE name or name in constructor)
#define AFX_IDS_APP_TITLE               0xE000
// idle message bar line
#define AFX_IDS_IDLEMESSAGE             0xE001
// message bar line when in shift-F1 help mode
#define AFX_IDS_HELPMODEMESSAGE         0xE002
// document title when editing OLE embedding
#define AFX_IDS_APP_TITLE_EMBEDDING     0xE003
// company name
#define AFX_IDS_COMPANY_NAME            0xE004
// object name when server is inplace
#define AFX_IDS_OBJ_TITLE_INPLACE       0xE005

/////////////////////////////////////////////////////////////////////////////
// Standard Commands

// File commands
#define ID_FILE_NEW                     0xE100
#define ID_FILE_OPEN                    0xE101
#define ID_FILE_CLOSE                   0xE102
#define ID_FILE_SAVE                    0xE103
#define ID_FILE_SAVE_AS                 0xE104
#define ID_FILE_PAGE_SETUP              0xE105
#define ID_FILE_PRINT_SETUP             0xE106
#define ID_FILE_PRINT                   0xE107
#define ID_FILE_PRINT_DIRECT            0xE108
#define ID_FILE_PRINT_PREVIEW           0xE109
#define ID_FILE_UPDATE                  0xE10A
#define ID_FILE_SAVE_COPY_AS            0xE10B
#define ID_FILE_SEND_MAIL               0xE10C

#define ID_FILE_MRU_FIRST               0xE110
#define ID_FILE_MRU_FILE1               0xE110          // range - 16 max
#define ID_FILE_MRU_FILE2               0xE111
#define ID_FILE_MRU_FILE3               0xE112
#define ID_FILE_MRU_FILE4               0xE113
#define ID_FILE_MRU_FILE5               0xE114
#define ID_FILE_MRU_FILE6               0xE115
#define ID_FILE_MRU_FILE7               0xE116
#define ID_FILE_MRU_FILE8               0xE117
#define ID_FILE_MRU_FILE9               0xE118
#define ID_FILE_MRU_FILE10              0xE119
#define ID_FILE_MRU_FILE11              0xE11A
#define ID_FILE_MRU_FILE12              0xE11B
#define ID_FILE_MRU_FILE13              0xE11C
#define ID_FILE_MRU_FILE14              0xE11D
#define ID_FILE_MRU_FILE15              0xE11E
#define ID_FILE_MRU_FILE16              0xE11F
#define ID_FILE_MRU_LAST                0xE11F

// Edit commands
#define ID_EDIT_CLEAR                   0xE120
#define ID_EDIT_CLEAR_ALL               0xE121
#define ID_EDIT_COPY                    0xE122
#define ID_EDIT_CUT                     0xE123
#define ID_EDIT_FIND                    0xE124
#define ID_EDIT_PASTE                   0xE125
#define ID_EDIT_PASTE_LINK              0xE126
#define ID_EDIT_PASTE_SPECIAL           0xE127
#define ID_EDIT_REPEAT                  0xE128
#define ID_EDIT_REPLACE                 0xE129
#define ID_EDIT_SELECT_ALL              0xE12A
#define ID_EDIT_UNDO                    0xE12B
#define ID_EDIT_REDO                    0xE12C

// Window commands
#define ID_WINDOW_NEW                   0xE130
#define ID_WINDOW_ARRANGE               0xE131
#define ID_WINDOW_CASCADE               0xE132
#define ID_WINDOW_TILE_HORZ             0xE133
#define ID_WINDOW_TILE_VERT             0xE134
#define ID_WINDOW_SPLIT                 0xE135
#ifndef RC_INVOKED      // code only
#define AFX_IDM_WINDOW_FIRST            0xE130
#define AFX_IDM_WINDOW_LAST             0xE13F
#define AFX_IDM_FIRST_MDICHILD          0xFF00  // window list starts here
#endif //!RC_INVOKED

// Help and App commands
#define ID_APP_ABOUT                    0xE140
#define ID_APP_EXIT                     0xE141
#define ID_HELP_INDEX                   0xE142
#define ID_HELP_FINDER                  0xE143
#define ID_HELP_USING                   0xE144
#define ID_CONTEXT_HELP                 0xE145      // shift-F1
// special commands for processing help
#define ID_HELP                         0xE146      // first attempt for F1
#define ID_DEFAULT_HELP                 0xE147      // last attempt

// Misc
#define ID_NEXT_PANE                    0xE150
#define ID_PREV_PANE                    0xE151

// Format
#define ID_FORMAT_FONT                  0xE160

// OLE commands
#define ID_OLE_INSERT_NEW               0xE200
#define ID_OLE_EDIT_LINKS               0xE201
#define ID_OLE_EDIT_CONVERT             0xE202
#define ID_OLE_EDIT_CHANGE_ICON         0xE203
#define ID_OLE_EDIT_PROPERTIES          0xE204
#define ID_OLE_VERB_FIRST               0xE210     // range - 16 max
#ifndef RC_INVOKED      // code only
#define ID_OLE_VERB_LAST                0xE21F
#endif //!RC_INVOKED

// for print preview dialog bar
#define AFX_ID_PREVIEW_CLOSE            0xE300
#define AFX_ID_PREVIEW_NUMPAGE          0xE301      // One/Two Page button
#define AFX_ID_PREVIEW_NEXT             0xE302
#define AFX_ID_PREVIEW_PREV             0xE303
#define AFX_ID_PREVIEW_PRINT            0xE304
#define AFX_ID_PREVIEW_ZOOMIN           0xE305
#define AFX_ID_PREVIEW_ZOOMOUT          0xE306

// View commands (same number used as IDW used for control bar)
#define ID_VIEW_TOOLBAR                 0xE800
#define ID_VIEW_STATUS_BAR              0xE801
 // -> E8FF reserved for other control bar commands

// RecordForm commands
#define ID_RECORD_FIRST                 0xE900
#define ID_RECORD_LAST                  0xE901
#define ID_RECORD_NEXT                  0xE902
#define ID_RECORD_PREV                  0xE903

/////////////////////////////////////////////////////////////////////////////
// Standard control IDs

#ifdef IDC_STATIC
#undef IDC_STATIC
#endif
#define IDC_STATIC              (-1)     // all static controls

/////////////////////////////////////////////////////////////////////////////
// Standard string error/warnings

#ifndef RC_INVOKED      // code only
#define AFX_IDS_SCFIRST                 0xEF00
#endif //!RC_INVOKED

#define AFX_IDS_SCSIZE                  0xEF00
#define AFX_IDS_SCMOVE                  0xEF01
#define AFX_IDS_SCMINIMIZE              0xEF02
#define AFX_IDS_SCMAXIMIZE              0xEF03
#define AFX_IDS_SCNEXTWINDOW            0xEF04
#define AFX_IDS_SCPREVWINDOW            0xEF05
#define AFX_IDS_SCCLOSE                 0xEF06
#define AFX_IDS_SCRESTORE               0xEF12
#define AFX_IDS_SCTASKLIST              0xEF13

#define AFX_IDS_MDICHILD                0xEF1F

#define AFX_IDS_DESKACCESSORY           0xEFDA

// General strings
#define AFX_IDS_OPENFILE                0xF000
#define AFX_IDS_SAVEFILE                0xF001
#define AFX_IDS_ALLFILTER               0xF002
#define AFX_IDS_UNTITLED                0xF003
#define AFX_IDS_SAVEFILECOPY            0xF004
#define AFX_IDS_PREVIEW_CLOSE           0xF005
#define AFX_IDS_UNNAMED_FILE            0xF006
#ifdef _MAC
#define AFX_IDS_ABOUT                   0xF010
#endif
#define AFX_IDS_HIDE                    0xF011

// MFC Standard Exception Error messages
#define AFX_IDP_NO_ERROR_AVAILABLE      0xF020
#define AFX_IDS_NOT_SUPPORTED_EXCEPTION 0xF021
#define AFX_IDS_RESOURCE_EXCEPTION      0xF022
#define AFX_IDS_MEMORY_EXCEPTION        0xF023
#define AFX_IDS_USER_EXCEPTION          0xF024

// Printing and print preview strings
#define AFX_IDS_PRINTONPORT             0xF040
#define AFX_IDS_ONEPAGE                 0xF041
#define AFX_IDS_TWOPAGE                 0xF042
#define AFX_IDS_PRINTPAGENUM            0xF043
#define AFX_IDS_PREVIEWPAGEDESC         0xF044
#define AFX_IDS_PRINTDEFAULTEXT         0xF045
#define AFX_IDS_PRINTDEFAULT            0xF046
#define AFX_IDS_PRINTFILTER             0xF047
#define AFX_IDS_PRINTCAPTION            0xF048
#define AFX_IDS_PRINTTOFILE             0xF049


// OLE strings
#define AFX_IDS_OBJECT_MENUITEM         0xF080
#define AFX_IDS_EDIT_VERB               0xF081
#define AFX_IDS_ACTIVATE_VERB           0xF082
#define AFX_IDS_CHANGE_LINK             0xF083
#define AFX_IDS_AUTO                    0xF084
#define AFX_IDS_MANUAL                  0xF085
#define AFX_IDS_FROZEN                  0xF086
#define AFX_IDS_ALL_FILES               0xF087
// dynamically changing menu items
#define AFX_IDS_SAVE_MENU               0xF088
#define AFX_IDS_UPDATE_MENU             0xF089
#define AFX_IDS_SAVE_AS_MENU            0xF08A
#define AFX_IDS_SAVE_COPY_AS_MENU       0xF08B
#define AFX_IDS_EXIT_MENU               0xF08C
#define AFX_IDS_UPDATING_ITEMS          0xF08D
// COlePasteSpecialDialog defines
#define AFX_IDS_METAFILE_FORMAT         0xF08E
#define AFX_IDS_DIB_FORMAT              0xF08F
#define AFX_IDS_BITMAP_FORMAT           0xF090
#define AFX_IDS_LINKSOURCE_FORMAT       0xF091
#define AFX_IDS_EMBED_FORMAT            0xF092
// other OLE utility strings
#define AFX_IDS_PASTELINKEDTYPE         0xF094
#define AFX_IDS_UNKNOWNTYPE             0xF095
#define AFX_IDS_RTF_FORMAT              0xF096
#define AFX_IDS_TEXT_FORMAT             0xF097
// OLE datatype format error strings
#define AFX_IDS_INVALID_CURRENCY        0xF098
#define AFX_IDS_INVALID_DATETIME        0xF099
#define AFX_IDS_INVALID_DATETIMESPAN    0xF09A

// General error / prompt strings
#define AFX_IDP_INVALID_FILENAME        0xF100
#define AFX_IDP_FAILED_TO_OPEN_DOC      0xF101
#define AFX_IDP_FAILED_TO_SAVE_DOC      0xF102
#define AFX_IDP_ASK_TO_SAVE             0xF103
#define AFX_IDP_FAILED_TO_CREATE_DOC    0xF104
#define AFX_IDP_FILE_TOO_LARGE          0xF105
#define AFX_IDP_FAILED_TO_START_PRINT   0xF106
#define AFX_IDP_FAILED_TO_LAUNCH_HELP   0xF107
#define AFX_IDP_INTERNAL_FAILURE        0xF108      // general failure
#define AFX_IDP_COMMAND_FAILURE         0xF109      // command failure
#define AFX_IDP_FAILED_MEMORY_ALLOC     0xF10A

// DDV parse errors
#define AFX_IDP_PARSE_INT               0xF110
#define AFX_IDP_PARSE_REAL              0xF111
#define AFX_IDP_PARSE_INT_RANGE         0xF112
#define AFX_IDP_PARSE_REAL_RANGE        0xF113
#define AFX_IDP_PARSE_STRING_SIZE       0xF114
#define AFX_IDP_PARSE_RADIO_BUTTON      0xF115
#define AFX_IDP_PARSE_BYTE              0xF116
#define AFX_IDP_PARSE_UINT              0xF117
#define AFX_IDP_PARSE_DATETIME          0xF118
#define AFX_IDP_PARSE_CURRENCY          0xF119

// CFile/CArchive error strings for user failure
#define AFX_IDP_FAILED_INVALID_FORMAT   0xF120
#define AFX_IDP_FAILED_INVALID_PATH     0xF121
#define AFX_IDP_FAILED_DISK_FULL        0xF122
#define AFX_IDP_FAILED_ACCESS_READ      0xF123
#define AFX_IDP_FAILED_ACCESS_WRITE     0xF124
#define AFX_IDP_FAILED_IO_ERROR_READ    0xF125
#define AFX_IDP_FAILED_IO_ERROR_WRITE   0xF126

// OLE errors / prompt strings
#define AFX_IDP_STATIC_OBJECT           0xF180
#define AFX_IDP_FAILED_TO_CONNECT       0xF181
#define AFX_IDP_SERVER_BUSY             0xF182
#define AFX_IDP_BAD_VERB                0xF183
#define AFX_IDP_FAILED_TO_NOTIFY        0xF185
#define AFX_IDP_FAILED_TO_LAUNCH        0xF186
#define AFX_IDP_ASK_TO_UPDATE           0xF187
#define AFX_IDP_FAILED_TO_UPDATE        0xF188
#define AFX_IDP_FAILED_TO_REGISTER      0xF189
#define AFX_IDP_FAILED_TO_AUTO_REGISTER 0xF18A
#define AFX_IDP_FAILED_TO_CONVERT       0xF18B
#define AFX_IDP_GET_NOT_SUPPORTED       0xF18C
#define AFX_IDP_SET_NOT_SUPPORTED       0xF18D
#define AFX_IDP_ASK_TO_DISCARD          0xF18E
#define AFX_IDP_FAILED_TO_CREATE        0xF18F

// MAPI errors / prompt strings
#define AFX_IDP_FAILED_MAPI_LOAD        0xF190
#define AFX_IDP_INVALID_MAPI_DLL        0xF191
#define AFX_IDP_FAILED_MAPI_SEND        0xF192

#define AFX_IDP_FILE_NONE               0xF1A0
#define AFX_IDP_FILE_GENERIC            0xF1A1
#define AFX_IDP_FILE_NOT_FOUND          0xF1A2
#define AFX_IDP_FILE_BAD_PATH           0xF1A3
#define AFX_IDP_FILE_TOO_MANY_OPEN      0xF1A4
#define AFX_IDP_FILE_ACCESS_DENIED      0xF1A5
#define AFX_IDP_FILE_INVALID_FILE       0xF1A6
#define AFX_IDP_FILE_REMOVE_CURRENT     0xF1A7
#define AFX_IDP_FILE_DIR_FULL           0xF1A8
#define AFX_IDP_FILE_BAD_SEEK           0xF1A9
#define AFX_IDP_FILE_HARD_IO            0xF1AA
#define AFX_IDP_FILE_SHARING            0xF1AB
#define AFX_IDP_FILE_LOCKING            0xF1AC
#define AFX_IDP_FILE_DISKFULL           0xF1AD
#define AFX_IDP_FILE_EOF                0xF1AE

#define AFX_IDP_ARCH_NONE               0xF1B0
#define AFX_IDP_ARCH_GENERIC            0xF1B1
#define AFX_IDP_ARCH_READONLY           0xF1B2
#define AFX_IDP_ARCH_ENDOFFILE          0xF1B3
#define AFX_IDP_ARCH_WRITEONLY          0xF1B4
#define AFX_IDP_ARCH_BADINDEX           0xF1B5
#define AFX_IDP_ARCH_BADCLASS           0xF1B6
#define AFX_IDP_ARCH_BADSCHEMA          0xF1B7

#define AFX_IDS_OCC_SCALEUNITS_PIXELS   0xF1C0

// 0xf200-0xf20f reserved

// font names and point sizes
#define AFX_IDS_STATUS_FONT             0xF230
#define AFX_IDS_TOOLTIP_FONT            0xF231
#define AFX_IDS_UNICODE_FONT            0xF232
#define AFX_IDS_MINI_FONT               0xF233

// ODBC Database errors / prompt strings
#ifndef RC_INVOKED      // code only
#define AFX_IDP_SQL_FIRST                       0xF280
#endif //!RC_INVOKED
#define AFX_IDP_SQL_CONNECT_FAIL                0xF281
#define AFX_IDP_SQL_RECORDSET_FORWARD_ONLY      0xF282
#define AFX_IDP_SQL_EMPTY_COLUMN_LIST           0xF283
#define AFX_IDP_SQL_FIELD_SCHEMA_MISMATCH       0xF284
#define AFX_IDP_SQL_ILLEGAL_MODE                0xF285
#define AFX_IDP_SQL_MULTIPLE_ROWS_AFFECTED      0xF286
#define AFX_IDP_SQL_NO_CURRENT_RECORD           0xF287
#define AFX_IDP_SQL_NO_ROWS_AFFECTED            0xF288
#define AFX_IDP_SQL_RECORDSET_READONLY          0xF289
#define AFX_IDP_SQL_SQL_NO_TOTAL                0xF28A
#define AFX_IDP_SQL_ODBC_LOAD_FAILED            0xF28B
#define AFX_IDP_SQL_DYNASET_NOT_SUPPORTED       0xF28C
#define AFX_IDP_SQL_SNAPSHOT_NOT_SUPPORTED      0xF28D
#define AFX_IDP_SQL_API_CONFORMANCE             0xF28E
#define AFX_IDP_SQL_SQL_CONFORMANCE             0xF28F
#define AFX_IDP_SQL_NO_DATA_FOUND               0xF290
#define AFX_IDP_SQL_ROW_UPDATE_NOT_SUPPORTED    0xF291
#define AFX_IDP_SQL_ODBC_V2_REQUIRED            0xF292
#define AFX_IDP_SQL_NO_POSITIONED_UPDATES       0xF293
#define AFX_IDP_SQL_LOCK_MODE_NOT_SUPPORTED     0xF294
#define AFX_IDP_SQL_DATA_TRUNCATED              0xF295
#define AFX_IDP_SQL_ROW_FETCH                   0xF296
#define AFX_IDP_SQL_INCORRECT_ODBC              0xF297
#define AFX_IDP_SQL_UPDATE_DELETE_FAILED        0xF298
#define AFX_IDP_SQL_DYNAMIC_CURSOR_NOT_SUPPORTED    0xF299

// DAO Database errors / prompt strings
#ifndef RC_INVOKED      // code only
#define AFX_IDP_DAO_FIRST                       0xF2A0
#endif //!RC_INVOKED
#define AFX_IDP_DAO_ENGINE_INITIALIZATION       0xF2A0
#define AFX_IDP_DAO_DFX_BIND                    0xF2A1
#define AFX_IDP_DAO_OBJECT_NOT_OPEN             0xF2A2

// ICDAORecordset::GetRows Errors
//  These are not placed in DAO Errors collection
//  and must be handled directly by MFC.
#define AFX_IDP_DAO_ROWTOOSHORT                 0xF2A3
#define AFX_IDP_DAO_BADBINDINFO                 0xF2A4
#define AFX_IDP_DAO_COLUMNUNAVAILABLE           0xF2A5

/////////////////////////////////////////////////////////////////////////////
// Strings for ISAPI support

#define AFX_IDS_HTTP_TITLE    0xF2D1
#define AFX_IDS_HTTP_NO_TEXT   0xF2D2
#define AFX_IDS_HTTP_BAD_REQUEST  0xF2D3
#define AFX_IDS_HTTP_AUTH_REQUIRED  0xF2D4
#define AFX_IDS_HTTP_FORBIDDEN   0xF2D5
#define AFX_IDS_HTTP_NOT_FOUND   0xF2D6
#define AFX_IDS_HTTP_SERVER_ERROR  0xF2D7
#define AFX_IDS_HTTP_NOT_IMPLEMENTED 0xF2D8


/////////////////////////////////////////////////////////////////////////////
// AFX implementation - control IDs (AFX_IDC)

// Parts of dialogs
#define AFX_IDC_LISTBOX                 100
#define AFX_IDC_CHANGE                  101

// for print dialog
#define AFX_IDC_PRINT_DOCNAME           201
#define AFX_IDC_PRINT_PRINTERNAME       202
#define AFX_IDC_PRINT_PORTNAME          203
#define AFX_IDC_PRINT_PAGENUM           204

// Property Sheet control id's (determined with Spy++)
#define ID_APPLY_NOW                    0x3021
#define ID_WIZBACK                      0x3023
#define ID_WIZNEXT                      0x3024
#define ID_WIZFINISH                    0x3025
#define AFX_IDC_TAB_CONTROL             0x3020

/////////////////////////////////////////////////////////////////////////////
// IDRs for standard components

#ifndef RC_INVOKED  // code only
// These are really COMMDLG dialogs, so there usually isn't a resource
// for them, but these IDs are used as help IDs.
#define AFX_IDD_FILEOPEN                28676
#define AFX_IDD_FILESAVE                28677
#define AFX_IDD_FONT                    28678
#define AFX_IDD_COLOR                   28679
#define AFX_IDD_PRINT                   28680
#define AFX_IDD_PRINTSETUP              28681
#define AFX_IDD_FIND                    28682
#define AFX_IDD_REPLACE                 28683
#endif //!RC_INVOKED

// Standard dialogs app should leave alone (0x7801->)
#define AFX_IDD_NEWTYPEDLG              30721
#define AFX_IDD_PRINTDLG                30722
#define AFX_IDD_PREVIEW_TOOLBAR         30723
#ifdef _MAC
#define AFX_IDD_PREVIEW_SHORTTOOLBAR    30731
#endif

// Dialogs defined for OLE2UI library
#define AFX_IDD_INSERTOBJECT            30724
#define AFX_IDD_CHANGEICON              30725
#define AFX_IDD_CONVERT                 30726
#define AFX_IDD_PASTESPECIAL            30727
#define AFX_IDD_EDITLINKS               30728
#define AFX_IDD_FILEBROWSE              30729
#define AFX_IDD_BUSY                    30730

#define AFX_IDD_OBJECTPROPERTIES        30732
#define AFX_IDD_CHANGESOURCE            30733

// Standard cursors (0x7901->)
 // AFX_IDC = Cursor resources
#define AFX_IDC_CONTEXTHELP             30977       // context sensitive help
#define AFX_IDC_MAGNIFY                 30978       // print preview zoom
#define AFX_IDC_SMALLARROWS             30979       // splitter
#define AFX_IDC_HSPLITBAR               30980       // splitter
#define AFX_IDC_VSPLITBAR               30981       // splitter
#define AFX_IDC_NODROPCRSR              30982       // No Drop Cursor
#define AFX_IDC_TRACKNWSE               30983       // tracker
#define AFX_IDC_TRACKNESW               30984       // tracker
#define AFX_IDC_TRACKNS                 30985       // tracker
#define AFX_IDC_TRACKWE                 30986       // tracker
#define AFX_IDC_TRACK4WAY               30987       // tracker
#define AFX_IDC_MOVE4WAY                30988       // resize bar (server only)

// Mini frame window bitmap ID
#define AFX_IDB_MINIFRAME_MENU          30994

// CheckListBox checks bitmap ID
#define AFX_IDB_CHECKLISTBOX_NT         30995
#define AFX_IDB_CHECKLISTBOX_95         30996

// AFX standard accelerator resources
#define AFX_IDR_PREVIEW_ACCEL           30997

// AFX standard ICON IDs (for MFC V1 apps) (0x7A01->)
#define AFX_IDI_STD_MDIFRAME            31233
#define AFX_IDI_STD_FRAME               31234

/////////////////////////////////////////////////////////////////////////////
// AFX OLE control implementation - control IDs (AFX_IDC)

// Font property page
#define AFX_IDC_FONTPROP                1000
#define AFX_IDC_FONTNAMES               1001
#define AFX_IDC_FONTSTYLES              1002
#define AFX_IDC_FONTSIZES               1003
#define AFX_IDC_STRIKEOUT               1004
#define AFX_IDC_UNDERLINE               1005
#define AFX_IDC_SAMPLEBOX               1006

// Color property page
#define AFX_IDC_COLOR_BLACK             1100
#define AFX_IDC_COLOR_WHITE             1101
#define AFX_IDC_COLOR_RED               1102
#define AFX_IDC_COLOR_GREEN             1103
#define AFX_IDC_COLOR_BLUE              1104
#define AFX_IDC_COLOR_YELLOW            1105
#define AFX_IDC_COLOR_MAGENTA           1106
#define AFX_IDC_COLOR_CYAN              1107
#define AFX_IDC_COLOR_GRAY              1108
#define AFX_IDC_COLOR_LIGHTGRAY         1109
#define AFX_IDC_COLOR_DARKRED           1110
#define AFX_IDC_COLOR_DARKGREEN         1111
#define AFX_IDC_COLOR_DARKBLUE          1112
#define AFX_IDC_COLOR_LIGHTBROWN        1113
#define AFX_IDC_COLOR_DARKMAGENTA       1114
#define AFX_IDC_COLOR_DARKCYAN          1115
#define AFX_IDC_COLORPROP               1116
#define AFX_IDC_SYSTEMCOLORS            1117

// Picture porperty page
#define AFX_IDC_PROPNAME                1201
#define AFX_IDC_PICTURE                 1202
#define AFX_IDC_BROWSE                  1203
#define AFX_IDC_CLEAR                   1204

/////////////////////////////////////////////////////////////////////////////
// IDRs for OLE control standard components

// Standard propery page dialogs app should leave alone (0x7E01->)
#define AFX_IDD_PROPPAGE_COLOR         32257
#define AFX_IDD_PROPPAGE_FONT          32258
#define AFX_IDD_PROPPAGE_PICTURE       32259

#define AFX_IDB_TRUETYPE               32384

/////////////////////////////////////////////////////////////////////////////
// Standard OLE control strings

// OLE Control page strings
#define AFX_IDS_PROPPAGE_UNKNOWN        0xFE01
#define AFX_IDS_COLOR_DESKTOP           0xFE04
#define AFX_IDS_COLOR_APPWORKSPACE      0xFE05
#define AFX_IDS_COLOR_WNDBACKGND        0xFE06
#define AFX_IDS_COLOR_WNDTEXT           0xFE07
#define AFX_IDS_COLOR_MENUBAR           0xFE08
#define AFX_IDS_COLOR_MENUTEXT          0xFE09
#define AFX_IDS_COLOR_ACTIVEBAR         0xFE0A
#define AFX_IDS_COLOR_INACTIVEBAR       0xFE0B
#define AFX_IDS_COLOR_ACTIVETEXT        0xFE0C
#define AFX_IDS_COLOR_INACTIVETEXT      0xFE0D
#define AFX_IDS_COLOR_ACTIVEBORDER      0xFE0E
#define AFX_IDS_COLOR_INACTIVEBORDER    0xFE0F
#define AFX_IDS_COLOR_WNDFRAME          0xFE10
#define AFX_IDS_COLOR_SCROLLBARS        0xFE11
#define AFX_IDS_COLOR_BTNFACE           0xFE12
#define AFX_IDS_COLOR_BTNSHADOW         0xFE13
#define AFX_IDS_COLOR_BTNTEXT           0xFE14
#define AFX_IDS_COLOR_BTNHIGHLIGHT      0xFE15
#define AFX_IDS_COLOR_DISABLEDTEXT      0xFE16
#define AFX_IDS_COLOR_HIGHLIGHT         0xFE17
#define AFX_IDS_COLOR_HIGHLIGHTTEXT     0xFE18
#define AFX_IDS_REGULAR                 0xFE19
#define AFX_IDS_BOLD                    0xFE1A
#define AFX_IDS_ITALIC                  0xFE1B
#define AFX_IDS_BOLDITALIC              0xFE1C
#define AFX_IDS_SAMPLETEXT              0xFE1D
#define AFX_IDS_DISPLAYSTRING_FONT      0xFE1E
#define AFX_IDS_DISPLAYSTRING_COLOR     0xFE1F
#define AFX_IDS_DISPLAYSTRING_PICTURE   0xFE20
#define AFX_IDS_PICTUREFILTER           0xFE21
#define AFX_IDS_PICTYPE_UNKNOWN         0xFE22
#define AFX_IDS_PICTYPE_NONE            0xFE23
#define AFX_IDS_PICTYPE_BITMAP          0xFE24
#define AFX_IDS_PICTYPE_METAFILE        0xFE25
#define AFX_IDS_PICTYPE_ICON            0xFE26
#define AFX_IDS_COLOR_PPG               0xFE28
#define AFX_IDS_COLOR_PPG_CAPTION       0xFE29
#define AFX_IDS_FONT_PPG                0xFE2A
#define AFX_IDS_FONT_PPG_CAPTION        0xFE2B
#define AFX_IDS_PICTURE_PPG             0xFE2C
#define AFX_IDS_PICTURE_PPG_CAPTION     0xFE2D
#define AFX_IDS_PICTUREBROWSETITLE      0xFE30
#define AFX_IDS_BORDERSTYLE_0           0xFE31
#define AFX_IDS_BORDERSTYLE_1           0xFE32

// OLE Control verb names
#define AFX_IDS_VERB_EDIT               0xFE40
#define AFX_IDS_VERB_PROPERTIES         0xFE41

// OLE Control internal error messages
#define AFX_IDP_PICTURECANTOPEN         0xFE83
#define AFX_IDP_PICTURECANTLOAD         0xFE84
#define AFX_IDP_PICTURETOOLARGE         0xFE85
#define AFX_IDP_PICTUREREADFAILED       0xFE86

// Standard OLE Control error strings
#define AFX_IDP_E_ILLEGALFUNCTIONCALL       0xFEA0
#define AFX_IDP_E_OVERFLOW                  0xFEA1
#define AFX_IDP_E_OUTOFMEMORY               0xFEA2
#define AFX_IDP_E_DIVISIONBYZERO            0xFEA3
#define AFX_IDP_E_OUTOFSTRINGSPACE          0xFEA4
#define AFX_IDP_E_OUTOFSTACKSPACE           0xFEA5
#define AFX_IDP_E_BADFILENAMEORNUMBER       0xFEA6
#define AFX_IDP_E_FILENOTFOUND              0xFEA7
#define AFX_IDP_E_BADFILEMODE               0xFEA8
#define AFX_IDP_E_FILEALREADYOPEN           0xFEA9
#define AFX_IDP_E_DEVICEIOERROR             0xFEAA
#define AFX_IDP_E_FILEALREADYEXISTS         0xFEAB
#define AFX_IDP_E_BADRECORDLENGTH           0xFEAC
#define AFX_IDP_E_DISKFULL                  0xFEAD
#define AFX_IDP_E_BADRECORDNUMBER           0xFEAE
#define AFX_IDP_E_BADFILENAME               0xFEAF
#define AFX_IDP_E_TOOMANYFILES              0xFEB0
#define AFX_IDP_E_DEVICEUNAVAILABLE         0xFEB1
#define AFX_IDP_E_PERMISSIONDENIED          0xFEB2
#define AFX_IDP_E_DISKNOTREADY              0xFEB3
#define AFX_IDP_E_PATHFILEACCESSERROR       0xFEB4
#define AFX_IDP_E_PATHNOTFOUND              0xFEB5
#define AFX_IDP_E_INVALIDPATTERNSTRING      0xFEB6
#define AFX_IDP_E_INVALIDUSEOFNULL          0xFEB7
#define AFX_IDP_E_INVALIDFILEFORMAT         0xFEB8
#define AFX_IDP_E_INVALIDPROPERTYVALUE      0xFEB9
#define AFX_IDP_E_INVALIDPROPERTYARRAYINDEX 0xFEBA
#define AFX_IDP_E_SETNOTSUPPORTEDATRUNTIME  0xFEBB
#define AFX_IDP_E_SETNOTSUPPORTED           0xFEBC
#define AFX_IDP_E_NEEDPROPERTYARRAYINDEX    0xFEBD
#define AFX_IDP_E_SETNOTPERMITTED           0xFEBE
#define AFX_IDP_E_GETNOTSUPPORTEDATRUNTIME  0xFEBF
#define AFX_IDP_E_GETNOTSUPPORTED           0xFEC0
#define AFX_IDP_E_PROPERTYNOTFOUND          0xFEC1
#define AFX_IDP_E_INVALIDCLIPBOARDFORMAT    0xFEC2
#define AFX_IDP_E_INVALIDPICTURE            0xFEC3
#define AFX_IDP_E_PRINTERERROR              0xFEC4
#define AFX_IDP_E_CANTSAVEFILETOTEMP        0xFEC5
#define AFX_IDP_E_SEARCHTEXTNOTFOUND        0xFEC6
#define AFX_IDP_E_REPLACEMENTSTOOLONG       0xFEC7





#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, on)
#endif

#endif //__AFXRES_H__

/////////////////////////////////////////////////////////////////////////////
//
// CmnHdr.h
// Purpose:  Common header file containing macros and definitions used
// throughout all applications in the book

// Disable warnings so that code will compile cleanly using warning level 4.

// nonstandard extension 'single line comment' was used
#pragma warning(disable: 4001)
// nonstandard extension used : nameless struc/union
#pragma warning(disable: 4201)
// nonstandard extension used : bit field types other than int
#pragma warning(disable: 4214)
// Note:  creating pre-compiled header
#pragma warning(disable: 4699)
// unreferenced inline function has been removed
#pragma warning(disable: 4514)
// unreferenced formal parameter
#pragma warning(disable: 4100)
// indirection to slightly different base types
#pragma warning(disable: 4057)
// named type definition in parentheses
#pragma warning(disable: 4115)
// nonstandard extension used : benign typedef redefinition
#pragma warning(disable: 4209)

// Windows Version build option
#define _WIN32_WINNT 0x0400
// Strict build option: Force all EXE/DLL to use STRICT type checking
#define STRICT

// CPU Portability Macros

// If no CPU platform was specified, default to the current platform
#if !defined(_PPC_) && !defined(_ALPHA_) && !defined(_MIPS_) && !defined(_X86_)
 #if defined(_M_IX86_)
    #define _X86_
   #endif
   #if defined(_M_MRX000)
    #define _MIPS)
   #endif
   #if defined(_M_ALPHA)
    #define _ALPHA_
   #endif
   #if defined(_M_PPC)
    #define _PPC_
   #endif
#endif

// Unicode build option

// If you are not compiling for an x86 CPU, you always compile using Unicode.
#ifndef _X86_
 #define UNICODE
#endif

// To compile using Unicode on the x86 CPU, uncomment the line below:
// #define UNICODE

// When using Unicode win32 functions, use Unicode C-Runtime functions too.
#ifdef UNICODE
 #define _UNICODE
#endif

// chDIMOF Macro

// This macro evaluates to the number of elements in an array.
#define chDIMOF(Array) (sizeof(Array) / sizeof(Array[0]))

// chBEGINTHREADEX Macro

// Create a chBEGINTHREADEX macro that calls the C run-time's
// _beginthreadex function.  The C run-time library doesn't
// want to have any reliance on Win32 data types such as HANDLE.
// This means that a Win32 progammer needs to case the return value
// to a HANDLE, which is inconvenient. This macro will perform the
// casting for you:
typedef unsigned (_stdcall *PTHREAD_START) (void *);
 #define chBEGINTHREADEX(lpsa, cbStack, lpStartAddr, \
    lpvthreadParm, fdwCreate, lpIDThread)            \
      ((HANDLE)_beginthreadex                          \
         (                                             \
       (void *) (lpsa), (unsigned) (cbStack),        \
         (PTHREAD_START) (lpStartAddr),                \
         (void *) (lpvThreadParm),                     \
         (unsigned) (fdwCreate),                       \
         (unsigned *) (lpIDThread))                    \
         )

// Assert/Verify macros
#define chFAIL(szMSG)                                              \
{                                                                  \
 MessageBox(GetActiveWindow(), szMSG, _TEXT("Assertion Failed"), \
   MB_OK | MB_ICONERROR);                                          \
   DebugBreak();                                                   \
}

// Put up an assertion failure message box.
#define chASSERTFAIL(file, line, expr)               \
{                                                    \
 TCHAR sz[128];                                    \
   wsprintf(sz, _TEXT("File %hs, line %d : %hs"),    \
    file, line, expr);                             \
   chFAIL(sz);                                       \
}

// Put up a message box if an assertion filas in a debug build.
#ifdef _DEBUG
#define chASSERT(x) if (!(x))    \
 chASSERTFAIL(_FILE_, _LINE_, #x)
#else
#define chASSERT(x)
#endif

// Assert in debug builds. Don't remove the code in retail builds.
#ifdef _DEBUG
#define chVERIFY(x) chASSERT(x)
#else
#define chVERIFY(x) (x)
#endif

// chHANDLE_DLGMSG Macro

// The normal HANDLE_MSG macro in WINDOWSX.H does not work
// properly for dialog boxes because DlgProcs return a BOOL
// instead of an LRESULT (like WndProcs). This chHANDLE_DLGMSG
// macro will correct the problem:
#define chHANDLE_DLGMSG(hwnd, message, fn)                                   \
  case (message):                                                            \
    return (SetDlgMsgResult(hwnd, uMsg, HANDLE_##message((hwnd), (wParam), (lParam), (fn))))

// Quick MesageBox Macro
#define chMB(s)              \
 {                                                     \
   TCHAR szTMP[128];                                     \
   GetModuleFileName(NULL, szTMP, chDIMOF(szTMP));       \
   MessageBox(GetActiveWindow(), s, szTMP, MB_OK);       \
   }

// Zero Variable Macro
// Zero out a structure. If fInitsize is TRUE, initialize the first
// int to the size of the structure. Many structures like WNDCLASSEX and
// STARUPINFO require that their first member be set to the size of the
// structure itself.
#define chINITSTRUCT(structure, fInitSize)                     \
 (ZeroMemory(&(structure), sizeof(structure)),               \
   fInitSize ? (*(int*) &(structure) = sizeof(structure)) : 0)

// Dialog Box Icon Setting Macro
// The call to SetClassLong is for Windows NT 3.51 or less.
// The WM_SETICON messages are for Windows NT 4.0 and Win 95.
#define chSETDLGICONS(hwnd, idiLarge, idiSmall)                 \
 {                                                            \
    OSVERSIONINFO VerInfo;                                    \
      chINITSTRUCT(VerInfo, TRUE);                              \
      GetVersionEx(&VerInfo);                                   \
      if ((VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) &&    \
       (VerInfo.dwMajorVersion <= 3 &&                        \
         VerInfo.dwMinorVersion <= 51))                         \
         {                                                      \
         SetClassLong(hwnd, GCL_HICON, (LONG)                   \
          LoadIcon(GetWindowInstance(hwnd),                   \
            MAKEINTRESOURCE(idiLarge)));                        \
         }                                                      \
      else                                                      \
       {                                                      \
         SendMessage(hwnd, WM_SETICON, TRUE, (LPARAM)           \
          LoadIcon(GetWindowInstance(hwnd),                   \
            MAKEINTRESOURCE(idiLarge)));                        \
         SendMessage(hwnd, WM_SETICON, FALSE, (LPARAM)          \
          LoadIcon(GetWindowInstance(hwnd),                   \
            MAKEINTRESOURCE(idiSmall)));                        \
         }                                                      \
   }

// UNICODE check Macro
#ifdef UNICODE
#define chWARNIFUNICODEUNDERWIN95()                                         \
 if (GetWindowsDirectoryW(NULL, 0) <= 0)                                  \
    MessageBoxA(NULL, "This operating system does not support UniCode.",  \
      NULL, MB_OK)
#else
#define chWANIFUNICODEUNDERWIN95()
#endif

// Pragma message helper macro
// When the compiler sees a line like:  #pragma chMSG(Fix this later)
// it will output a line like this: C:\Document=AdvWin.....fix this later.
// you can easily jump directly to this line and examine the surrounding code.
#define chSTR(x) #x
#define chSTR2(x) chSTR(x)
#define chMSG(desc)           \
 message(_FILE_ "(" chSTR2(_LINE_) "):" #desc)

#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <dir.h>
#include <alloc.h>
#include <string.h>

void main(int argc, char **argv)
 {
   void delete_tree(void);

   char buffer[128];

   char drive[MAXDRIVE], directory[MAXDIR], filename[MAXFILE], ext[MAXEXT];

   if (argc < 2)
     {
       printf ("Syntax error\n");
       exit(0);
     }


   fnsplit (argv[1], drive, directory, filename, ext);
   getcwd (buffer, sizeof(buffer));

   if (drive[0] == NULL)
     {
       fnsplit (buffer, drive, directory, filename, ext);
       strcpy (buffer, directory);
       strcat (buffer, filename);
       strcat (buffer, ext);
     }
   else
     { 
       printf ("Do not specify drive letter\n");
       exit (1);
     }

   if (strcmpi(buffer, argv[1]) == 0)
     {
       printf ("Cannot delete current directory\n");
       exit (1);
     }
    
   getcwd (directory, 64);

   if (chdir (argv[1]))
     printf ("Invalid directory %s\n", argv[1]);
   else
     delete_tree(); 

   chdir (directory);
   rmdir (argv[1]);
 }

union REGS inregs, outregs;
struct SREGS segs;

void delete_tree(void)
 {
   struct ffblk fileinfo;
   int result;
   char far *farbuff;
   unsigned dta_seg, dta_ofs;

   result = findfirst("*.*", &fileinfo, 16);
   inregs.h.ah = 0x2f;
   intdosx (&inregs, &outregs, &segs);
   dta_seg = segs.es;
   dta_ofs = outregs.x.bx;

   while (! result)
    {
      if ((fileinfo.ff_attrib & 16) && (fileinfo.ff_name[0] != '.'))
 {
    inregs.h.ah = 0x1A;
    inregs.x.dx = FP_SEG(farbuff);
    segread(&segs);
    intdosx (&inregs, &outregs, &segs);
  
    chdir (fileinfo.ff_name);
    delete_tree();
    chdir ("..");

    inregs.h.ah = 0x1A;
    inregs.x.dx = dta_ofs;
    segs.ds = dta_seg;
    rmdir (fileinfo.ff_name);
 }
      else if (fileinfo.ff_name[0] != '.')
 {
    remove (fileinfo.ff_name);
 }
   
      result = findnext (&fileinfo);
    }
 }
//
// DirWalk.rc
//

#include "Resource.h"

#define APSTUDIO_READONLY_SYMBOLS

// Generated from the TEXTINCLUDE 2 resource.
#include "afxres.h"

#undef APSTUDIO_READONLY_SYMBOLS

// U.S. English resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif // _WIN32

// Icon
// Icon with the lowest ID value placed first to ensure
// application icon remains consistent on all systems.
IDI_DIRWALK ICON DISCARDABLE "DirWalk.Ico"

// Dialog
IDD_DIRWALK DIALOG DISCARDABLE 10, 18, 250, 250
STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP |
  WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Directory Walk"
FONT 8, "System"
BEGIN
 LISTBOX  IDC_TREE,0,0,0,0,NOT LBS_NOTIFY |
       LBX_NOINTEGRALHEIGHT | NOT WS_BORDER |
             WS_VSCROLL | WS_HSCROLL | WS_GROUP |
             WS_TABSTOP
END

#ifdef APSTUDIO_INVOKED

// Textinclude
1 TEXTINCLUDE DISCARDABLE
BEGIN
 "Resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE
BEGIN
 "#include ""afxres.h""\r\n"
   "\0"
END

3 TEXTINCLUDE DISCARDABLE
BEGIN
 "\r\n"
   "\0"
END

#endif  // APSTUDIO_INVOKED

#endif // U.S. English Resources

#ifndef APSTUDIO_INVOKED

#endif  // not APSTUDIO_INVOKED

//
// Resource.h
//

#define IDI_DIRWALK  100
#define IDC_TREE   101
#define IDD_DIRWALK 102

// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1995 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.

// winres.h - Windows resource definitions
//  extracted from WINUSER.H and COMMCTRL.H

#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, off)
#endif

#define VS_VERSION_INFO     1

#ifdef APSTUDIO_INVOKED
#define APSTUDIO_HIDDEN_SYMBOLS // Ignore following symbols
#endif

#ifndef WINVER
#define WINVER 0x0400   // default to Windows Version 4.0
#endif

#define OBM_CLOSE       32754
#define OBM_UPARROW     32753
#define OBM_DNARROW     32752
#define OBM_RGARROW     32751
#define OBM_LFARROW     32750
#define OBM_REDUCE      32749
#define OBM_ZOOM        32748
#define OBM_RESTORE     32747
#define OBM_REDUCED     32746
#define OBM_ZOOMD       32745
#define OBM_RESTORED    32744
#define OBM_UPARROWD    32743
#define OBM_DNARROWD    32742
#define OBM_RGARROWD    32741
#define OBM_LFARROWD    32740
#define OBM_MNARROW     32739
#define OBM_COMBO       32738
#define OBM_UPARROWI    32737
#define OBM_DNARROWI    32736
#define OBM_RGARROWI    32735
#define OBM_LFARROWI    32734
#define OBM_OLD_CLOSE   32767
#define OBM_SIZE        32766
#define OBM_OLD_UPARROW 32765
#define OBM_OLD_DNARROW 32764
#define OBM_OLD_RGARROW 32763
#define OBM_OLD_LFARROW 32762
#define OBM_BTSIZE      32761
#define OBM_CHECK       32760
#define OBM_CHECKBOXES  32759
#define OBM_BTNCORNERS  32758
#define OBM_OLD_REDUCE  32757
#define OBM_OLD_ZOOM    32756
#define OBM_OLD_RESTORE 32755
#define OCR_NORMAL      32512
#define OCR_IBEAM       32513
#define OCR_WAIT        32514
#define OCR_CROSS       32515
#define OCR_UP          32516
#define OCR_SIZE        32640
#define OCR_ICON        32641
#define OCR_SIZENWSE    32642
#define OCR_SIZENESW    32643
#define OCR_SIZEWE      32644
#define OCR_SIZENS      32645
#define OCR_SIZEALL     32646
#define OCR_ICOCUR      32647
#define OCR_NO          32648
#define OIC_SAMPLE      32512
#define OIC_HAND        32513
#define OIC_QUES        32514
#define OIC_BANG        32515
#define OIC_NOTE        32516

#if (WINVER >= 0x0400)
#define OCR_APPSTARTING     32650
#define OIC_WINLOGO         32517
#define OIC_WARNING         OIC_BANG
#define OIC_ERROR           OIC_HAND
#define OIC_INFORMATION     OIC_NOTE
#endif

#define WS_OVERLAPPED   0x00000000L
#define WS_POPUP        0x80000000L
#define WS_CHILD        0x40000000L
#define WS_CLIPSIBLINGS 0x04000000L
#define WS_CLIPCHILDREN 0x02000000L
#define WS_VISIBLE      0x10000000L
#define WS_DISABLED     0x08000000L
#define WS_MINIMIZE     0x20000000L
#define WS_MAXIMIZE     0x01000000L
#define WS_CAPTION      0x00C00000L
#define WS_BORDER       0x00800000L
#define WS_DLGFRAME     0x00400000L
#define WS_VSCROLL      0x00200000L
#define WS_HSCROLL      0x00100000L
#define WS_SYSMENU      0x00080000L
#define WS_THICKFRAME   0x00040000L
#define WS_MINIMIZEBOX  0x00020000L
#define WS_MAXIMIZEBOX  0x00010000L
#define WS_GROUP        0x00020000L
#define WS_TABSTOP      0x00010000L

// other aliases
#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
#define WS_POPUPWINDOW  (WS_POPUP | WS_BORDER | WS_SYSMENU)
#define WS_CHILDWINDOW  (WS_CHILD)
#define WS_TILED        WS_OVERLAPPED
#define WS_ICONIC       WS_MINIMIZE
#define WS_SIZEBOX      WS_THICKFRAME
#define WS_TILEDWINDOW  WS_OVERLAPPEDWINDOW

#define WS_EX_DLGMODALFRAME     0x00000001L
#define WS_EX_NOPARENTNOTIFY    0x00000004L
#define WS_EX_TOPMOST           0x00000008L
#define WS_EX_ACCEPTFILES       0x00000010L
#define WS_EX_TRANSPARENT       0x00000020L
#if (WINVER >= 0x0400)
#define WS_EX_MDICHILD          0x00000040L
#define WS_EX_TOOLWINDOW        0x00000080L
#define WS_EX_WINDOWEDGE        0x00000100L
#define WS_EX_CLIENTEDGE        0x00000200L
#define WS_EX_CONTEXTHELP       0x00000400L

#define WS_EX_RIGHT             0x00001000L
#define WS_EX_LEFT              0x00000000L
#define WS_EX_RTLREADING        0x00002000L
#define WS_EX_LTRREADING        0x00000000L
#define WS_EX_LEFTSCROLLBAR     0x00004000L
#define WS_EX_RIGHTSCROLLBAR    0x00000000L

#define WS_EX_CONTROLPARENT     0x00010000L
#define WS_EX_STATICEDGE        0x00020000L
#define WS_EX_APPWINDOW         0x00040000L

#define WS_EX_OVERLAPPEDWINDOW  (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)
#define WS_EX_PALETTEWINDOW     (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST)
#endif

#define VK_LBUTTON      0x01
#define VK_RBUTTON      0x02
#define VK_CANCEL       0x03
#define VK_MBUTTON      0x04
#define VK_BACK         0x08
#define VK_TAB          0x09
#define VK_CLEAR        0x0C
#define VK_RETURN       0x0D
#define VK_SHIFT        0x10
#define VK_CONTROL      0x11
#define VK_MENU         0x12
#define VK_PAUSE        0x13
#define VK_CAPITAL      0x14
#define VK_ESCAPE       0x1B
#define VK_SPACE        0x20
#define VK_PRIOR        0x21
#define VK_NEXT         0x22
#define VK_END          0x23
#define VK_HOME         0x24
#define VK_LEFT         0x25
#define VK_UP           0x26
#define VK_RIGHT        0x27
#define VK_DOWN         0x28
#define VK_SELECT       0x29
#define VK_PRINT        0x2A
#define VK_EXECUTE      0x2B
#define VK_SNAPSHOT     0x2C
#define VK_INSERT       0x2D
#define VK_DELETE       0x2E
#define VK_HELP         0x2F
#define VK_NUMPAD0      0x60
#define VK_NUMPAD1      0x61
#define VK_NUMPAD2      0x62
#define VK_NUMPAD3      0x63
#define VK_NUMPAD4      0x64
#define VK_NUMPAD5      0x65
#define VK_NUMPAD6      0x66
#define VK_NUMPAD7      0x67
#define VK_NUMPAD8      0x68
#define VK_NUMPAD9      0x69
#define VK_MULTIPLY     0x6A
#define VK_ADD          0x6B
#define VK_SEPARATOR    0x6C
#define VK_SUBTRACT     0x6D
#define VK_DECIMAL      0x6E
#define VK_DIVIDE       0x6F
#define VK_F1           0x70
#define VK_F2           0x71
#define VK_F3           0x72
#define VK_F4           0x73
#define VK_F5           0x74
#define VK_F6           0x75
#define VK_F7           0x76
#define VK_F8           0x77
#define VK_F9           0x78
#define VK_F10          0x79
#define VK_F11          0x7A
#define VK_F12          0x7B
#define VK_F13          0x7C
#define VK_F14          0x7D
#define VK_F15          0x7E
#define VK_F16          0x7F
#define VK_F17          0x80
#define VK_F18          0x81
#define VK_F19          0x82
#define VK_F20          0x83
#define VK_F21          0x84
#define VK_F22          0x85
#define VK_F23          0x86
#define VK_F24          0x87
#define VK_NUMLOCK      0x90
#define VK_SCROLL       0x91

#define VK_LSHIFT       0xA0
#define VK_RSHIFT       0xA1
#define VK_LCONTROL     0xA2
#define VK_RCONTROL     0xA3
#define VK_LMENU        0xA4
#define VK_RMENU        0xA5

#if (WINVER >= 0x0400)
#define VK_PROCESSKEY   0xE5
#endif /* WINVER >= 0x0400 */

#define VK_ATTN         0xF6
#define VK_CRSEL        0xF7
#define VK_EXSEL        0xF8
#define VK_EREOF        0xF9
#define VK_PLAY         0xFA
#define VK_ZOOM         0xFB
#define VK_NONAME       0xFC
#define VK_PA1          0xFD
#define VK_OEM_CLEAR    0xFE

#define SC_SIZE         0xF000
#define SC_MOVE         0xF010
#define SC_MINIMIZE     0xF020
#define SC_MAXIMIZE     0xF030
#define SC_NEXTWINDOW   0xF040
#define SC_PREVWINDOW   0xF050
#define SC_CLOSE        0xF060
#define SC_VSCROLL      0xF070
#define SC_HSCROLL      0xF080
#define SC_MOUSEMENU    0xF090
#define SC_KEYMENU      0xF100
#define SC_ARRANGE      0xF110
#define SC_RESTORE      0xF120
#define SC_TASKLIST     0xF130
#define SC_SCREENSAVE   0xF140
#define SC_HOTKEY       0xF150

#define DS_ABSALIGN     0x01L
#define DS_SYSMODAL     0x02L
#define DS_LOCALEDIT    0x20L
#define DS_SETFONT      0x40L
#define DS_MODALFRAME   0x80L
#define DS_NOIDLEMSG    0x100L
#define DS_SETFOREGROUND 0x200L

#ifdef _MAC
#define DS_WINDOWSUI    0x8000L
#endif

#if (WINVER >= 0x0400)
#define DS_3DLOOK       0x0004L
#define DS_FIXEDSYS     0x0008L
#define DS_NOFAILCREATE 0x0010L
#define DS_CONTROL      0x0400L
#define DS_CENTER       0x0800L
#define DS_CENTERMOUSE  0x1000L
#define DS_CONTEXTHELP  0x2000L
#endif

#define SS_LEFT         0x00000000L
#define SS_CENTER       0x00000001L
#define SS_RIGHT        0x00000002L
#define SS_ICON         0x00000003L
#define SS_BLACKRECT    0x00000004L
#define SS_GRAYRECT     0x00000005L
#define SS_WHITERECT    0x00000006L
#define SS_BLACKFRAME   0x00000007L
#define SS_GRAYFRAME    0x00000008L
#define SS_WHITEFRAME   0x00000009L
#define SS_SIMPLE       0x0000000BL
#define SS_LEFTNOWORDWRAP 0x0000000CL
#define SS_BITMAP           0x0000000EL

#if (WINVER >= 0x0400)
#define SS_OWNERDRAW        0x0000000DL
#define SS_ENHMETAFILE      0x0000000FL
#define SS_ETCHEDHORZ       0x00000010L
#define SS_ETCHEDVERT       0x00000011L
#define SS_ETCHEDFRAME      0x00000012L
#endif

#define SS_NOPREFIX     0x00000080L
#if (WINVER >= 0x0400)
#define SS_NOTIFY           0x00000100L
#endif
#define SS_CENTERIMAGE      0x00000200L
#if (WINVER >= 0x0400)
#define SS_RIGHTJUST        0x00000400L
#define SS_REALSIZEIMAGE    0x00000800L
#define SS_SUNKEN           0x00001000L
#endif

#define BS_PUSHBUTTON   0x00000000L
#define BS_DEFPUSHBUTTON 0x00000001L
#define BS_CHECKBOX     0x00000002L
#define BS_AUTOCHECKBOX 0x00000003L
#define BS_RADIOBUTTON  0x00000004L
#define BS_3STATE       0x00000005L
#define BS_AUTO3STATE   0x00000006L
#define BS_GROUPBOX     0x00000007L
#define BS_USERBUTTON   0x00000008L
#define BS_AUTORADIOBUTTON  0x00000009L
#define BS_OWNERDRAW        0x0000000BL
#define BS_LEFTTEXT     0x00000020L
#if (WINVER >= 0x0400)
#define BS_TEXT             0x00000000L
#define BS_ICON             0x00000040L
#define BS_BITMAP           0x00000080L
#define BS_LEFT             0x00000100L
#define BS_RIGHT            0x00000200L
#define BS_CENTER           0x00000300L
#define BS_TOP              0x00000400L
#define BS_BOTTOM           0x00000800L
#define BS_VCENTER          0x00000C00L
#define BS_PUSHLIKE         0x00001000L
#define BS_MULTILINE        0x00002000L
#define BS_NOTIFY           0x00004000L
#define BS_FLAT             0x00008000L
#define BS_RIGHTBUTTON      BS_LEFTTEXT
#endif

#define ES_LEFT         0x00000000L
#define ES_CENTER       0x00000001L
#define ES_RIGHT        0x00000002L
#define ES_MULTILINE    0x00000004L
#define ES_UPPERCASE    0x00000008L
#define ES_LOWERCASE    0x00000010L
#define ES_PASSWORD     0x00000020L
#define ES_AUTOVSCROLL  0x00000040L
#define ES_AUTOHSCROLL  0x00000080L
#define ES_NOHIDESEL    0x00000100L
#define ES_OEMCONVERT   0x00000400L
#define ES_READONLY     0x00000800L
#define ES_WANTRETURN   0x00001000L
#if (WINVER >= 0x0400)
#define ES_NUMBER       0x2000L
#endif

#define SBS_HORZ        0x0000L
#define SBS_VERT        0x0001L
#define SBS_TOPALIGN    0x0002L
#define SBS_LEFTALIGN   0x0002L
#define SBS_BOTTOMALIGN 0x0004L
#define SBS_RIGHTALIGN  0x0004L
#define SBS_SIZEBOXTOPLEFTALIGN 0x0002L
#define SBS_SIZEBOXBOTTOMRIGHTALIGN 0x0004L
#define SBS_SIZEBOX     0x0008L
#if (WINVER >= 0x0400)
#define SBS_SIZEGRIP    0x0010L
#endif

#define LBS_NOTIFY      0x0001L
#define LBS_SORT        0x0002L
#define LBS_NOREDRAW    0x0004L
#define LBS_MULTIPLESEL 0x0008L
#define LBS_OWNERDRAWFIXED 0x0010L
#define LBS_OWNERDRAWVARIABLE 0x0020L
#define LBS_HASSTRINGS  0x0040L
#define LBS_USETABSTOPS 0x0080L
#define LBS_NOINTEGRALHEIGHT 0x0100L
#define LBS_MULTICOLUMN 0x0200L
#define LBS_WANTKEYBOARDINPUT 0x0400L
#define LBS_EXTENDEDSEL 0x0800L
#define LBS_DISABLENOSCROLL 0x1000L
#if (WINVER >= 0x0400)
#define LBS_NOSEL       0x4000L
#endif
#define LBS_STANDARD    (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER)

#define CBS_SIMPLE      0x0001L
#define CBS_DROPDOWN    0x0002L
#define CBS_DROPDOWNLIST 0x0003L
#define CBS_OWNERDRAWFIXED 0x0010L
#define CBS_OWNERDRAWVARIABLE 0x0020L
#define CBS_AUTOHSCROLL 0x0040L
#define CBS_OEMCONVERT  0x0080L
#define CBS_SORT        0x0100L
#define CBS_HASSTRINGS  0x0200L
#define CBS_NOINTEGRALHEIGHT 0x0400L
#define CBS_DISABLENOSCROLL 0x0800L
#if (WINVER >= 0x0400)
#define CBS_UPPERCASE   0x2000L
#define CBS_LOWERCASE   0x4000L
#endif

// operation messages sent to DLGINIT
#define WM_USER         0x0400
#define LB_ADDSTRING    (WM_USER+1)
#define CB_ADDSTRING    (WM_USER+3)

#if (WINVER >= 0x0400)

#define HDS_HORZ                0x00000000
#define HDS_BUTTONS             0x00000002
#define HDS_HIDDEN              0x00000008

#define TTS_ALWAYSTIP           0x01
#define TTS_NOPREFIX            0x02

#define SBARS_SIZEGRIP          0x0100

#define TBS_AUTOTICKS           0x0001
#define TBS_VERT                0x0002
#define TBS_HORZ                0x0000
#define TBS_TOP                 0x0004
#define TBS_BOTTOM              0x0000
#define TBS_LEFT                0x0004
#define TBS_RIGHT               0x0000
#define TBS_BOTH                0x0008
#define TBS_NOTICKS             0x0010
#define TBS_ENABLESELRANGE      0x0020
#define TBS_FIXEDLENGTH         0x0040
#define TBS_NOTHUMB             0x0080

#define UDS_WRAP                0x0001
#define UDS_SETBUDDYINT         0x0002
#define UDS_ALIGNRIGHT          0x0004
#define UDS_ALIGNLEFT           0x0008
#define UDS_AUTOBUDDY           0x0010
#define UDS_ARROWKEYS           0x0020
#define UDS_HORZ                0x0040
#define UDS_NOTHOUSANDS         0x0080

#define CCS_TOP                 0x00000001L
#define CCS_NOMOVEY             0x00000002L
#define CCS_BOTTOM              0x00000003L
#define CCS_NORESIZE            0x00000004L
#define CCS_NOPARENTALIGN       0x00000008L
#define CCS_NOHILITE            0x00000010L
#define CCS_ADJUSTABLE          0x00000020L
#define CCS_NODIVIDER           0x00000040L

#define LVS_ICON                0x0000
#define LVS_REPORT              0x0001
#define LVS_SMALLICON           0x0002
#define LVS_LIST                0x0003
#define LVS_TYPEMASK            0x0003
#define LVS_SINGLESEL           0x0004
#define LVS_SHOWSELALWAYS       0x0008
#define LVS_SORTASCENDING       0x0010
#define LVS_SORTDESCENDING      0x0020
#define LVS_SHAREIMAGELISTS     0x0040
#define LVS_NOLABELWRAP         0x0080
#define LVS_AUTOARRANGE         0x0100
#define LVS_EDITLABELS          0x0200
#define LVS_NOSCROLL            0x2000

#define LVS_ALIGNTOP            0x0000
#define LVS_ALIGNLEFT           0x0800
#define LVS_ALIGNMASK           0x0c00

#define LVS_OWNERDRAWFIXED      0x0400
#define LVS_NOCOLUMNHEADER      0x4000
#define LVS_NOSORTHEADER        0x8000

#define TVS_HASBUTTONS          0x0001
#define TVS_HASLINES            0x0002
#define TVS_LINESATROOT         0x0004
#define TVS_EDITLABELS          0x0008
#define TVS_DISABLEDRAGDROP     0x0010
#define TVS_SHOWSELALWAYS       0x0020

#define TCS_FORCEICONLEFT       0x0010
#define TCS_FORCELABELLEFT      0x0020
#define TCS_SHAREIMAGELISTS     0x0040
#define TCS_TABS                0x0000
#define TCS_BUTTONS             0x0100
#define TCS_SINGLELINE          0x0000
#define TCS_MULTILINE           0x0200
#define TCS_RIGHTJUSTIFY        0x0000
#define TCS_FIXEDWIDTH          0x0400
#define TCS_RAGGEDRIGHT         0x0800
#define TCS_FOCUSONBUTTONDOWN   0x1000
#define TCS_OWNERDRAWFIXED      0x2000
#define TCS_TOOLTIPS            0x4000
#define TCS_FOCUSNEVER          0x8000

#define ACS_CENTER              0x0001
#define ACS_TRANSPARENT         0x0002
#define ACS_AUTOPLAY            0x0004

#endif // (WINVER >= 0x0400)

// 32-bit language/sub-language identifiers

#ifndef LANG_NEUTRAL
// Primary language IDs.
#define LANG_NEUTRAL                     0x00

#define LANG_BULGARIAN                   0x02
#define LANG_CHINESE                     0x04
#define LANG_CROATIAN                    0x1a
#define LANG_CZECH                       0x05
#define LANG_DANISH                      0x06
#define LANG_DUTCH                       0x13
#define LANG_ENGLISH                     0x09
#define LANG_FINNISH                     0x0b
#define LANG_FRENCH                      0x0c
#define LANG_GERMAN                      0x07
#define LANG_GREEK                       0x08
#define LANG_HUNGARIAN                   0x0e
#define LANG_ICELANDIC                   0x0f
#define LANG_ITALIAN                     0x10
#define LANG_JAPANESE                    0x11
#define LANG_KOREAN                      0x12
#define LANG_NORWEGIAN                   0x14
#define LANG_POLISH                      0x15
#define LANG_PORTUGUESE                  0x16
#define LANG_ROMANIAN                    0x18
#define LANG_RUSSIAN                     0x19
#define LANG_SLOVAK                      0x1b
#define LANG_SLOVENIAN                   0x24
#define LANG_SPANISH                     0x0a
#define LANG_SWEDISH                     0x1d
#define LANG_TURKISH                     0x1f
#endif //!LANG_NEUTRAL

#ifndef SUBLANG_NEUTRAL
// Sublanguage IDs.
#define SUBLANG_NEUTRAL                  0x00
#define SUBLANG_DEFAULT                  0x01
#define SUBLANG_SYS_DEFAULT              0x02

#define SUBLANG_CHINESE_TRADITIONAL      0x01
#define SUBLANG_CHINESE_SIMPLIFIED       0x02
#define SUBLANG_CHINESE_HONGKONG         0x03
#define SUBLANG_CHINESE_SINGAPORE        0x04
#define SUBLANG_DUTCH                    0x01
#define SUBLANG_DUTCH_BELGIAN            0x02
#define SUBLANG_ENGLISH_US               0x01
#define SUBLANG_ENGLISH_UK               0x02
#define SUBLANG_ENGLISH_AUS              0x03
#define SUBLANG_ENGLISH_CAN              0x04
#define SUBLANG_ENGLISH_NZ               0x05
#define SUBLANG_ENGLISH_EIRE             0x06
#define SUBLANG_FRENCH                   0x01
#define SUBLANG_FRENCH_BELGIAN           0x02
#define SUBLANG_FRENCH_CANADIAN          0x03
#define SUBLANG_FRENCH_SWISS             0x04
#define SUBLANG_GERMAN                   0x01
#define SUBLANG_GERMAN_SWISS             0x02
#define SUBLANG_GERMAN_AUSTRIAN          0x03
#define SUBLANG_ITALIAN                  0x01
#define SUBLANG_ITALIAN_SWISS            0x02
#define SUBLANG_NORWEGIAN_BOKMAL         0x01
#define SUBLANG_NORWEGIAN_NYNORSK        0x02
#define SUBLANG_PORTUGUESE               0x02
#define SUBLANG_PORTUGUESE_BRAZILIAN     0x01
#define SUBLANG_SPANISH                  0x01
#define SUBLANG_SPANISH_MEXICAN          0x02
#define SUBLANG_SPANISH_MODERN           0x03
#endif //!SUBLANG_NEUTRAL

#ifdef APSTUDIO_INVOKED
#undef APSTUDIO_HIDDEN_SYMBOLS
#endif

#define IDOK            1
#define IDCANCEL        2
#define IDABORT         3
#define IDRETRY         4
#define IDIGNORE        5
#define IDYES           6
#define IDNO            7
#if (WINVER >= 0x0400)
#define IDCLOSE         8
#define IDHELP          9
#endif

#ifdef IDC_STATIC
#undef IDC_STATIC
#endif
#define IDC_STATIC      (-1)

#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, on)
#endif
//
// win_dtre.cpp
//

#include "CmnHdr.H"
#include <windows.h>
#include <windowsx.h>

#include <tchar.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "Resource.H"

static BOOL IsChildDir (WIN32_FIND_DATA *lpFindData) 
{
  return(
    ((lpFindData->dwFileAttributes &
      FILE_ATTRIBUTE_DIRECTORY) != 0) &&
      (lstrcmp(lpFindData->cFileName, _TEXT(".")) !=0) &&
      (lstrcmp(lpFindData->cFileName, _TEXT("..")) != 0));
}

static BOOL FindNextChildDir (HANDLE hFindFile, WIN32_FIND_DATA *lpFindData)
{
  BOOL fFound = FALSE;

  do
  {
    fFound = FindNextFile(hFindFile, lpFindData);
  } while (fFound && !IsChildDir(lpFindData));

  return(fFound);
}

static HANDLE FindFirstChildDir (LPTSTR szPath, WIN32_FIND_DATA *lpFindData)
{
  BOOL fFound;
  HANDLE hFindFile = FindFirstFile(szPath, lpFindData);

  if (hFindFile != INVALID_HANDLE_VALUE)
  {
    fFound = IsChildDir(lpFindData);

    if (!fFound)
      fFound = FindNextChildDir(hFindFile, lpFindData);

    if (!fFound)
    {
      FindClose(hFindFile);
      hFindFile = INVALID_HANDLE_VALUE;
    }
  }
  return (hFindFile);
}

// To minimize stack use, one instance of the DIRWALKDATA structure is
// created as a local variable in DirWalk.C, and a pointer to it is passed
// to DirWalkRecurse()

// Data Used by DirWalkRecurse
typedef struct
{
  HWND hwndTreeLB;           // Handle to the output list box
  int nDepth;                // Nesting depth
  BOOL fRecurse;             // Set to TRUE to list subdirectories
  TCHAR szBuf[1000];         // Output formatting buffer
  int nIndent;               // Indentation character count
  BOOL fOk;                  // Loop control flag
  BOOL fIsDir;                // Loop control flag
  WIN32_FIND_DATA FindData;   // File information
} DIRWALKDATA, *LPDIRWALKDATA;

// Walk the directory structure and fill a ListBox control with filenames.
// If pDW->fRecurse is set, list any child directories by recursively calling
// DirWalkRecurse.

static void DirWalkRecurse (LPDIRWALKDATA pDW)
{
  HANDLE hFind;

  pDW->nDepth++;

  pDW->nIndent = 3 * pDW->nDepth;
  _stprintf(pDW->szBuf, _TEXT("%*s"), pDW->nIndent, _TEXT(""));

  GetCurrentDirectory(chDIMOF(pDW->szBuf) - pDW->nIndent, &pDW->szBuf[pDW->nIndent]);
  ListBox_AddString(pDW->hwndTreeLB, pDW->szBuf);

  hFind = FindFirstFile(_TEXT("*.*"), &pDW->FindData);
  pDW->fOk = (hFind != INVALID_HANDLE_VALUE);

  while (pDW->fOk)
  {
    pDW->fIsDir = pDW->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
    if (!pDW->fIsDir || (!pDW->fRecurse && IsChildDir(&pDW->FindData)))
    {
      _stprintf(pDW->szBuf,
        pDW->fIsDir ? _TEXT("%*s[%s]") : _TEXT("%*s%s"),
        pDW->nIndent, _TEXT(""),
        pDW->FindData.cFileName);

      DeleteFile(pDW->hwndTreeLB, pDW->szBuf);
    }
    pDW->fOk = FindNextFile(hFind, &pDW->FindData);
  }
  if (hFind != INVALID_HANDLE_VALUE)
    FindClose(hFind);

  if (pDW->fRecurse)
  {
    // Get the first child directory
    hFind = FindFirstChildDir(_TEXT("*.*"), &pDW->FindData);
    pDW->fOk = (hFind != INVALID_HANDLE_VALUE);
    while (pDW->fOk)
    {
      // Change into the child directory
      if (SetCurrentDirectory(pDW->FindData.cFileName))
      {
        // Perform the recursive walk into the child directory.
        // Remember that some members of pDW will be overwritten by this call.
        DirWalkRecurse(pDW);

        // Change back to the child's parent directory.
        SetCurrentDirectory(_TEXT(".."));
      }
      pDW->fOk = FindNextChildDir(hFind, &pDW->FindData);
    }
    if (hFind != INVALID_HANDLE_VALUE)
      FindClose(hFind);
  }
  pDW->nDepth--;
}

// Walk the directory structure and fill a ListBox with filenames.
// This function sets up a call to DirWalkRecurse, which does the real work.

void DirWalk (
              HWND hwndTreeLB,              // ListBox to fill
              LPCTSTR pszRootPath,          // Starting point of the tree walk
              BOOL fRecurse                 // Expand subdirectories
              )
{
  TCHAR szCurrDir[_MAX_DIR];
  DIRWALKDATA DW;                 // Create instance of DIRWALKDATA

  // Clear the ListBox
  ListBox_ResetContent(hwndTreeLB);

  // Save the current directory so that it can be restored later.
  GetCurrentDirectory(chDIMOF(szCurrDir), szCurrDir);

  // Set the current directory to where you want to start walking
  SetCurrentDirectory(pszRootPath);

  // nDepth is used to control indenting. The value -1 will cause
  // the first level to display flush left.
  DW.nDepth = -1;

  DW.hwndTreeLB = hwndTreeLB;
  DW.fRecurse = fRecurse;

  // Call the recursive function to walk the subdirectories.
  DirWalkRecurse(&DW);
 
  // Restore the current directory to what it was before the function was called.
  SetCurrentDirectory(szCurrDir);
}

BOOL Dlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
  RECT rc;

  // Associate an icon with the dialog box.
  chSETDLGICONS(hwnd, IDI_DIRWALK, IDI_DIRWALK);

  DirWalk(GetDlgItem(hwnd, IDC_TREE), _TEXT("\\"), TRUE);

  GetClientRect(hwnd, &rc);
  SetWindowPos(GetDlgItem(hwnd, IDC_TREE), NULL, 0, 0, rc.right, rc.bottom, SWP_NOZORDER);

  return(TRUE);
}

void Dlg_OnSize (HWND hwnd, UINT state, int cx, int cy)
{
  SetWindowPos(GetDlgItem(hwnd, IDC_TREE), NULL, 0, 0, cx, cy, SWP_NOZORDER);
}

void Dlg_OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT CodeNotify)
{
  switch (id)
  {
  case IDCANCEL:
    EndDialog(hwnd, id);
    break;

  case IDOK:
    // Call the recursive routine to walk the tree
    DirWalk(GetDlgItem(hwnd, IDC_TREE), _TEXT("\\"), TRUE);
    break;
  }
}

BOOL CALLBACK Dlg_Proc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch (uMsg)
  {
    chHANDLE_DLGMSG(hwnd, WM_INITDIALOG, Dlg_OnInitDialog);
    chHANDLE_DLGMSG(hwnd, WM_SIZE, Dlg_OnSize);
    chHANDLE_DLGMSG(hwnd, WM_COMMAND, Dlg_OnCommand);
  }
  return(FALSE);
}

int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE hinstPrev, LPSTR pszCmdLine, int nCmdShow)
{
  chWARNIFUNICODEUNDERWIN95();
  DialogBox(hinstExe, MAKEINTRESOURCE(IDD_DIRWALK), NULL, Dlg_Proc);
  return(0);
}
#include <string.h>
#include <stdio.h>
#include <dir.h>

void main(void)
 {
    char s[MAXPATH];
    char drive[MAXDRIVE];
    char dir[MAXDIR];
    char file[MAXFILE];
    char ext[MAXEXT];

    getcwd(s,MAXPATH);               /* get the current working directory */
    strcat(s,"\\");                  /* append on a trailing \ character */
    fnsplit(s,drive,dir,file,ext);  /* split the string to separate elems */
    strcpy(file,"DATA");
    strcpy(ext,".TXT");
    fnmerge(s,drive,dir,file,ext);   /* merge everything into one string */
    puts(s);                         /* display resulting string */
}

#include <stdio.h>
#include <direct.h>
#include <stdlib.h>

void main(void)
  {
    char *path_1 = "C:\\SUBDIR\\FILENAME.EXT";
    char *path_2 = "SUBDIR\\FILENAME.EXT";
    char *path_3 = "FILENAME.EXE";
    char subdir[MAXDIR];
    char drive[MAXDRIVE];
    char filename[MAXFILE];
    char extension[MAXEXT];
    int flags;     // holds the fnsplit return value

  flags = fnsplit (path_1, drive, subdir, filename, extension);
    printf ("Splitting %s\n", path_1);
    printf ("Drive %s Subdir %s Filename %s Extension %s\n",
      drive, subdir, filename, extension);
    flags = fnsplit (path_2, drive, subdir, filename, extension);
    printf ("Splitting %s\n", path_2);
    printf ("Drive %s Subdir %s Filename %s Extension %s\n",
      drive, subdir, filename, extension);

    flags = fnsplit (path_3, drive, subdir, filename, extension);
    printf ("Splitting %s\n", path_3);
    printf ("Drive %s Subdir %s Filename %s Extension %s\n",
      drive, subdir, filename, extension);
  }
#include <stdio.h>
#include <stdlib.h>
#include <dir.h>

void main(void)
 {
   char pathname[MAXPATH];

   char *drive = "C:";
   char *subdir = "\\SUBDIR";
   char *filename = "FILENAME";
   char *extension = "EXT";

   fnmerge(pathname, drive, subdir, filename, extension);

   printf("The complete pathname is %s\n", pathname);
 }

#include <stdio.h>
#include <io.h>        
#include <fcntl.h>     
#include <sys\types.h> 
#include <sys\stat.h>  

void main(int argc, char *argv[])
 {
    int source, target; // file handles
    char buffer[1024];  // I/O buffer 
    int bytes_read;     

    if (argc < 3)
 fprintf(stderr, "Must specify source and target files\n");
    else if ((source = open(argv[1], O_BINARY | O_RDONLY)) == -1)
 fprintf(stderr, "Error opening %s\n", argv[1]);
    else if ((target = open(argv[2], O_WRONLY | O_BINARY | O_TRUNC |
      O_CREAT, S_IWRITE)) == -1)
  fprintf(stderr, "Error opening %s\n", argv[2]);
    else
      {
  while (!eof(source))
   {
     if ((bytes_read = read(source, buffer, sizeof(buffer))) <= 0)
  fprintf(stderr, "Error reading from source file");
     else if (write(target, buffer, bytes_read) != bytes_read)
  fprintf(stderr, "Error writing to target file");
   }

  close(source);
  close(target);
     }
 }
#include <stdio.h>
#include <dos.h>    
#include <fcntl.h> 
 
void main(int argc, char *argv[])
{
   char buffer[1024];

   int input, output;                   // file handles
   unsigned bytes_read, bytes_written;  // actual number of bytes transferred

   if (argc < 3)
     fprintf(stderr, "Must specify source and target file\n");
   else if (_dos_open (argv[1], O_RDONLY, &input))
     fprintf(stderr, "Error opening source file\n");
   else if (_dos_creat (argv[2], 0, &output))
     fprintf(stderr, "Error opening target file\n");
   else
    {
       while (!_dos_read(input, buffer, sizeof(buffer), &bytes_read))
  {
    if (bytes_read == 0)
        break;
    _dos_write(output, buffer, bytes_read, &bytes_written);
  }

       _dos_close(input);
       _dos_close(output);
    }
}
#include <stdio.h>
#include <dos.h>  
#include <fcntl.h>

void main(int argc, char *argv[])
{
    unsigned date, time;
    int handle;

    if (_dos_open(argv[1], O_RDONLY, &handle))
 fprintf(stderr, "Error opening source file\n");
    else
     {
  if (_dos_getftime(handle, &date, &time))
    printf("Error getting date/time stamp\n");
  else
     printf("%s last modified %02d-%02d-%d %02d:%02d:%02d\n",
        argv[1],
        (date & 0x1E0) >> 5,  /* month */
        (date & 0x1F),        /* day */
        (date >> 9) + 1980,   /* year */
        (time >> 11),         /* hours */
        (time & 0x7E0) >> 5,  /* minutes */
        (time & 0x1F) * 2);   /* seconds */
  _dos_close(handle);
 }
}
#include <stdio.h>
#include <dos.h>  
#include <fcntl.h>

void main(int argc, char *argv[])
{
    struct Date
    {
      unsigned int day:5;
      unsigned int month:4;
      unsigned int years:7;
    } date;

    struct Time
    {
      unsigned seconds:5;
      unsigned minutes:6;
      unsigned hours:5;
    } time;

    int handle;

    if (_dos_open(argv[1], O_RDONLY, &handle))
  fprintf(stderr, "Error opening source file\n");
    else
     {
  if (_dos_getftime(handle, &date, &time))
     printf("Error getting date and time stamp\n");
  else
     printf("%s last modified %02d-%02d-%d %02d:%02d:%02d\n",
      argv[1],
      date.month,    // month 
      date.day,    // day 
      date.years + 1980,  // year 
      time.hours,           // hours 
      time.minutes,         // minutes 
      time.seconds * 2);    // seconds 
   _dos_close(handle);
    }
 }
#include <stdio.h>
#include <dos.h>  
#include <fcntl.h>

void main(int argc, char *argv[])
 {
 union
  {
  struct Date
     {
   unsigned int day:5;
   unsigned int month:4;
   unsigned int years:7;
   } bits;
  unsigned value;
  } date;

 union
  {
    struct Time
   {
   unsigned seconds:5;
   unsigned minutes:6;
   unsigned hours:5;
   } bits;
  unsigned value;
    } time;

    int handle;

    if (_dos_open(argv[1], O_RDONLY, &handle))
   fprintf(stderr, "Error opening source file\n");
    else
  {
   date.bits.day = 4;
   date.bits.month = 7;
   date.bits.years = 17;   // 1980 + 17
   time.bits.hours = 12;
   time.bits.minutes = 0;
   time.bits.seconds = 0;

   if (_dos_setftime(handle, date.value, time.value))
    printf("Error setting date/time stamp\n");
   _dos_close(handle);
  }
 }
#include <stdio.h>
#include <utime.h>

void main(int argc, char **argv)
 {
   if (utime(argv[1], (struct utimbuf *) NULL))
     printf("Error setting date and time\n");
   else
     printf("Date and time stamp set\n");
 }

#include <stdio.h>
#include <stdlib.h>

void main(void)
 { 
   FILE *fp;

   int word;

   if ((fp = fopen("DATA.DAT", "wb")) == NULL)
     {
       printf("Error opening DATA.DAT for output\n");
       exit(1);
     }
   else
     {
       for (word = 1; word <= 100; word++)
         putw(word, fp);
       fclose(fp);
     }

   if ((fp = fopen("DATA.DAT", "rb")) == NULL)
     {
       printf("Error opening DATA.DAT for input\n");
       exit(1);
     }
   else
     {
       do {
         word = getw(fp); 
         if ((word == EOF) && (feof(fp)))
           break;
         else
           printf("%d ", word);
       } while (1);
       fclose(fp);
     }
 }
#include <stdio.h>
#include <io.h>        
#include <fcntl.h>     
#include <sys\types.h> 
#include <sys\stat.h>  

void main(void)
 {
    int handle;

    if ((handle = creat("100ZEROS.DAT", S_IWRITE)) == -1)
   fprintf(stderr, "Error opening 100ZEROS.DAT");
    else
     { 
       if (chsize(handle, 100L)) 
    printf("Error changing file size\n");
   close(handle);
     }
 }
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <stdlib.h>

void main(void)
 {
   int output;
   int old_setting;

   old_setting = umask(S_IWRITE);

   if ((output = creat("OUTPUT.DAT", S_IWRITE)) == -1)
     { 
       fprintf(stderr, "Error creating OUTPUT.DAT\n");
       exit(1);
     }
   else
     {
       if (write(output, "Test", 4) == -1)
         fprintf(stderr, "Cannot write to file\n");
       else
         printf("File successfully written to\n");
       close(output);
     }

   if ((output = open("OUTPUT.DAT", O_WRONLY)) == -1)
     fprintf(stderr, "Error opening OUTPUT.DAT for output\n");
   else     
     printf("File successfully opened for write access\n");
 }
#include <stdio.h>
#include <dos.h>
#include <conio.h>

void main(void)
 { 
   char buffer[512];
   int letter;

   setbuf(stdout, buffer);

   puts("First line of output");
   puts("Second line of output");
   puts("Third line of output");
   
   delay(3000);

   printf("About to fill buffer\n");
   fflush(stdout);
 
   for (letter = 0; letter < 513; letter++) 
    { 
     putchar('A');
     delay(10);
    }
 }
#include <stdio.h>
#include <dos.h>
#include <conio.h>

void main(void)
 { 
   char line[512];
   char *buffer;
   FILE *input;

   if ((input = fopen("\\AUTOEXEC.BAT", "r")) == NULL)
     printf("Error opening \\AUTOEXEC.BAT\n");
   else
    {
      if (setvbuf(input, buffer, _IOFBF, 8192))
        printf("Error changing file buffer\n");
      else
        while (fgets(line, sizeof(line), input))
          fputs(line, stdout);
        fclose(input);
    }
 }
#include <stdio.h>
#include <dir.h>

void main(void)
 {
   char name_a[13] = "ACCTNGXXXXXX";
   char name_b[13] = "COMPUTXXXXXX";
   char name_c[13] = "PCCHIPXXXXXX";

   if (mktemp(name_a))
     puts(name_a);
   
   if (mktemp(name_b))
     puts(name_b);
   
   if (mktemp(name_c))
     puts(name_c);
 }


#include <stdio.h>
#include <dos.h>
#include <io.h>
#include <fcntl.h>

void main(void)
 {
   struct date curr_date;
   struct time curr_time;

   int handle;

   if ((handle = open("DATETIME.OUT", O_RDONLY)) == -1)
     fprintf(stderr, "Error opening file DATETIME.OUT\n");
   else
     {
       read(handle, &curr_date, sizeof(curr_date));
       read(handle, &curr_time, sizeof(curr_time));
       close(handle);

       printf("Date: %02d-%02d-%02d\n", curr_date.da_mon,
         curr_date.da_day, curr_date.da_year);
       printf("Time: %02d:%02d\n", curr_time.ti_hour, 
         curr_time.ti_min);
     }
 }
#include <stdio.h>
#include <dos.h>
#include <io.h>
#include <sys\stat.h>

void main(void)
 {
   struct date curr_date;
   struct time curr_time;

   int handle;

   getdate(&curr_date);
   gettime(&curr_time);

   if ((handle = creat("DATETIME.OUT", S_IWRITE)) == -1)
     fprintf(stderr, "Error opening file DATETIME.OUT\n");
   else
     {
       write(handle, &curr_date, sizeof(curr_date));
       write(handle, &curr_time, sizeof(curr_time));
       close(handle);
     }
 }
#include <stdio.h>
#include <dos.h>

void main(void)
 {
   struct date curr_date;
   struct time curr_time;

   FILE *input; 
   
   if ((input = fopen("DATETIME.OUT", "r")) == NULL)
     fprintf(stderr, "Error opening file DATETIME.OUT\n");
   else
     {
       fread(&curr_date, sizeof(curr_date), 1, input);
       fread(&curr_time, sizeof(curr_time), 1, input);
       fclose(input);

       printf("Date: %02d-%02d-%02d\n", curr_date.da_mon,
         curr_date.da_day, curr_date.da_year);
       printf("Time: %02d:%02d\n", curr_time.ti_hour, 
         curr_time.ti_min);
     }
 }
#include <stdio.h>
#include <dos.h>

void main(void)
 {
   struct date curr_date;
   struct time curr_time;

   FILE *output;

   getdate(&curr_date);
   gettime(&curr_time);

   if ((output = fopen("DATETIME.OUT", "w")) == NULL)
     fprintf(stderr, "Error opening file DATETIME.OUT\n");
   else
     {
       fwrite(&curr_date, sizeof(curr_date), 1, output);
       fwrite(&curr_time, sizeof(curr_time), 1, output);
       fclose(output);
     }
 }
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <sys\stat.h>

void main(void)
 {
   int handle;
   int duplicate_handle;

   char title[] = "Jamsa\'s C/C++ Programmer\'s Bible!";
   char section[] = "Files";

   if ((handle = open("OUTPUT.TST", O_WRONLY | O_CREAT, 
        S_IWRITE)) == -1)
     printf("Error opening OUTPUT.TST\n");
   else
    {
      if ((duplicate_handle = dup(handle)) == -1)
        printf("Error duplicating handle\n");
      else
        {
          write(handle, title, sizeof(title));
          close(duplicate_handle);  // Flush the buffer
          write(handle, section, sizeof(section));
          close(handle);
        }
    }
 }

#include <stdio.h>
#include <io.h>

void main(void)
 {
   dup2(2, 1);  // stdout is handle 1 stderr is handle 2

   printf("This message cannot be redirected!\n");
 }

#include <stdio.h>
#include <share.h>
#include <io.h>
#include <fcntl.h>

void main(int argc, char *argv[])
 {
   int handle, bytes_read;

   char buffer[256];

   if ((handle = sopen(argv[1], O_RDONLY, SH_DENYWR)) == -1)
     printf("Error opening the file %s\n", argv[1]);
   else
     {
       printf("Press Enter to continue\n");
       getchar();
       
       while (bytes_read = read(handle, buffer, sizeof(buffer)))
         write(1, buffer, bytes_read);  // 1 is stdout
       
       close(handle);
    }
 }
#include <stdio.h>
#include <io.h>
#include <share.h>
#include <fcntl.h>

void main(void)
 {
   int handle;

   if ((handle = sopen("\\AUTOEXEC.BAT", O_RDONLY, SH_DENYNO)) == -1)
     printf("Error opening AUTOEXEC.BAT\n");
   else
    {
      lock(handle, 0L, 5L);
      printf("File locked--press Enter to continue\n");
      getchar();
      close(handle);
    }
 }

#include <stdio.h>
#include <io.h>
#include <share.h>
#include <fcntl.h>

void main(void)
 {
   int handle;
   int offset = 0;
   int bytes_read;
   char buffer[128];

   if ((handle = sopen("\\AUTOEXEC.BAT", O_BINARY | O_RDONLY, SH_DENYNO)) == -1)
     printf("Error opening AUTOEXEC.BAT\n");
   else
    {
      while (bytes_read = read(handle, buffer, 1)) 
       {   
         if (bytes_read == -1)
           printf("Error reading offset %d\n", offset);
         else
           write(1, buffer, bytes_read);
         offset++;
         lseek(handle, offset, SEEK_SET);
       }
      close(handle);
    }
 }

#include <stdio.h>
#include <io.h>
#include <share.h>
#include <fcntl.h>
#include <sys\locking.h>

void main(void)
 {
   int handle;

   if ((handle = sopen("\\AUTOEXEC.BAT", O_RDONLY, SH_DENYNO)) == -1)
     printf("Error opening AUTOEXEC.BAT\n");
   else
    {
      printf("Trying to lock file\n");
      if (locking(handle, LK_LOCK, 5L))
         printf("Error locking file\n");
      else
       {
         printf("File locked--press Enter to continue\n");
         getchar();
         close(handle);
       }
    }
 }

#include <stdio.h>
#include <dirent.h>

void main(int argc, char *argv[])
 { 
   DIR *directory_pointer;
   struct dirent *entry;

   if ((directory_pointer = opendir(argv[1])) == NULL)
     printf("Error opening %s\n", argv[1]);
   else
     {
        while (entry = readdir(directory_pointer))
          printf("%s\n", entry);
        closedir(directory_pointer);
     }
 }


#include <stdio.h>
#include <dirent.h>
#include <dos.h>
#include <io.h>
#include <direct.h>
#include <string.h>

void show_directory(char *directory_name)
 { 
   DIR *directory_pointer;
   struct dirent *entry;

   unsigned attributes;

   if ((directory_pointer = opendir(directory_name)) == NULL)
     printf("Error opening %s\n", directory_name);
   else
     {
        chdir(directory_name);
        while (entry = readdir(directory_pointer))
          {
            attributes = _chmod(entry, 0);
            
            // Check if entry is for a subdirectory and is not "." or ".."
            if ((attributes & FA_DIREC) && 
               (strncmp(entry, ".", 1) != 0))
             { 
               printf("\n\n----%s----\n", entry);
               show_directory(entry);
             }
            else
             printf("%s\n", entry);
          }
        
        closedir(directory_pointer);
        chdir("..");
     }
 }

 void main(void)
  {
    char buffer[MAXPATH];

    // Save current directory so you can restore it later
    getcwd(buffer, sizeof(buffer));
    show_directory("\\");
    chdir(buffer);
  }


#include <stdio.h>
#include <io.h>
#include <fcntl.h>

void main(void)
 {
   int handle;
   char buffer[512];
   int bytes_read;

   if ((handle = open("\\CONFIG.SYS", O_RDONLY)) == -1)
     printf("Error opening \\CONFIG.SYS\n");
   else
     {
       printf("Current file position %ld\n", tell(handle));

       while (bytes_read = read(handle, buffer, sizeof(buffer)))
         write(1, buffer, bytes_read);

       printf("Current file position %ld\n", tell(handle));
       close(handle);      
     }
 }
 
#include <stdio.h>
#include <dos.h>
#include <io.h>

void main(void)
 {
   char path[64] = "C:\\TEMP\\";

   int handle;


   if ((handle = creattemp(path, 0)) == -1)
     printf("Error creating file\n");
   else
    {
      printf("Complete path: %s\n", path);
      close(handle);
    }
 }

#include <stdio.h>
#include <dos.h>
#include <io.h>

void main(void)
 {
   int handle;

   if ((handle = creatnew("NEW.DAT", 0)) == -1)
     printf("Error creating NEW.DAT\n");
   else
    { 
      printf("File successfully created\n");
      close(handle);
    }
 }
#include <stdio.h>
#include <dos.h>

void main(int argc, char **argv)
  {
    union REGS inregs, outregs;
    struct SREGS segs;

    char buffer[256];

    unsigned source_handle, target_handle;

    if (*argv[1] && *argv[2])
      {
   // Open the file to copy
   inregs.h.ah = 0x3D;
   inregs.h.al = 0;            // Open for read access
   inregs.x.dx = (unsigned) argv[1];
   segread (&segs);
   intdosx(&inregs, &outregs, &segs);

    if (outregs.x.cflag)
         printf ("Error opening source file %s\n", argv[1]);
     else
      {
        source_handle = outregs.x.ax;

          // Create the target file, truncating an
        // existing file with the same name
        inregs.h.ah = 0x3C;
        inregs.x.cx = 0;     // Open with normal attribute
        inregs.x.dx = (unsigned) argv[2];
        intdosx (&inregs, &outregs, &segs);

        if (outregs.x.cflag)
    printf ("Error creating target file %s\n", argv[2]);
        else
    {
       target_handle = outregs.x.ax;
               do {
          // Read the source data
          inregs.h.ah = 0x3F;
          inregs.x.bx = source_handle;
          inregs.x.cx = sizeof(buffer);
          inregs.x.dx = (unsigned) buffer;
          intdosx (&inregs, &outregs, &segs);
                if (outregs.x.cflag)
           {
        printf ("Error reading source file\n");
        break;
           }
          else if (outregs.x.ax)  // Not end of file
           {
        // Write the data
        inregs.h.ah = 0x40;
        inregs.x.bx = target_handle;
        inregs.x.cx = outregs.x.ax;
        inregs.x.dx = (unsigned) buffer;
        intdosx (&inregs, &outregs, &segs);

        if (outregs.x.cflag)
                       {
            printf ("Error writing target file\n");
            break;
           }
           }
      } while (outregs.x.ax != 0);

     // Close the files
     inregs.h.ah = 0x3E;
     inregs.x.bx = source_handle;
     intdos (&inregs, &outregs);
     inregs.x.bx = target_handle;
     intdos (&inregs, &outregs);
   }
    }
      }
    else
      printf ("Specify source and target filenames\n");
  }
#include <stdio.h>

void main(int argc, char **argv)
 {
   FILE *input, *output;

   char string[256];

   if ((input = fopen(argv[1], "r")) == NULL)
     printf("Error opening %s\n", argv[1]); 
   else if ((output = fopen(argv[2], "w")) == NULL)
     {
       printf("Error opening %s\n", argv[2]);
       fclose(input);
     }
   else 
     {
       while (fgets(string, sizeof(string), input))
         fputs(string, output);

       fclose(input);
       fclose(output);
     }
 }
#include <stdio.h>

void main(void)
 {
   FILE *fp;

   int age;
   float salary;
   char name[64];

   if ((fp = fopen("DATA.DAT", "w")) == NULL)
     printf("Error opening DATA.DAT for output\n");
   else
     {
       fprintf(fp, "33 35000.0 Kris");
       fclose(fp);
   
       if ((fp = fopen("DATA.DAT", "r")) == NULL)
         printf("Error opening DATA.DAT for input\n");
       else
        {
          fscanf(fp, "%d %f %s", &age, &salary, name);
          printf("Age %d Salary %f Name %s\n", age, salary, name);
          fclose(fp);
        }
     }
 }
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <time.h>

void main(void)
  {
    int handle;
    struct stat buffer;

    if ((handle = open("\\AUTOEXEC.BAT", O_RDONLY)) == -1)
     printf("Error opening \\AUTOEXEC.BAT\n");
    else
      {
        if (fstat(handle, &buffer))
          printf("Error getting file information\n");
        else
          printf("AUTOEXEC.BAT is %ld bytes Last used %s\n",
            buffer.st_size, ctime(&buffer.st_atime));
        close(handle);
      }
 }

           

#include <stdio.h>

void main(void)
 {
   if (freopen("STANDARD.ERR", "w", stderr))
     fputs("stderr has been redirected", stderr);
   else
     printf("Error in reopen\n");
 }

#include <stdio.h>

void main(void)
 {
   int scores[100];
   float salaries[100];
   char string[100];

   printf("Bytes used to hold int scores[100] is %d bytes\n",
     sizeof(scores));

   printf("Bytes used to hold int salaries[100] is %d bytes\n",
     sizeof(salaries));
   
   printf("Bytes used to hold char string[100] is %d bytes\n",
     sizeof(string));
 }

#include <stdio.h>

void main(void)
 {
   int scores[5] = {80, 70, 90, 85, 80};

   printf("Array Values\n");
   printf("scores[0] %d\n", scores[0]);
   printf("scores[1] %d\n", scores[1]);
   printf("scores[2] %d\n", scores[2]);
   printf("scores[3] %d\n", scores[3]);
   printf("scores[4] %d\n", scores[4]);
 }
#include <stdio.h>

void main(void)
 {
   int scores[5] = {80, 70, 90, 85, 80};
   int i;

   printf("Array Values\n");
 
   for (i = 0; i < 5; i++)
     printf("scores[%d] %d\n", i, scores[i]);
 }
#include <stdio.h>

#define ARRAY_SIZE 5

void main(void)
 {
   int values[ARRAY_SIZE] = {80, 70, 90, 85, 80};
   int i;

   for (i = 0; i < ARRAY_SIZE; i++)
     printf("values[%d] %d\n", i, values[i]);
 }
#include <stdio.h>

void main(void)
 {
   int values[5] = {80, 70, 90, 85, 80};
   int i;

   for (i = 0; i < 5; i++)
     printf("values[%d] %d\n", i, values[i]);
 }
#include <stdio.h>

void show_array(int values[], int number_of_elements)
 {
   int i;

   for (i = 0; i < number_of_elements; i++)
    printf("%d\n", values[i]);
 }

void main(void)
 {
   int scores[5] = {70, 80, 90, 100, 90};

   show_array(scores, 5);
 }

#include <stdio.h>

void show_array(int values[], int number_of_elements)
 {
   int i;

   printf("About to display %d values\n", number_of_elements);
   for (i = 0; i < number_of_elements; i++)
    printf("%d\n", values[i]);
 }

void main(void)
 {
   int scores[5] = {70, 80, 90, 100, 90};
   int count[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
   int small[2] = {-33, -44};
                       
   show_array(scores, 5);
   show_array(count, 10);
   show_array(small, 2);
 }

void main(void)
 { 
   char string[66000L];   // 66,000 bytes

   int values[33000L];    // 33,000 * 2 = 66,000 bytes

   float numbers[17000];  // 17,000 * 4 = 68,000 bytes
 }

#include <stdio.h>
#include <malloc.h>

void main(void)
  {
     int i;

     float huge *values;

     if ((values = (float huge *) halloc (17000, sizeof(float))) == NULL)
       printf ("Error allocating huge array\n");
     else
       {             
  printf("Filling the array\n");

  for (i = 0; i < 17000; i++)
    values[i] = i * 1.0;

  for (i = 0; i < 17000; i++)
    printf ("%8.1f ", values[i]);

  hfree(values);
       }
  }
#include <stdio.h>

void main(void)
 {
   int box[3][3];

   float year_sales[52][5];

   char pages[40][60][20];

   printf("Bytes to hold int box[3][3] %d bytes\n", sizeof(box));
   printf("Bytes to hold float year_sales[52][5] %d bytes\n",
     sizeof(year_sales));
   printf("Bytes to hold char pages[40][60][20] %ld bytes\n",
     sizeof(pages));
 }

#include <stdio.h>

void main(void)
 {
   int row, column;

   float table[3][5] = {{1.0, 2.0, 3.0, 4.0, 5.0},
                        {6.0, 7.0, 8.0, 9.0, 10.0},
                        {11.0, 12.0, 13.0, 14.0, 15.0}};

   for (row = 0; row < 3; row++)
    for (column = 0; column < 5; column++)
     printf("table[%d][%d] = %f\n", row, column, table[row][column]);
 }

#include <stdio.h>

void main(void)
 {
   int row, column, table;

   float values[2][3][5] = {
                            {{1.0, 2.0, 3.0, 4.0, 5.0},
                             {6.0, 7.0, 8.0, 9.0, 10.0},
                             {11.0, 12.0, 13.0, 14.0, 15.0}},
                             
                            {{16.0, 17.0, 18.0, 19.0, 20.0},
                             {21.0, 22.0, 23.0, 24.0, 25.0},
                             {26.0, 27.0, 28.0, 29.0, 30.0}}
                           };
   
   for (row = 0; row < 2; row++)
    for (column = 0; column < 3; column++)
     for (table = 0; table < 5; table++)
      printf("values[%d][%d][%d] = %f\n", row, column, table, 
        values[row][column][table]);
 }

#include <stdio.h>

void show_2d_array(int array[][10], int rows)
 {
   int i, j;

   for (i = 0; i < rows; i++)
     for (j = 0; j < 10; j++)
       printf("array[%d][%d] = %d\n", i, j, array[i][j]);
 }

void main(void)
 {
   int a[1][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
   int b[2][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
                   {11, 12, 13, 14, 15, 16, 17, 18, 19, 20}};
   int c[3][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
                   {11, 12, 13, 14, 15, 16, 17, 18, 19, 20},
                   {21, 22, 23, 24, 25, 26, 27, 28, 29, 30}};

   show_2d_array(a, 1);
   show_2d_array(b, 2);
   show_2d_array(c, 3);
 }
#include <stdio.h>

long sum_array(int array[], int elements)
 {
   long sum = 0;

   int i;

   for (i = 0; i < elements; i++)
     sum += array[i];

   return(sum);
 }


void main(void)
 {
   int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
   int b[2][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
                   {11, 12, 13, 14, 15, 16, 17, 18, 19, 20}};
   int c[3][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
                   {11, 12, 13, 14, 15, 16, 17, 18, 19, 20},
                   {21, 22, 23, 24, 25, 26, 27, 28, 29, 30}};

   printf("Sum of first array elements %d\n", sum_array(a, 10));
   printf("Sum of second array elements %d\n", sum_array(b, 20));
   printf("Sum of third array elements %d\n", sum_array(c, 30));
 }
#include <stdio.h>

void main(void)
 {
   union EmployeeDates 
  {
     int days_worked;
     struct Date 
   {
       int month;
       int day;
       int year;
     } last_day;
   } emp_info;

   union Numbers 
  {
     int a;
     float b;
     long c;
     double d;  // Largest--requires 8 bytes
   } value;

   printf("Size of EmployeeDates %d bytes\n", sizeof(emp_info));
   printf("Size of Numbers %d bytes\n", sizeof(value));
 }

#include <stdio.h>
#include <dos.h>

void main(void)
 {
   union REGS inregs, outregs;

   inregs.h.ah = 0x30;
   inregs.h.al = 0;
   intdos(&inregs, &outregs);

   printf("Current version %d.%d\n", outregs.h.al, outregs.h.ah);
 }

#include <stdio.h>
#include <dos.h>

void main(void)
 {
   union REGS inregs, outregs;

   inregs.x.ax = 0x3000;
   intdos(&inregs, &outregs);

   printf("Current version %d.%d\n", outregs.x.ax & 0xFF,
     outregs.x.ax >> 8);
 }

#include <stdio.h>

int binary_search(int array[], int value, int size)
 {
   int found = 0;
   int high = size, low = 0, mid;

   mid = (high + low) / 2;

   printf("\n\nLooking for %d\n", value);

   while ((! found) && (high >= low))
    {
      printf("Low %d Mid %d High %d\n", low, mid, high);

      if (value == array[mid])
        found = 1;
      else if (value < array[mid])
        high = mid - 1;
      else
        low = mid + 1;
       mid = (high + low) / 2;
   }
  return((found) ? mid: -1);
 }

void main(void)
 {
   int array[100], i;

   for (i = 0; i < 100; i++)
     array[i] = i;

   printf("Result of search %d\n", binary_search(array, 33, 100));
   printf("Result of search %d\n", binary_search(array, 75, 100));
   printf("Result of search %d\n", binary_search(array, 1, 100));
   printf("Result of search %d\n", binary_search(array, 1001, 100));
 }
  


   
#include <stdio.h>
#include <stdlib.h>

void bubble_sort(int array[], int size)
 {
   int temp, i, j;

   for (i = 0; i < size; i++) 
    for (j = 0; j < size; j++)
      if (array[i] < array[j])
        {
          temp = array[i];
          array[i] = array[j];
          array[j] = temp;
        }
  }

void main(void)
 {
   int values[30], i; 

   for (i = 0; i < 30; i++)
     values[i] = rand() % 100;

   bubble_sort(values, 30);

   for (i = 0; i < 30; i++)
     printf("%d ", values[i]);
 }

#include <stdio.h>
#include <stdlib.h>

void selection_sort(int array[], int size)
 {
   int temp, current, j;

   for (current = 0; current < size; current++) 
    for (j = current + 1; j < size; j++)
      if (array[current] > array[j])
        {
          temp = array[current];
          array[current] = array[j];
          array[j] = temp;
        }
  }

void main(void)
 {
   int values[30], i; 

   for (i = 0; i < 30; i++)
     values[i] = rand() % 100;

   selection_sort(values, 30);

   for (i = 0; i < 30; i++)
     printf("%d ", values[i]);
 }

#include <stdio.h>
#include <stdlib.h>

void shell_sort(int array[], int size)
 {
   int temp, gap, i, exchange_occurred;
          
   gap = size / 2;      
   
   do 
  {
    do 
  {
      exchange_occurred = 0;

      for (i = 0; i < size - gap; i++)
       if (array[i] > array[i + gap])
        {  
          temp = array[i];
          array[i] = array[i + gap];
          array[i + gap] = temp;
          exchange_occurred = 1;
        }
    } while (exchange_occurred);
   } 
  while (gap = gap / 2);
  }

void main(void)
 {
   int values[50], i; 

   for (i = 0; i < 50; i++)
     values[i] = rand() % 100;

   shell_sort(values, 50);

   for (i = 0; i < 50; i++)
     printf("%d ", values[i]);
 }

#include <stdio.h>
#include <stdlib.h>

void quick_sort(int array[], int first, int last)
 {
   int temp, low, high, list_separator;    
   
   low = first;
   high = last;
   list_separator = array[(first + last) / 2];

   do 
   {
     while (array[low] < list_separator)
       low++;

     while (array[high] > list_separator)
       high--;
   
     if (low <= high)
      {  
        temp = array[low];
        array[low++] = array[high];
        array[high--] = temp;
      }
   } 
   while (low <= high);

  if (first < high)
    quick_sort(array, first, high);
  if (low < last)
    quick_sort(array, low, last);
 }

void main(void)
 {
   int values[100], i; 

   for (i = 0; i < 100; i++)
     values[i] = rand() % 100;

   quick_sort(values, 0, 99);

   for (i = 0; i < 100; i++)
     printf("%d ", values[i]);
 }

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

void bubble_sort(char *array[], int size)
 {
   char *temp; 
   int i, j;

   for (i = 0; i < size; i++) 
    for (j = 0; j < size; j++)
      if (strcmp(array[i], array[j]) < 0)
        {
          temp = array[i];
          array[i] = array[j];
          array[j] = temp;
        }
  }

void main(void)
 {
   char *values[] = {"AAA", "CCC", "BBB", "EEE", "DDD"};
   int i;

   bubble_sort(values, 5);

   for (i = 0; i < 5; i++)
     printf("%s ", values[i]);
 }

#include <stdlib.h>
#include <stdio.h>

int compare_int(int *a, int *b)
 {
   return(*a - *b);
 }

int compare_float(float *a, float *b)
 {
   return((*a == *b) ? 0: 1);
 }


void main(void)
 {
   int int_values[] = {1, 3, 2, 4, 5}; 
   float float_values[] = {1.1, 3.3, 2.2, 4.4, 5.5};  
   
   int *int_ptr, int_value = 2, elements = 5;
   float *float_ptr, float_value = 33.3;

   int_ptr = lfind(&int_value, int_values, 
      &elements, sizeof(int), 
      (int (*) (const void *, const void *)) compare_int);

   if (*int_ptr)
     printf("Value %d found\n", int_value);
   else 
     printf("Value %d not found\n", int_value);

   float_ptr = lfind(&float_value, float_values, 
     &elements, sizeof(float), 
     (int (*) (const void *, const void *)) compare_float);
   
   
   if (*float_ptr)
     printf("Value %3.1f found\n", float_value);
   else 
     printf("Value %3.1f not found\n", float_value);

 }

#include <stdlib.h>
#include <stdio.h>

int compare_int(int *a, int *b)
 {
   return(*a - *b);
 }


void main(void)
 {
   int int_values[10] = {1, 3, 2, 4, 5}; 
   int *int_ptr, int_value = 1500, elements = 5, i;

   printf("Array contents before search\n");
   for (i = 0; i < elements; i++)
     printf("%d ", int_values[i]);

   
   int_ptr = lsearch(&int_value, int_values, 
      &elements, sizeof(int), 
      (int (*) (const void *, const void *)) compare_int);

   printf("\nArray contents after search\n");
   for (i = 0; i < elements; i++)
     printf("%d ", int_values[i]);

 }

#include <stdlib.h>
#include <stdio.h>

int compare_int(int *a, int *b)
 {
   return(*a - *b);
 }

int compare_float(float *a, float *b)
 {
   return((*a == *b) ? 0: 1);
 }


void main(void)
 {
   int int_values[] = {1, 3, 2, 4, 5}; 
   float float_values[] = {1.1, 3.3, 2.2, 4.4, 5.5};  
   
   int *int_ptr, int_value = 2, elements = 5;
   float *float_ptr, float_value = 33.3;

   int_ptr = bsearch(&int_value, int_values, 
      elements, sizeof(int), 
      (int (*) (const void *, const void *)) compare_int);

   if (*int_ptr)
     printf("Value %d found\n", int_value);
   else 
     printf("Value %d not found\n", int_value);

   float_ptr = bsearch(&float_value, float_values, 
     elements, sizeof(float), 
     (int (*) (const void *, const void *)) compare_float);
   
   
   if (*float_ptr)
     printf("Value %3.1f found\n", float_value);
   else 
     printf("Value %3.1f not found\n", float_value);

 }

#include <stdlib.h>
#include <stdio.h>

int compare_int(int *a, int *b)
 {
  if (*a < *b)
   return(-1);
  else if (*a == *b)
   return(0);
  else
   return(1);
 }

int compare_float(float *a, float *b)
 {
   if (*a < *b)
     return(-1);
   else if (*a == *b)
     return(0);
   else
     return(1);
 }


void main(void)
 {
   int int_values[] = {51, 23, 2, 44, 45}; 
   float float_values[] = {21.1, 13.3, 22.2, 34.4, 15.5};  
   
   int elements = 5, i;
   
   qsort(int_values, elements, sizeof(int), 
      (int (*) (const void *, const void *)) compare_int);

   for (i = 0; i < elements; i++)
     printf("%d ", int_values[i]);

   putchar('\n');

   qsort(float_values, elements, sizeof(float), 
     (int (*) (const void *, const void *)) compare_float);
   
   for (i = 0; i < elements; i++)
     printf("%4.1f ", float_values[i]);
 }

#include <stdio.h>

void main(void)
 {
   int int_values[] = {51, 23, 2, 44, 45}; 
   float float_values[] = {21.1, 13.3, 22.2, 34.4, 15.5};  
 
   printf("Number of elements in int_values %d\n",
     sizeof(int_values) / sizeof(int_values[0]));

   printf("Number of elements in float_values %d\n",
     sizeof(float_values) / sizeof(float_values[0]));
 }

#include <stdio.h>

void main(void)
 {
   int count = 1;
   float salary = 40000.0;
   long distance = 1234567L;

   printf("Address of count is %x\n", &count);
   printf("Address of salary is %x\n", &salary);
   printf("Address of distance is %x\n", &distance);
 }

#include <stdio.h>

void main(void)
 {
   int count[10];
   float salaries[5];
   long distances[10];

   printf("Address of the array count is %x\n", count);
   printf("Address of the array salaries is %x\n", salaries);
   printf("Address of the array distances is %x\n", distances);
 }
#include <stdio.h>

void main(void)
 {
   int count[10];
   float salaries[5];
   long distances[10];

   printf("Address of the array count is %x &count is %x\n", 
     count, &count);
   printf("Address of the array salaries is %x &count is %x\n", 
     salaries, &salaries);
   printf("Address of the array distances is %x &distances is %x\n", 
     distances, &distances);
 }
#include <stdio.h>

void main(void)
 {
   int *iptr;      // Declare pointer variable
   int count = 1;

   iptr = &count;
   printf("Value of iptr %x Value of count %d Address of count %x\n", 
     iptr, count, &count);
 }
#include <stdio.h>

void main(void)
 {
   int counter = 10;
   int *iptr;          // Declare pointer value

   iptr = &counter;    // Assign the address
   printf("Addres in iptr %x Value at *iptr %d\n", iptr, *iptr); 
   
   *iptr = 25;         // Change the value in memory

   printf("Value of counter %d\n", counter);
 }

#include <stdio.h>

void swap_values(int *a, int *b)
 { 
   int temp;

   temp = *a;  // Temporarily hold the value pointed to by a
   *a = *b;    // Assign b's value to a
   *b = temp;  // Assign a's value to b
 }

void main(void)
 {
   int one = 1, two = 2;

   swap_values(&one, &two);

   printf("one contains %d two contains %d\n", one, two);
 }


   
#include <stdio.h>

void main(void)
 {
   int values[5] = {1, 2, 3, 4, 5};
   int counter;
   int *iptr;

   iptr = values;

   for (counter = 0; counter < 5; counter++)
     {
       printf("%d\n", *iptr);
       iptr++;
     }
 }


#include <stdio.h>

void show_string(char *string)
 { 
   while (*string)
     putchar(*string++);
 }

void main(void)
 {
   show_string("Jamsa\'s C/C++ Programmer\'s Bible");
 }

#include <stdio.h>
#include <ctype.h>

char *string_uppercase(char *string)
 {
   char *starting_address;

   starting_address = string;

   while (*string)
     toupper(*string++);

   return(starting_address);
 }

void main(void)
 {
   char *title = "Jamsa\'s C/C++ Programmmer\'s Bible";
   char *string;

   string = string_uppercase(title);
   printf("%s\n", string);

   printf("%s\n", string_uppercase("Arrays and Pointers"));
 }
#include <stdio.h>

void main(void)
 {
   char *weekdays[7] = {"Sunday", "Monday", "Tuesday", "Wednesday",
                        "Thursday", "Friday", "Saturday"};

   int i;

   for (i = 0; i < 7; i++)
     printf("weekdays[%d] contains %s\n", i, weekdays[i]);
 }

#include <stdio.h>

void main(void)
 {
   char *workdays[] = {"Monday", "Tuesday", "Wednesday",
                        "Thursday", "Friday", "" };
   char **work_day;

   work_day = workdays; 

   while (*work_day)
     printf("%s\n", *work_day++);
 }

#include <stdio.h>

int get_result(int a, int b, int (*compare)())
 {
   return(compare(a, b));  // Invoke the function passed
 }
 

int max(int a, int b)
 {
   printf("In max\n");
   return((a > b) ? a: b);
 }

int min(int a, int b)
 {
   printf("In min\n");
   return((a < b) ? a: b);
 }

void main(void)
 {
   int result;

   result = get_result(1, 2, &max);
   printf("Max of 1 and 2 is %d\n", result);
   
   result = get_result(1, 2, &min);
   printf("Min of 1 and 2 is %d\n", result);
 }


#include <stdio.h>

int what_is_the_value(int ***ptr)
 {
   return(***ptr);
 }

void main(void)
 {
   int *level_1, **level_2, ***level_3, value = 1001;

   level_1 = &value;
   level_2 = &level_1;
   level_3 = &level_2;

   printf("The value is %d\n", what_is_the_value(level_3));
 }

#include <stdio.h>
#include <dos.h>

void main(void)
 {
   struct date curr_date;

   getdate(&curr_date);

   printf("Current date: %d-%d-%d\n", curr_date.da_mon,
     curr_date.da_day, curr_date.da_year); 
 }
#include <stdio.h>

struct Shape 
{
  int type;
  int color;
  float radius;
  float area;
  float perimeter;
};

void show_structure(struct Shape shape)
 {
   printf("shape.type %d\n", shape.type);
   printf("shape.color %d\n", shape.color);
   printf("shape.radius %f shape.area %f shape.perimeter %f\n",
     shape.radius, shape.area, shape.perimeter);
 }

void main(void)
 {
   struct Shape circle;

   circle.type = 0;
   circle.color = 1;
   circle.radius = 5.0;
   circle.area = 22.0 / 7.0 * circle.radius * circle.radius; 
   circle.perimeter = 2.0 * 22.0 / 7.0 * circle.radius;

   show_structure(circle);
 }

#include <stdio.h>

struct Shape 
{
  int type;
  int color;
  float radius;
  float area;
  float perimeter;
};

void change_structure(struct Shape *shape)
 {
   (*shape).type = 0;
   (*shape).color = 1;
   (*shape).radius = 5.0;
   (*shape).area = 22.0 / 7.0 * (*shape).radius * (*shape).radius; 
   (*shape).perimeter = 2.0 * 22.0 / 7.0 * (*shape).radius;
 }

void main(void)
 {
   struct Shape circle;
   
   change_structure(&circle);
   
   printf("circle.type %d\n", circle.type);
   printf("circle.color %d\n", circle.color);
   printf("circle.radius %f circle.area %f circle.perimeter %f\n",
     circle.radius, circle.area, circle.perimeter);
 }

#include <stdio.h>

struct Shape 
{
  int type;
  int color;
  float radius;
  float area;
  float perimeter;
};

void change_structure(struct Shape *shape)
 {
   shape->type = 0;
   shape->color = 1;
   shape->radius = 5.0;
   shape->area = 22.0 / 7.0 * shape->radius * shape->radius; 
   shape->perimeter = 2.0 * 22.0 / 7.0 * shape->radius;
 }

void main(void)
 {
   struct Shape circle;
   
   change_structure(&circle);
   
   printf("circle.type %d\n", circle.type);
   printf("circle.color %d\n", circle.color);
   printf("circle.radius %f circle.area %f circle.perimeter %f\n",
     circle.radius, circle.area, circle.perimeter);
 }

#include <stdio.h>

void main(void)
 {
   struct Shape 
  {
    int type;
    int color;
    float radius;
    float area;
    float perimeter;
   } circle = {0, 1, 5.0, 78.37, 31.42};
   
   printf("circle.type %d\n", circle.type);
   printf("circle.color %d\n", circle.color);
   printf("circle.radius %f circle.area %f circle.perimeter %f\n",
     circle.radius, circle.area, circle.perimeter);
 }

#include <stdio.h>

void main(void)
 {
   struct Date 
  {
     char month_name[64];
     int  month;
     int  day;
     int  year;
   } current_date = { "July", 7, 4, 1994 };

   int i;

   for (i = 0; current_date.month_name[i]; i++)
     putchar(current_date.month_name[i]);
 }

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

void main(void)
  {
    int status = 0;
    int old_status = 0;

    do
     {
       status = biosprint(2, 0, 0);  // Read LPT1       
    
       if (status != old_status)
  {
    if (status & 1)
      printf ("Time-out\t");

    if (status & 8)
      printf ("Output Error\t");
 
    if (status & 16)
      printf ("Printer Selected\t");
       
    if (status & 32)
      printf ("Out of Paper\t");

    if (status & 64)
      printf ("Acknowledge\t");

    if (status & 128)
      printf ("Printer Not Busy");
   
    printf ("\n");
  
    old_status = status;
 }
      }
    while (! kbhit());       
  }
#include <stdio.h>
#include <dos.h>

void main(void)
 {
   printf("Previous extended Ctrl-Break status %s\n",
    (getcbrk()) ? "On": "Off");

   setcbrk(0);  // Turn if off
 }


#include <stdio.h>
#include <dos.h>

void main(void)
 {
   printf("About to sleep for 5 seconds\n");
   sleep(5);
   printf("Awake\n");
 }

#include <dos.h>
#include <conio.h>

void main(void)
 {
   unsigned frequency;

   do 
  {
     for (frequency = 500; frequency <= 1000; frequency += 50)
      { 
       sound(frequency);
       delay(50);
      }
     for (frequency = 1000; frequency >= 500; frequency -= 50)
      { 
       sound(frequency);
       delay(50);
      }
   } 
  while (! kbhit());
   nosound();
 }
#include <stdio.h>
#include <dos.h>

void main(void)
 {
   struct COUNTRY info;

   country(0, &info);

   if (info.co_date == 0)
     printf("Date format: mm/dd/yy\n");
   else if (info.co_date == 1)
     printf("Date format: dd/mm/yy\n");
   else if (info.co_date == 2)
     printf("Date format: yy/mm/dd\n");

   printf("Currency symbol %s\n", info.co_curr);
   printf("Decimal separator %s\n", info.co_thsep);
   printf("Date separator %s Time separator %s\n",
     info.co_dtsep, info.co_tmsep);
   
   if (info.co_currstyle == 0)
     printf("Currency symbol precedes with no leading spaces\n");
   else if (info.co_currstyle == 1)
     printf("Currency symbol follows with no spaces\n");
   else if (info.co_currstyle == 2)
     printf("Currency symbol precedes with leading space\n");
   if (info.co_currstyle == 4)
     printf("Currency symbol follows with space\n");

   printf("Currency significant digits %d\n", info.co_digits);

   if (info.co_time)
     printf("24 hour time\n");
   else
     printf("12 hour time\n");

   printf("Data separator %s\n", info.co_dasep);
 }


#include <stdio.h>
#include <dos.h>
#include <malloc.h>

void main(void)
 {
   char far *dta;

   dta = getdta();

   printf("Current DTA is %lX\n", dta);
 
   if (MK_FP(_psp, 0x80) == dta)
     printf("DTA is at same location as command line\n");

   dta = _fmalloc(128);
   setdta(dta);

   printf("New DTA is %lX\n", getdta());
 }

#include <stdio.h>
#include <bios.h>

void main(void)
 {
   unsigned int state, old_state = 0;

   do 
  {
     state = _bios_keybrd(_KEYBRD_SHIFTSTATUS);

     if (state != old_state)
       {
         old_state = state;

         if (state & 0x80)
           printf("Ins On ");
         if (state & 0x40)
           printf("Caps On ");
         if (state & 0x20)
           printf("Num Lock On ");
         if (state & 0x10)
           printf("Scroll Lock On ");
         if (state & 0x08)
           printf("Alt pressed ");
         if (state & 0x04)
           printf("Ctrl pressed ");
         if (state & 0x02)
           printf("Left shift pressed ");
         if (state & 0x01)
           printf("Right shift pressed ");
         printf("\n");
      }
   } while (! _bios_keybrd(_KEYBRD_READY));
 }

#define IDM_EXIT           100
#define IDM_TEST           200
#define IDM_ABOUT          300

#define DLG_VERFIRST        400
#define DLG_VERLAST         404

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About  (HWND, UINT, WPARAM, LPARAM);
#include "windows.h"
#include "generic.h"
#include "winver.h"

MYAPP ICON  DISCARDABLE "GENERIC.ICO"
SMALL ICON  DISCARDABLE "SMALL.ICO"

GENERIC MENU DISCARDABLE
BEGIN
   POPUP "&File"
   BEGIN
      MENUITEM "&Test!",            IDM_TEST
      MENUITEM "E&xit",             IDM_EXIT
   END
   POPUP "&Help"
   BEGIN
      MENUITEM "&About MyApp...",   IDM_ABOUT
   END
END

1 VERSIONINFO
 FILEVERSION 3,3,0,0
 PRODUCTVERSION 3,3,0,0
 FILEFLAGSMASK 0X3fl
#ifdef _DEBUG
   FILEFLAGS 0xbl
#else
   FILEFLAGS 0xal
#endif
 FILEOS 0X4L
 FILETYPE 0X1L
 FILESUBTYPE 0X0L
BEGIN
   BLOCK "StringFileInfo"
   BEGIN
      BLOCK "040904B0"
      BEGIN
         VALUE "CompanyName", "GenericCompany\0"
         VALUE "FileDescription", "GenericApplication\0"
         VALUE "FileVersion", "1.0\0"
         VALUE "InternalName", "1.0\0"
         VALUE "LegalCopyright", "Copyright \251 Generic Company. 1997\0"
         VALUE "LegalTrademarks", "Generic Trademark.\0"
         VALUE "OriginalFilename", "\0"
         VALUE "ProductName", "Generic Application.\0"
         VALUE "ProductVersion", "1.0\0"
      END
   END
   BLOCK "VarFileInfo"
   BEGIN
      VALUE "Translation", 0x409, 1200
   END
END




        ÿÿ  ÿÿ                  è       ÿÿ  ÿÿ                  (       @           €                         €  €   €€ €   € € €€  €€€ ÀÀÀ   ÿ  ÿ   ÿÿ ÿ   ÿ ÿ ÿÿ  ÿÿÿ ð ÿ   ðÿ ðð ÿ ð   ÿ  ðððððÿððððð  ÿ  ðððððð ðððð  ÿðð  ðð ðÿðððð  ð ð ðÿ ðð ÿ ðð  ÿÿÿÿÿÿÿÿÿÿÿÿðð               ð ÿÿÿÿÿÿÿÿÿÿÿÿÿÿð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð   ððð ÿ  ð ð ðð ÿÿÿÿÿÿÿÿÿÿÿÿÿÿðð                                                                                                                                               (       ÿÿ  ÿÿ                  (                   À                         €  €   €€ €   € € €€  ÀÀÀ €€€   ÿ  ÿ   ÿÿ ÿ   ÿ ÿ ÿÿ  ÿÿÿ     ÿðð    ð  ðð    ð ðð  ÿÿÿÿðð       ð ÿÿÿÿÿÿð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð ÿÿÿÿÿÿð              ç   ç   ð   ðð   ð   ÿ  ð   ðð   ð   ÿ  ð   ðð  ÿÿ  ÿÿ  ø "   (   ÿÿ  M Y A P P       0                         è             (       (       ÿÿ  ÿÿ                  (                   À                         €  €   €€ €   € € €€  €€€ ÀÀÀ   ÿ  ÿ   ÿÿ ÿ   ÿ ÿ ÿÿ  ÿÿÿ     ÿðð    ð  ðð    ð ðð  ÿÿÿÿðð       ð ÿÿÿÿÿÿð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð   ð ÿÿÿÿÿÿð                                                                            (   ÿÿ  S M A L L       0                         (     f   ,   ÿÿ  G E N E R I C       0                 & F i l e     È & T e s t !   € d E & x i t     & H e l p   € , & A b o u t   M y A p p . . .             ÿÿ  ÿÿ      0             4   V S _ V E R S I O N _ I N F O     ½ ïþ                    ?   
                       x     S t r i n g F i l e I n f o   T     0 4 0 9 0 4 B 0   >     C o m p a n y N a m e     G e n e r i c C o m p a n y     N     F i l e D e s c r i p t i o n     G e n e r i c A p p l i c a t i o n     (     F i l e V e r s i o n     1 . 0   (     I n t e r n a l N a m e   1 . 0   h "   L e g a l C o p y r i g h t   C o p y r i g h t   ©   G e n e r i c   C o m p a n y .   1 9 9 7   N     L e g a l T r a d e m a r k s     G e n e r i c   T r a d e m a r l .     *     O r i g i n a l F i l e n a m e       J     P r o d u c t N a m e     G e n e r i c   A p p l i c a t i o n .     ,     P r o d u c t V e r s i o n   1 . 0   D     V a r F i l e I n f o     $     T r a n s l a t i o n       ° #include <windows.h>

#if defined (WIN32)
 #define IS_WIN32 TRUE
#else
 #define IS_WIN32 FALSE
#endif

#define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
#define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
#define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32

HINSTANCE hInst;   // current instance

LPCTSTR lpszAppName  = "MyApp";
LPCTSTR lpszTitle    = "My Application"; 

BOOL RegisterWin95( CONST WNDCLASS* lpwc );

int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                      LPTSTR lpCmdLine, int nCmdShow)
{
   MSG      msg;
   HWND     hWnd; 
   WNDCLASS wc;

   // Register the main application window class.
   //............................................
   wc.style         = CS_HREDRAW | CS_VREDRAW;
   wc.lpfnWndProc   = (WNDPROC)WndProc;       
   wc.cbClsExtra    = 0;
   wc.cbWndExtra    = 0;                      
   wc.hInstance     = hInstance;              
   wc.hIcon         = LoadIcon( hInstance, lpszAppName ); 
   wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
   wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
   wc.lpszMenuName  = lpszAppName;              
   wc.lpszClassName = lpszAppName;              

   if ( IS_WIN95 )
   {
      if ( !RegisterWin95( &wc ) )
         return( FALSE );
   }
   else if ( !RegisterClass( &wc ) )
      return( FALSE );

   hInst = hInstance; 

   // Create the main application window.
   //....................................
   hWnd = CreateWindow( lpszAppName, 
                        lpszTitle,    
                        WS_OVERLAPPEDWINDOW, 
                        CW_USEDEFAULT, 0, 
                        CW_USEDEFAULT, 0,  
                        NULL,              
                        NULL,              
                        hInstance,
                        NULL               
                      );

   if ( !hWnd ) 
      return( FALSE );

   ShowWindow( hWnd, nCmdShow ); 
   UpdateWindow( hWnd );         

   while( GetMessage( &msg, NULL, 0, 0) )   
   {
      TranslateMessage( &msg ); 
      DispatchMessage( &msg );  
   }

   return( msg.wParam ); 
}


BOOL RegisterWin95( CONST WNDCLASS* lpwc )
{
   WNDCLASSEX wcex;

   wcex.style         = lpwc->style;
   wcex.lpfnWndProc   = lpwc->lpfnWndProc;
   wcex.cbClsExtra    = lpwc->cbClsExtra;
   wcex.cbWndExtra    = lpwc->cbWndExtra;
   wcex.hInstance     = lpwc->hInstance;
   wcex.hIcon         = lpwc->hIcon;
   wcex.hCursor       = lpwc->hCursor;
   wcex.hbrBackground = lpwc->hbrBackground;
   wcex.lpszMenuName  = lpwc->lpszMenuName;
   wcex.lpszClassName = lpwc->lpszClassName;

   // Added elements for Windows 95.
   //...............................
   wcex.cbSize = sizeof(WNDCLASSEX);
   wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName, 
                            IMAGE_ICON, 16, 16,
                            LR_DEFAULTCOLOR );
   
   return RegisterClassEx( &wcex );
}

LRESULT CALLBACK About( HWND hDlg,
                        UINT message,
                        WPARAM wParam,
                        LPARAM lParam)
{
   switch (message)
   {
       case WM_INITDIALOG:
               return (TRUE);

       case WM_COMMAND:                              
               if (   LOWORD(wParam) == IDOK         
                   || LOWORD(wParam) == IDCANCEL)    
               {
                       EndDialog(hDlg, TRUE);        
                       return (TRUE);
               }
               break;
   }

   return (FALSE); 
}
#include <stdio.h>
#include <bios.h>

void main(void)
 {
   struct Equip 
  {
     unsigned floppy_available:1;
     unsigned coprocessor_available:1;
     unsigned system_memory:2;
     unsigned video_memory:2;
     unsigned floppy_disk_count:2;
     unsigned unused_1:1;
     unsigned serial_port_count:3;
     unsigned game_adapter_available:1;
     unsigned unused_2:1;
     unsigned printer_count:2;
   };

   union Equipment 
  {
     unsigned list;
     struct Equip list_bits;
   } equip;

   equip.list = _bios_equiplist();

   if (equip.list_bits.coprocessor_available)
     printf("Math coprocessor available\n");
   else
     printf("No math coprocessor\n");

   printf("System board memory %d\n", 
      (equip.list_bits.system_memory + 1) * 16);

   printf("Number of floppies %d\n", 
      equip.list_bits.floppy_disk_count + 1);

   printf("Number of printers %d\n",
      equip.list_bits.printer_count);

   printf("Number of serial ports %d\n",
      equip.list_bits.serial_port_count);
 }


#include <genstub.c>

LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{

   switch (uMsg)
   {
         case WM_COMMAND:
               switch ( LOWORD( wParam ) )
               {
                     case IDM_TEST:
                     {
                           SYSTEM_INFO si;
                           char        szBuffer[128];
                           HDC         hDC = GetDC( hWnd );

                           GetSystemInfo( &si );
                           // Report system info.
                           wsprintf( szBuffer, "OEM Id: %X, Addr Range %lX-%lX",
                                     si.dwOemId, si.lpMinimumApplicationAddress,
                                     si.lpMaximumApplicationAddress);
                           TextOut( hDC, 0, 0, szBuffer, lstrlen(szBuffer ) );
                           wsprintf( szBuffer, "Page Size: %lX, Allocation: %lX",
                                     si.dwPageSize, si.dwAllocationGranularity );
                           TextOut( hDC, 0, 20, szBuffer, lstrlen(szBuffer ) );
                           // Just test for Intel x86 chips. Windows 95 does not run
                           // on the RISC-based architectures.
                           wsprintf( szBuffer, "Type of Processor: %s",
                                   ( si.dwProcessorType == PROCESSOR_INTEL_386 ) ?
                                   "386" :
                                   ( ( si.dwProcessorType == PROCESSOR_INTEL_486 ) ?
                                   "486" : "PENTIUM" ) );
                           TextOut( hDC, 0, 40, szBuffer, lstrlen(szBuffer ) );
                           ReleaseDC( hWnd, hDC );
                           return 0;
                     }
                     break;
                     case IDM_EXIT:
                           DestroyWindow( hWnd );
                           break;
               }
               break;
               case WM_DESTROY:
                     PostQuitMessage( 0 );
               break;
         default:
               return (DefWindowProc(hWnd, uMsg, wParam, lParam));
   }
   return (NULL);
}# Nmake macros for building Windows 32-Bit apps

all: ShowEqup.exe

# Update the resource if necessary

generic.res:generic.rc generic.h
    rc -r -fo generic.res generic.rc

# Update the object file if necessary

Win_e~1.obj: Win_e~1.cpp generic.cpp generic.h
    $(cc) $(cdebug) $(cflags) $(cvars) Win_e~1.cpp

# Update the executable file if necessary, and if so, add the resource back in.

Win_e~1.exe: Win_e~1.obj generic.res
    $(link) $(linkdebug) $(guiflags) -out:Win_e~1.exe Win_e~1.obj generic.res $(guilibs) advapi.lib
#include <stdio.h>
#include <bios.h>

void main(void)
 {
   char i = 0, title[] = "Jamsa\'s C/C++ Programmer\'s Bible";

   unsigned status;

   status = _bios_serialcom(_COM_INIT, 0, _COM_9600 | _COM_CHR8 | _COM_STOP1 |
        _COM_NOPARITY);

   if (status & 0x100) // Data ready
     while (title[i])
       {
         _bios_serialcom(_COM_SEND, 0, title[i]);
         putchar(title[i]);
         i++;
       }
 }

#include <stdio.h>
#include <dos.h>

void main(void)
 {
   int drive;

   drive = bdos(0x19, 0, 0);

   printf("Current drive is %c\n", 'A' + drive);
 }

#include <stdio.h>
#include <bios.h>

void main(void)
 {
   printf("BIOS Memory report %dKb\n", biosmemory());
   printf("BIOS Memory report %dKb\n", _bios_memsize());
 }
#include <stdio.h>
#include <alloc.h>

void main(void)
 {
 #if defined(__SMALL__)
  unsigned result;
 #else
  long result;
 #endif

   result = coreleft();

   printf("The amount of available memory is %dKb\n",
     result / 1024);
 }
#include <stdio.h>
#include <dos.h>

void main(void)
 {
   struct SREGS segs;

   segread(&segs);

   printf("CS %X DS %X SS %X ES %X\n", segs.cs, 
     segs.ds, segs.ss, segs.es);
 }
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <string.h>

int check_for_ems(void)
  {
     union REGS inregs, outregs;
     struct SREGS segs;
 
     int major, minor;   // DOS version

     struct DeviceHeader 
   {
       struct DeviceHeader far *link;
       unsigned attributes;
       unsigned strategy_offset;
       unsigned interrupt_offset;
       char name_or_number_of_units[8];
     } far *dev;

     int i;
     char driver_name[9];

     // Get the DOS version
     inregs.x.ax = 0x3001;
     intdos (&inregs, &outregs);
     major = outregs.h.al;
     minor = outregs.h.ah;

     if (major < 2)
       return(0);     // Requires DOS 2.0
     else
       {
   // Get the list of lists
   inregs.h.ah = 0x52;
   intdosx (&inregs, &outregs, &segs);

   if (major == 2)
    dev = (struct DeviceHeader far *) 
     MK_FP(segs.es + 1, outregs.x.bx + 7);        
   else if ((major == 3) && (minor == 0))
    dev = (struct DeviceHeader far *)
     MK_FP(segs.es + 2, outregs.x.bx + 8);
   else
    dev = (struct DeviceHeader far *)  
     MK_FP(segs.es + 2, outregs.x.bx + 2);

   while (FP_OFF(dev) != 0xFFFF)
    {
     if (dev->attributes & 0x8000)
   {  // Character device
    for (i = 0; i < 8; i++)
     driver_name[i] = dev->name_or_number_of_units[i];
    driver_name[8] = NULL;       
   }
   
     if (! strcmp(driver_name, "EMMXXXX0"))
   return(1);   // Found driver
   
     dev = dev->link; 
    }
     }

  return(0);
}

void main(void)
  {
    union REGS inregs, outregs;
    struct SREGS segs;

    unsigned handle;
    unsigned page;
    unsigned index, page_number; 

    unsigned page_frame_address;

    char far *data;

    if (check_for_ems())
      {
 inregs.h.ah = 0x40;
 int86 (0x67, &inregs, &outregs);

 // Make sure EMS is functional
 if (outregs.h.ah == 0)         
   {
     // Allocate a handle for 5 pages
     inregs.h.ah = 0x43;
     inregs.x.bx = 5;
     int86 (0x67, &inregs, &outregs);

     if (outregs.h.ah == 0)
       {  
   handle = outregs.x.dx; 

   // Get the page frame address
   inregs.h.ah = 0x41;
   int86 (0x67, &inregs, &outregs);
   
   if (outregs.h.ah == 0)
     {                 
       page_frame_address = outregs.x.bx;

       // map the first 4 pages
       for (page_number = 0; page_number < 4; page_number++)
         {
     inregs.h.ah = 0x44;
     inregs.h.al = page_number;  // Physical page
     inregs.x.bx = page_number;  // Logical page
     inregs.x.dx = handle;

     int86 (0x67, &inregs, &outregs);
 
     if (outregs.h.ah != 0)
       {
          printf ("Error mapping pages %xH\n",
     outregs.h.ah);

          // Release the handle
          inregs.h.ah = 0x45;
          inregs.x.dx = handle;
          int86 (0x67, &inregs, &outregs);            
          exit(0); 
       } 
         }        
       // Fill the first four pages
       data = (char far *) MK_FP(page_frame_address, 0);
     
       for (index = 0; index < 16384; index++)
         data[index] = 'A';

       for (index = 16384; index < 32768; index++)
         data[index] = 'B';

       for (index = 32768; index < 49152; index++)
         data[index] = 'C';

       for (index = 49152; index != 0; index++)
         data[index] = 'D';

       // Map logical page 4 into physical page 1
       inregs.h.ah = 0x44;
       inregs.h.al = 1;  // Physical page
       inregs.x.bx = 4;  // Logical page
       inregs.x.dx = handle;

       int86 (0x67, &inregs, &outregs);
 
       if (outregs.h.ah != 0)
         {
     printf ("Error mapping page %xH\n",
       outregs.h.ah);

     // Release the handle
     inregs.h.ah = 0x45;
     inregs.x.dx = handle;
     int86 (0x67, &inregs, &outregs);            
     exit(0); 
         } 

       // Fill page 4 which resides in page 1
       for (index = 16384; index < 32768; index++)
         data[index] = 'E';
        
       // Display the first 20 bytes of each page
       printf ("Physical Page Zero\n");
       for (index = 0; index < 20; index++)
         printf ("%c ", data[index]);

       printf ("\nPhysical Page One\n");
       for (index = 16384; index < 16404; index++)
         printf ("%c ", data[index]);

       printf ("\nPhysical Page Two\n");
       for (index = 32768; index < 32788; index++)
         printf ("%c ", data[index]);

       printf ("\nPhysical Page Three\n");
       for (index = 49152; index < 49172; index++)
         printf ("%c ", data[index]);

       // Map logical page 1 into physical page 3
       inregs.h.ah = 0x44;
       inregs.h.al = 3;  // Physical page
       inregs.x.bx = 1;  // Logical page
       inregs.x.dx = handle;

       int86 (0x67, &inregs, &outregs);
 
       if (outregs.h.ah != 0)
         {
     printf ("Error mapping page %xH\n",
       outregs.h.ah);

     // Release the handle
     inregs.h.ah = 0x45;
     inregs.x.dx = handle;
     int86 (0x67, &inregs, &outregs);            
     exit(0); 
         } 

       printf ("\nMapping logical page 1 to physical page 3"); 
       printf ("\nPhysical Page Three\n");
       for (index = 49152; index < 49162; index++)
         printf ("%c ", data[index]);

     }
   else
     printf ("Error getting base address %xH\n",
       outregs.h.ah);
      
   // Release the handle
   inregs.h.ah = 0x45;
   inregs.x.dx = handle;
   int86 (0x67, &inregs, &outregs);            
       }
     else
       printf ("Error allocating 5 pages %xH\n", 
  outregs.h.ah); 
   }
 else 
  printf ("EMM not functional\n");
      }
    else
      printf ("EMS driver not present\n");

  }


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

// Note: If you want to use XMS function 0xB, this simple 
// xms_access routine only works for tiny, small, or medium 
// models where the value of the data segment does not change.

void xms_access(union REGS *inregs, union REGS *outregs)
  {
     union REGS in, out;
     struct SREGS segs;

     unsigned segs_ds, save_bx;
     unsigned flags;

     void far (*xms)(void);  // pointer to the XMS services

     // Get the entry point to the XMS services
     in.x.ax = 0x4310;
     int86x (0x2F, &in, &out, &segs);

     xms = (void far *) (((long) (segs.es) << 16) + out.x.bx);

     // Assign the input registers to the actual registers
 
     _AX = inregs->x.ax;
     _CX = inregs->x.cx;
     _DX = inregs->x.dx;
     _SI = inregs->x.si;
     _DI = inregs->x.di;    
     _BX = inregs->x.bx;

    xms();   // Call the XMS entry point.

    // Assign the registers to the output register structure  
    asm {     
      pushf
      push bx

      pop save_bx
      pop flags
    }

    outregs->x.ax = _AX;
    outregs->x.bx = save_bx;
    outregs->x.cx = _CX;
    outregs->x.dx = _DX;
    outregs->x.si = _SI;
    outregs->x.di = _DI;

    outregs->x.cflag = flags & 1;
    outregs->x.flags = flags;
  }


void main(void)
  {
    union REGS inregs, outregs;
    struct SREGS segs;

    FILE *data;

    char data_buffer[256];

    struct xms_move {
     long byte_count;         // Number of bytes to move
     unsigned source_handle;  // Data to move
     long source_offset;           
     unsigned destination_handle;  
     long destination_offset;
    } block; 

    unsigned handle;

    int string_length;
    long character_count = 0L;
    int transfer_error = 0;   // 1 if a transfer error occurs  
    int i, extra_byte;

    void xms_access (union REGS *, union REGS *); 
 
    inregs.x.ax = 0x4300;
    int86 (0x2F, &inregs, &outregs);

    if (outregs.h.al != 0x80)
      printf ("XMS driver not installed\n");
    else
      {
  // Allocate the extended memory 
  inregs.h.ah = 9;
  inregs.x.dx = 64;  // Size 64Kb

  xms_access (&inregs, &outregs);         

  if (outregs.x.ax == 0)
    printf ("Error allocating extended memory %2xH\n",
      outregs.h.bl);
  else
    {
      handle = outregs.x.dx;

      // Read the file into a conventional memory
      // buffer and then move the data to extended memory
 
      if ((data = fopen ("\\AUTOEXEC.BAT", "r")) == NULL)
        printf ("Error opening AUTOEXEC.BAT\n");
      else
        {
   segread (&segs);

   while (fgets (data_buffer, sizeof(data_buffer), data))
     {
       // Copy data_buffer to extended memory 
       string_length = strlen(data_buffer);

       block.byte_count = string_length + 1; 

       // transfer amount must be even
       if (block.byte_count % 2)
         block.byte_count++;

       block.source_handle = 0; 
       block.source_offset = (void far *)
    MK_FP(segs.ds, data_buffer);
       block.destination_handle = handle;
       block.destination_offset = character_count;
       character_count += string_length + 1;

       inregs.h.ah = 0xB;
       inregs.x.si = (unsigned) &block;

       xms_access (&inregs, &outregs);

       if (outregs.x.ax == 0)
         {
     transfer_error = 1;
     break;
         }                                                           
     }
        }

      if (transfer_error)
        printf ("Error in data transfer\n");
      else
        {
    block.destination_handle = 0;
    block.source_handle = handle;
    block.destination_offset = (void far *)
      MK_FP(segs.ds, data_buffer);
       
    block.source_offset = 0L;
    block.byte_count = sizeof(data_buffer);

    while (block.source_offset <
       character_count)
     {    
       if ((block.byte_count + block.source_offset) 
   > character_count)
         block.byte_count = character_count - 
    block.source_offset;

       // Transfer amount must be even
       if (block.byte_count % 2)
         {
    block.byte_count++;
    extra_byte = 1;
         }
       else 
         extra_byte = 0;

       xms_access (&inregs, &outregs);                  
    
       if (outregs.x.ax == 0)
         {
    transfer_error = 1;
    break; 
         } 
        
       for (i = 0; i < (block.byte_count - 
     extra_byte); i++)
         if (data_buffer[i])
    putchar(data_buffer[i]);
 
       block.source_offset += block.byte_count;
    }                        
        } 

      if (transfer_error)
        printf ("Error in data transfer\n");  

      // Release extended memory 
      inregs.h.ah = 0x0A;
      inregs.x.dx = handle;

      xms_access (&inregs, &outregs);

      if (outregs.x.ax == 0)
        printf ("Error releasing extending memory %2xH\n", 
   outregs.h.bl);
    }  
      }
  }  
#include <stdio.h>
#include <dos.h>

void main(void)
 {
   printf("The current stack size %d bytes\n", _stklen);
 }
 
#include <stdio.h>
#include <dos.h>

extern unsigned _stklen = 8096;

void main(void)
 {
   printf("The current stack size %d bytes\n", _stklen);
 }
 
#include <stdio.h>
#include <mem.h>

void main(void)
 {
   float values[] = { 1.1, 2.2, 3.3, 4.4, 5.5 };
   float empty[5];

   int i;

   memmove(empty, values, sizeof(values));

   for (i = 0; i < 5; i++)
     printf("%3.1f ", empty[i]);
 }
#include <stdio.h>
#include <mem.h>

void main(void)
 {
   char alphabet[27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   char target[27];
   char *result;

   result = memccpy(target, alphabet, 'K', sizeof(alphabet));
   
   if (result)
     *result = NULL;

   printf(target);
 }

#include <stdio.h>
#include <mem.h>

void main(void)
 {
   char *a = "AAA";
   char *b = "BBB";
   char *c = "aaa";

   printf("Comparing %s and %s with memcmp %d\n",
     a, b, memcmp(a, b, sizeof(a)));

   printf("Comparing %s and %s with memicmp %d\n",
     a, b, memicmp(a, c, sizeof(a)));
 }  
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mem.h>

void main(void)
 {
   char *source = "aJsm\'a s/C+C +rPgoarmmres\'B biele";
   char target[64];

   memset(target, NULL, sizeof(target));  

   swab(source, target, strlen(source));

   printf("Source: %s Target %s\n", source, target);
 }
#include <stdio.h>
#include <alloc.h>

void main(void)
 {
   char *string;
   int *int_values;
   float *float_values;

   if ((string = (char *) malloc(50)))
     printf("Successfully allocated a 50 byte string\n");
   else
     printf("Error allocating string\n");

   if ((int_values = (int *) malloc(100 * sizeof(int))) != NULL)
     printf("Successfully allocated int_values[100]\n");
   else 
     printf("Error allocating int_values[100]\n");

   if ((float_values = (float *) malloc(25 * sizeof(float))) != NULL)
     printf("Successfully allocated float_values[25]\n");
   else
     printf("Error allocating float_values[25]\n");
 }

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

void main(void)
 {  
   int *int_values;

   int i;

   if ((int_values = malloc(100 * sizeof(int))) == NULL)
     printf("Error allocating the array\n");
   else
     {
       for (i = 0; i < 100; i++)
         int_values[i] = i;

       for (i = 0; i < 100; i++)
         printf("%d ", int_values[i]);

       free(int_values);
     }
 }

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

void main(void)
 {
   char *string;
   int *int_values;
   float *float_values;

   if ((string = (char *) calloc(50, sizeof(char))))
     printf("Successfully allocated a 50 byte string\n");
   else
     printf("Error allocating string\n");

   if ((int_values = (int *) calloc(100, sizeof(int))) != NULL)
     printf("Successfully allocated int_values[100]\n");
   else 
     printf("Error allocating int_values[100]\n");

   if ((float_values = (float *) calloc(25, sizeof(float))) != NULL)
     printf("Successfully allocated float_values[25]\n");
   else
     printf("Error allocating float_values[25]\n");
 }

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

void main(void)
 {
   char *one, *two, *three;

   if ((one = (char *) malloc(30000)) == NULL)
     printf("Error allocating array one\n");
   else if ((two = (char *) malloc(30000)) == NULL)
     printf("Error allocating array two\n");
   else if ((three = (char *) malloc(30000)) == NULL)
     printf("Error allocating array three\n");
   else
     printf("All arrays successfully allocated\n");
 }
#include <stdio.h>
#include <alloc.h>

void main(void)
 {
   char far *string;
   int far *int_values;
   float far *float_values;

   if ((string = (char *) farmalloc(50)))
     printf("Successfully allocated a 50 byte string\n");
   else
     printf("Error allocating string\n");

   if ((int_values = (int *) farmalloc(100 * sizeof(int))) != NULL)
     printf("Successfully allocated int_values[100]\n");
   else 
     printf("Error allocating int_values[100]\n");

   if ((float_values = (float *) farmalloc(25 * sizeof(float))) != NULL)
     printf("Successfully allocated float_values[25]\n");
   else
     printf("Error allocating float_values[25]\n");
 }

#include <stdio.h>
#include <malloc.h>

void some_function(size_t size)
 {
   int i;
   char *pointer;
   char stack_fix[1];

   stack_fix[0] = NULL;

   if ((pointer = alloca(size)) == NULL)
     printf("Error allocating %u bytes from the stack\n", size);
   else
     {
       for (i = 0; i < size; i++)    
         pointer[i] = i;
       printf("Allocated and used a buffer of %u bytes\n", size);
     }
 }


void main(void)
 {
   some_function(1000);
   some_function(32000);
   some_function(65000);
 }


#include <stdio.h>
#include <malloc.h>

void main(void)
  {
     long int i;
     int huge *big_array;

     if ((big_array = (int huge *) halloc (100000L,
       sizeof(long int))) == NULL)
       printf ("Error allocating huge array\n");
     else
       {             
        printf("Filling the array\n");

        for (i = 0; i < 100000L; i++)
          big_array[i] = i % 32768;

        for (i = 0; i < 100000L; i++)
          printf ("%d ", big_array[i]);

        hfree(big_array);
        }
  }
#include <stdio.h>
#include <alloc.h>

void main(void)
 {
   char *string, *new_string;
    
   if ((string = (char *) malloc(100)))
     {
       printf("Successfully allocated a 100 byte string\n");
       if ((new_string = (char *) realloc(string, 1000)))
         printf("String size increased to 1000\n");
       else
         printf("Error reallocating the string\n");
     }
   else
     printf("Error allocating the 100 byte string\n");
 }


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

void main(void)
 {
   char *ptr;

   printf("Starting heap available %u\n", coreleft());
   
   
   ptr = malloc(1);  // Get pointer to current break value

   if (brk(ptr + 512) == 0)
   printf("Ending heap available %u\n", coreleft());
 }


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

void main(void)
 {
   char *buffer, *second_buffer;
   int i, state;

   buffer = malloc(100);
   second_buffer = malloc(100);

   state = heapcheck();

   if (state == _HEAPOK)
     printf("Heap is ok\n");
   else if (state == _HEAPCORRUPT)
     printf("Heap is corrupt\n");


   for (i = 0; i <= 100; i++)
     buffer[i] = i;


   state = heapcheck();

   if (state == _HEAPOK)
     printf("Heap is ok\n");
   else if (state == _HEAPCORRUPT)
     printf("Heap is corrupt\n");
 }
#include <stdio.h>
#include <alloc.h>

void main(void)
 {
   char *buffer1, *buffer2, *buffer3;
   int i, state;

   buffer1 = malloc(100);
   buffer2 = malloc(200);
   buffer3 = malloc(300);
   free(buffer2);          // Free space in the middle

   state = heapfillfree('A');

   if (state == _HEAPOK)
     printf("Heap is ok\n");
   else if (state == _HEAPCORRUPT)
     printf("Heap is corrupt\n");


   for (i = 0; i <= 150; i++)
     buffer1[i] = i;


   state = heapcheckfree('A');

   if (state == _HEAPOK)
     printf("Heap is ok\n");
   else if (state == _HEAPCORRUPT)
     printf("Heap is corrupt\n");
   else if (state == _BADVALUE)
     printf("Value has been changed in free space\n");
 }
#include <stdio.h>
#include <alloc.h>

void main(void)
 {
   char *buffer, *second_buffer;
   int i, state;

   buffer = malloc(100);
   second_buffer = malloc(100);

   state = heapchecknode(buffer);

   if (state == _USEDENTRY)
     printf("buffer is ok\n");
   else
     printf("buffer is not ok\n");

   state = heapchecknode(second_buffer);

   if (state == _USEDENTRY)
     printf("second_buffer is ok\n");
   else
     printf("second_buffer is not ok\n");

   for (i = 0; i <= 100; i++)
     buffer[i] = i;

   state = heapchecknode(buffer);

   if (state == _USEDENTRY)
     printf("buffer is ok\n");
   else
     printf("buffer is not ok\n");

   state = heapchecknode(second_buffer);

   if (state == _USEDENTRY)
     printf("second_buffer is ok\n");
   printf("second_buffer is not ok\n");
 }
#include <stdio.h>
#include <alloc.h>

void main(void)
 {
   char *buffer1, *buffer2, *buffer3;

   struct heapinfo node = { NULL, 0, 0};

   buffer1 = malloc(100);
   buffer2 = malloc(200);
   buffer3 = malloc(300);
   free(buffer2);
   
   while (heapwalk(&node) == _HEAPOK)
     printf("Size %u bytes State %s\n", node.size, 
       (node.in_use) ? "In use": "Free");
     
 }
#include <stdio.h>
#include <dos.h>
#define VIDEO 0xB800   // CGA base

void main(void)
 {
   FILE *fp;   
   int offset;
   
   if ((fp = fopen("SAVE_SCR.DAT", "wb")) == NULL)
     printf("Error opening file\n");
   else
    {
      for (offset = 0; offset < 8000; offset++)
        fprintf(fp, "%c", peekb(VIDEO, offset));
      fclose(fp);
    }
 }
#include <stdio.h>
#include <dos.h>
#define VIDEO 0xB800   // CGA base

void main(void)
 {
   FILE *fp;   
   int offset;
   char value;   

   if ((fp = fopen("SAVE_SCR.DAT", "rb")) == NULL)
     printf("Error opening file\n");
   else
    {
      for (offset = 0; offset < 8000; offset++)
       { 
         fscanf(fp, "%c", &value);
         pokeb(VIDEO, offset, value);
       }
      fclose(fp);
    }
 }
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>

void main(void)
 {
   struct CMOS 
   {
     unsigned char current_second;
     unsigned char alarm_second;
     unsigned char current_minute;
     unsigned char alarm_minute;
     unsigned char current_hour;
     unsigned char alarm_hour;
     unsigned char current_day_of_week;
     unsigned char current_day;
     unsigned char current_month;
     unsigned char current_year;
     unsigned char status_registers[4];
     unsigned char diagnostic_status;
     unsigned char shutdown_code;
     unsigned char drive_types;
     unsigned char reserved_x;
     unsigned char disk_1_type;
     unsigned char reserved;
     unsigned char equipment;
     unsigned char lo_mem_base;
     unsigned char hi_mem_base;
     unsigned char hi_exp_base;
     unsigned char lo_exp_base;
     unsigned char fdisk_0_type;
     unsigned char fdisk_1_type;
     unsigned char reserved_2[19];
     unsigned char hi_check_sum;
     unsigned char lo_check_sum;
     unsigned char lo_actual_exp;
     unsigned char hi_actual_exp;
     unsigned char century;
     unsigned char information;
     unsigned char reserved3[12];
   } cmos;

   char i;
   char *pointer;
   char byte;

   pointer = (char *) &cmos;

   for (i = 0; i < 0x34; i++)
    {
      outportb(0x70, i);
      byte = inportb(0x71);         
      *pointer++ = byte;
    }

   printf("Current date %d/%d/%d\n", cmos.current_month,
     cmos.current_day, cmos.current_year);
   printf("Current time %d:%d:%d\n", cmos.current_hour,
     cmos.current_minute, cmos.current_second);
   printf("Hard disk type %d\n", cmos.fdisk_0_type);
  }
#include <stdio.h>
#include <malloc.h>

void main(void)
  {
     long int i;
     int huge *big_array;

     if ((big_array = (int huge *) halloc (100000L, sizeof(long int))) == NULL)
       printf ("Error allocating huge array\n");
     else
       {             
      printf("Filling the array\n");

      for (i = 0; i < 100000L; i++)
        big_array[i] = i % 32768;

      for (i = 0; i < 100000L; i++)
        printf ("%d ", big_array[i]);

      hfree(big_array);
       }
  }
#include <stdio.h>
#include <time.h>

void main(void)
 {
    time_t current_time;
    time_t start_time;

    printf("About to delay 5 seconds\n");

    time(&start_time);  // Get starting time in seconds

    do 
    {
      time(&current_time);
    } 
    while ((current_time - start_time) < 5);

    printf("Done\n");
 }



#include <stdio.h>
#include <time.h>

void main(void)
 {
   time_t current_time;

   time(&current_time);  // Get the time in seconds;

   printf("The current date and time: %s", 
     ctime(&current_time));
 }
#include <stdio.h>
#include <dos.h>

void main(void)
 {
    printf("About to delay 5 seconds\n");

    delay(5000);

    printf("Done\n");
 }



#include <stdio.h>
#include <time.h>
#include <dos.h>    // Contains the delay prototype

void main(void)
 {
   clock_t processor_time;

   printf("Processor time consumed %ld\n", 
     clock() / (long) CLK_TCK);

   delay(2000);

   printf("Processor time consumed %ld\n", 
     (long) clock() / (long) CLK_TCK);

   delay(3000);

   printf("Processor time consumed %ld\n", 
     clock() / (long) CLK_TCK);
 }

#include <stdio.h>
#include <time.h>

void main(void)
 {
   time_t start_time;
   time_t current_time;

   time(&start_time);

   printf("About to delay 5 seconds\n");

   do 
   {
     time(&current_time);
   } 
   while (difftime(current_time, start_time) < 5.0);

   printf("Done\n");
 }
#include <stdio.h>
#include <time.h>

void main(void)
 {
   char date[9];

   _strdate(date);

   printf("The current date is %s\n", date);
 }
#include <stdio.h>
#include <time.h>

void main(void)
 {
   char time[9];

   _strtime(time);

   printf("The current time is %s\n", time);
 }
#include <stdio.h>
#include <bios.h>

void main(void)
 {
   long ticks;

   ticks = biostime(0, ticks);

   printf("Ticks since midnight %ld\n", ticks);

   _bios_timeofday(_TIME_GETCLOCK, &ticks);

   printf("Seconds since midnight %f\n", ticks / 18.2);
 }
#include <stdio.h>
#include <time.h>

void main(void)
 {
   struct tm *current_date;

   time_t seconds;

   time(&seconds);

   current_date = localtime(&seconds);

   printf("Current date: %d-%d-%d\n", current_date->tm_mon+1, 
     current_date->tm_mday, current_date->tm_year);
   printf("Current time: %02d:%02d\n", current_date->tm_hour,
     current_date->tm_min);
 }

#include <stdio.h>
#include <time.h>

void main(void)
 {
   struct tm *gm_date;

   time_t seconds;

   time(&seconds);

   gm_date = gmtime(&seconds);

   printf("Current date: %d-%d-%d\n", gm_date->tm_mon+1, 
     gm_date->tm_mday, gm_date->tm_year);
   printf("Current time: %02d:%02d\n", gm_date->tm_hour,
     gm_date->tm_min);
 }

#include <stdio.h>
#include <dos.h>

void main(void)
 {
   struct time curr_time;

   gettime(&curr_time);

   printf("Current time %02d:%02d:%02d.%02d\n", curr_time.ti_hour,
    curr_time.ti_min, curr_time.ti_sec, curr_time.ti_hund);
 }
#include <stdio.h>
#include <dos.h>

void main(void)
 {
   struct date curr_date;

   getdate(&curr_date);

   printf("Current date: %d-%d-%d\n", curr_date.da_mon,
     curr_date.da_day, curr_date.da_year); 
 }
#include <stdio.h>
#include <dos.h>

void main(void)
 {
   struct time desired_time;

   desired_time.ti_hour = 12;
   desired_time.ti_min = 30;

   settime(&desired_time);
 }


#include <stdio.h>
#include <dos.h>

void main(void)
 {
   struct date desired_date;

   desired_date.da_mon = 10;
   desired_date.da_day = 31;
   desired_date.da_year = 1997;

   setdate(&desired_date);
 }
#include <stdio.h>
#include <dos.h>
#include <time.h>

void main(void)
 {
   struct time dostime;
   struct date dosdate;

   time_t unix_format;
   struct tm *local;

   getdate(&dosdate);
   gettime(&dostime);

   unix_format = dostounix(&dosdate, &dostime);
   local = localtime(&unix_format);
   printf("UNIX time: %s\n", asctime(local));
 }
#include <stdio.h>
#include <time.h>

void main(void)
 {
   tzset();
   printf("Difference between local and GMT is %d hours\n",
     timezone / 3600);
 }

#include <stdio.h>
#include <time.h>

void main(void)
 {
   tzset();

   printf("Current time zone is %s\n", tzname[0]);

   if (tzname[1])
     printf("Daylight savings zone is %s\n", tzname[1]);
   else
     printf("Daylight savings zone is not defined\n");
 }

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void main(void)
 {
   putenv("TZ=PST8PDT");

   tzset();

   printf("Current time zone is %s\n", tzname[0]);

   if (tzname[1])
     printf("Daylight savings zone is %s\n", tzname[1]);
   else
     printf("Daylight savings zone is not defined\n");
 }

#include <stdio.h>
#include <time.h>
#include <sys\timeb.h>

void main(void)
 {
   struct timeb timezone;

   tzset();

   ftime(&timezone);

   printf("Seconds since 1 January 1970 (GMT) %ld\n",
     timezone.time);
   printf("Fractional seconds %d\n", timezone.millitm);
   printf("Hours difference between GMT and local zone %d\n",
     timezone.timezone / 60);
   if (timezone.dstflag)
     printf("Daylight savings time active\n");
   else
     printf("Daylight savings time inactive\n");
 }

#include <time.h>

void main(void)
 { 
   time_t seconds;

   time(&seconds);  // Get current time
   
   seconds += (time_t) 60 * 60 * 24;

   stime(&seconds);
 }

#include <stdio.h>
#include <time.h>

void main(void)
 {
   time_t seconds;

   struct tm time_fields;

   time_fields.tm_mday = 22;
   time_fields.tm_mon = 8;
   time_fields.tm_year = 97;
   time_fields.tm_hour = 0;
   time_fields.tm_min = 0;
   time_fields.tm_sec = 0;

   seconds = mktime(&time_fields);

   printf("The number of seconds between 1-1-70 and 10-31-97 is %ld\n",
     seconds);
 }

#include <stdio.h>
#include <time.h>

void main(void)
 {
   time_t seconds;

   struct tm time_fields;

   time_fields.tm_mday = 31;
   time_fields.tm_mon = 10;
   time_fields.tm_year = 97;

   if (mktime(&time_fields) == -1)
     printf("Error converting fields\n");
   else
     printf("Julian date for October 31, 1997 is %d\n", time_fields.tm_yday);
 }

#include <stdio.h>
#include <time.h>

void main(void)
 {
   char buffer[128];

   struct tm *datetime;
   time_t current_time;

   tzset();

   time(&current_time);
   datetime = localtime(&current_time);

   strftime(buffer, sizeof(buffer), "%x %X", datetime);
   printf("Using %%x %%X: %s\n", buffer);
   
   strftime(buffer, sizeof(buffer), "%A %B %d, %Y", datetime);
   printf("Using %%A %%B %%d %%Y: %s\n", buffer);
 
   strftime(buffer, sizeof(buffer), "%I:%M%p", datetime);
   printf("Using %%I:%%M%%p: %s\n", buffer);
 }



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

void main(void)
 {
   printf("Press any key to continue...");

   while (! kbhit());
     ;
   printf("Done\n");
 }
#include <stdio.h>
#include <conio.h>
#include <string.h>

void main(void)
 {
   char *password;

   password = getpass("Enter Password:");

   if (strcmp(password, "Bible"))
     printf("Password Incorrect\n");
   else 
     printf("Password OK\n");
 }
#include <stdio.h>
#include <conio.h>
#include <string.h>

#define BACKSPACE 8

char *get_password(const char *prompt)
 {
   static char buffer[128];

   int i = 0;
   
   char letter = NULL;

   printf(prompt);

   while ((i < 127) && (letter != '\r'))
     {
       letter = getch();

       if (letter == BACKSPACE)
         {
           if (i > 0)
            {
              buffer[--i] = NULL;  // Erase previous *
              putchar(BACKSPACE);
              putchar(' ');
              putchar(BACKSPACE);
            }
           else
             putchar(7);  // BELL
         }
       else if (letter != '\r') 
         {
           buffer[i++] = letter;
           putchar('*');
         }
     }     
   buffer[i] = NULL;
   return (buffer);
 }


void main(void)
 {
   char *password;

   password = get_password("Enter Password: ");

   if (strcmp(password, "Bible"))
     printf("\nPassword Incorrect\n");
   else
     printf("\nPassword OK\n");
 }
#include <stdio.h>
#include <conio.h>
#include <string.h>

#define BACKSPACE 8

char *get_password(const char *prompt)
 {
   static char buffer[128];

   int i = 0;
   
   char letter = NULL;

   printf(prompt);

   while ((i < 127) && (letter != '\r'))
     {
       letter = getch();

       if (letter == BACKSPACE)
         {
           if (i > 0)
            {
              buffer[--i] = NULL;  // Erase previous *
              putchar(BACKSPACE);
              putchar(' ');
              putchar(BACKSPACE);
            }
           else
             putchar(7);  // BELL
         }
       else if (letter != '\r') 
         {
           buffer[i++] = letter;
           putchar('*');
         }
     }     
   buffer[i] = NULL;
   return (buffer);
 }


void main(void)
 {
   char *password;

   password = get_password("Enter Password: ");

   if (strcmp(password, "Bible"))
     printf("\nPassword Incorrect\n");
   else
     printf("\nPassword OK\n");
 }
#include <stdio.h>
#include <string.h>

void main(void)  
 {
   char line[255];  // Line of text read 

   while (fgets(line, sizeof(line), stdin))
     fputs(strupr(line), stdout);
 }

#include <stdio.h>
#include <ctype.h>  // Contains the tolower prototype

void main(void)
  {
    int letter;

    for (letter = getchar(); ! feof(stdin); letter = getchar())
      putchar(tolower(letter));
  }
#include <stdio.h>

void main(void)
 {
   char line[255];  // Line of input

   long line_number = 0;  // Current line number

   while (fgets(line, sizeof(line), stdin))
     printf("%ld %s", ++line_number, line);
 }

#include <stdio.h>
#include <stdlib.h>

void main(int argc, char *argv[])
 {
   char line[255];  // Line read from the file

   FILE *fp;

   if (fp = fopen(argv[1], "r"))
     {
       while (fgets(line, sizeof(line), fp))
         fputs(line, stdout);
       fclose(fp);

       exit(0);  // Successful
     }
   else 
     {
       printf("Cannot open %s\n", argv[1]);
       exit (1);
     }
 }

#include <stdio.h>
#include <dos.h>

void main(void)
  {
     char buffer[256];
     long row_count = 0;
     union REGS inregs, outregs;
     int ctrl_key_pressed, scancode;

     while (fgets (buffer, sizeof(buffer), stdin))
       {
         fputs (buffer, stdout);
            
         if ((++row_count % 24) == 0)
           {
      printf ("-- More --");
             // get the scancode of the key pressed
      inregs.h.ah = 0; 
      int86 (0x16, &inregs, &outregs);
             scancode = outregs.h.ah;

      // get keyboard state in case of Ctrl-C 
      ctrl_key_pressed = 0;
      inregs.h.ah = 2;
             int86 (0x16, &inregs, &outregs);
 
             // Ctrl key flag is bit 2  
      ctrl_key_pressed = (outregs.h.al & 4); 

      // scancode for C is 0x2E 
      if ((ctrl_key_pressed) && (scancode == 0x2E))
  break;     // Ctrl-C pressed
             printf ("\r");                           
           }
        }
}#include <stdio.h>

void main(void) 
 {
   char line[256];  // Line of redirected input

   long line_count = 0;

   while (fgets(line, sizeof(line), stdin))
     line_count++;

   printf("The number of redirected lines: %ld\n", line_count);
 }

#include <stdio.h>

void main(void)
 {
   long character_count = 0; 

   getchar();

   while (! feof(stdin))
     {
       getchar();
       character_count++;
     }

   printf("The number of redirected characters is %ld\n", 
     character_count);
 }

#include <stdio.h>
#include <time.h>
#include <dos.h>

void main(void)
 {
   char buffer[256];
   char key_pressed = 0;
   long int counter = 1;
   union REGS inregs, outregs;

   time_t start_time, current_time, end_time; 

   while (fgets(buffer, sizeof(buffer), stdin))
     {
       fputs (buffer, stdout);

       if ((++counter % 25) == 0)
  {
    time (&start_time);

    end_time = start_time + 15;
 
    do
      {
        key_pressed = 0;
        time (&current_time);
       
        inregs.h.ah = 1;
        int86 (0x16, &inregs, &outregs); 
  
        if ((outregs.x.flags & 64) == 0)
   {                 
      key_pressed = 1;
      do 
        {                    
        inregs.h.ah = 0;
        int86 (0x16, &inregs, &outregs);
        inregs.h.ah = 1;
        int86 (0x16, &inregs, &outregs);
      } while (! (outregs.x.flags & 64)); 
   } 
      }            
    while ((current_time != end_time) && (! key_pressed));  
  }
     }
  }
#include <stdio.h>
#include <dos.h>

void main(void)
  {
     union REGS inregs, outregs;

     // check the stdin handle first
     inregs.x.ax = 0x4400;
     inregs.x.bx = 0;      // stdin is handle 0
     intdos (&inregs, &outregs);

     if ((outregs.x.dx & 1) && (outregs.x.dx & 128))
       fprintf (stderr, "stdin has not been redirected\n");
     else
       fprintf (stderr, "stdin is redirected\n");                      

     // Now check stdout
     inregs.x.ax = 0x4400;
     inregs.x.bx = 1;      // stdout is handle 1
     intdos (&inregs, &outregs);

     if ((outregs.x.dx & 2) && (outregs.x.dx & 128))
       fprintf (stderr, "stdout has not been redirected\n");
     else
       fprintf (stderr, "stdout is redirected\n");                      
  }
#include <stdio.h>
#include <string.h>

void main(void)  
 {
   char line[255];  // Line of text read 

   while (fgets(line, sizeof(line), stdin))
     {
       fputs(line, stdout);
       strcat(line, "\r");
       fputs(line, stdprn);
     }
 }

#include <stdio.h>

void main(void)
 {
   char buffer[256];

   while (fgets(buffer, sizeof(buffer), stdin))
     {
       fputs(buffer, stdout);
       fputs(buffer, stderr);
     }
 }

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

void main(void)  
 {
   char line[255];  // Line of text read 

   while (fgets(line, sizeof(line), stdin))
     {
       fputs(line, stdout);
       strcat(line, "\r");
       fputs(line, stdaux);
     }
 }

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

void main(int argc, char *argv[])
 {
   char string[256];

   while (fgets(string, sizeof(string), stdin))
     if (strstr(string, argv[1]))
       fputs(string, stdout);
 }

#include <stdio.h>
#include <stdlib.h>

void main(int argc, char *argv[])
 {
   char line[255];  // Line read from the file
   int i,j;
   FILE *fp;

   if (argc > 2)
      j = 10;
   else
      j = argv[2];

   if (fp = fopen(argv[1], "r"))
     {
       for (i=0; i < j; i++)
         {
            fgets(line, sizeof(line), fp);
            fputs(line, stdout);
         }
       fclose(fp);
     }
   else
     {
       printf("Cannot open %s\n", argv[1]);
       exit (1);
     }
 }

#include <stdio.h>

void main(int argc, char *argv[])
 {
   printf ("The number of command line entries is %d\n", argc); 
 }

#include <stdio.h>

void main(int argc, char *argv[])
 {
   int i;

   for (i = 0; i < argc; ++i)
     printf ("argv[%d] points to %s\n", i, argv[i]);
 }

#include <stdio.h>

void main(int argc, char *argv[])
  {
    FILE *fp;        // File pointer

    char line[255];  // Line from file

    if ((fp = fopen(argv[1], "r")) == NULL)
      printf("Error opening %s\n", argv[1]);
    else
      {
        // Read and display each line of the file
        while (fgets(line, sizeof(line), fp))
          fputs(line, stdout);
        fclose (fp);   // Close the file
      }
  }
#include <stdio.h>

void main(int argc, char **argv)
  {
    while (*argv)
      printf ("%s\n", *argv++);
  }

#include 






Comentarii

Postări populare de pe acest blog

program principal cpp

#include "clasa.h" #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> #define DELAY 9000000 void delay() { for(long i=0;i<DELAY;i++); } //constructor cu initializare de la tastatura BigInt::BigInt() {char x; signed char t[400]; int i; printf("\nNumarul cu semn "); do s=getche(); while((s!='+')&&(s!='-')); n=0; do {x=getche(); t[n]=x-'0'; n++; } while((x>='0')&&(x<='9')); n--; for(i=0;i<n;i++) nr[i]=t[n-i-1]; } //constructor cu initializare prin parametri BigInt::BigInt(char semn,signed char numar[],int dim) {int i; s=semn; n=dim; for(i=0;i<n;i++) nr[i]=numar[n-i-1]; } //transform un int negativ in pozitiv int BigInt::Pozitiv(int x) {int a,vb; a=0; vb=0; while(vb==0) if((x+a)==0) vb=1; else a=a+1; x=a; return x; } //constructor dintr-un nr int obisnuit BigInt::BigInt(int x) {int i; if(x>=0) s='+'…

NUMERE PRIME ALGORITM C++

// NUMERE PRIME ALGORITM C++//  reediting from scratch //on this page is just the study for a next algoritm for generating the parime nr series like Fibonnaci or ....if possibile

74111121313417374414124343447 if u know the red part you can generate the orange part
1 0 1 111112222 1 1 23

o aplicatie php localitati romania

//APLICATIA SE REFERA LA BAZA DE DATE SIRUTA

//dragtable.js


/* dragtable v1.0 June 26, 2008 Dan Vanderkam, http://danvk.org/dragtable/ http://code.google.com/p/dragtable/ \Bsortabledraggable\B Instructions: - Download this file - Add <script src="dragtable.js"></script> to your HTML. - Add class="draggable" to any table you might like to reorder. - Drag the headers around to reorder them. This is code was based on: - Stuart Langridge's SortTable (kryogenix.org/code/browser/sorttable) - Mike Hall's draggable class (http://www.brainjar.com/dhtml/drag/) - A discussion of permuting table columns on comp.lang.javascript Licensed under the MIT license. */ // Here's the notice from Mike Hall's draggable script: //***************************************************************************** // Do not remove this notice. // // Copyright 2001 by Mike Hall. // See http…