Loading

Archive for 25 Oct 2012

C - Program cprintf Example


cprintf Example


#include <conio.h>

int main(void)
{
   /* clear the screen */
   clrscr();

   /* create a text window */
   window(10, 10, 80, 25);

   /* output some text in the window */
   cprintf("Hello world\r\n");

   /* wait for a key */
   getch();
   return 0;
}

Posted in | Leave a comment

C - Program Putch Example


Putch Example



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

int main(void)
{
   char ch = 0;

   printf("Input a string:");
   while ((ch != '\r'))
   {
      ch = getch();
      putch(ch);
   }
   return 0;
}

Posted in | Leave a comment

C - Program - Getch Example

Getch Example




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

int main(void)
{
  int c;
  int extended = 0;
  c = getch();
  if (!c)
    extended = getch();
  if (extended)
    printf("The character is extended\n");
  else
    printf("The character isn't extended\n");

  return 0;
}

Posted in | Leave a comment

C - Program - Getche Example

Getche Example



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

int main(void)
{
   char ch;

   printf("Input a character:");
   ch = getche();
   printf("\nYou input a '%c'\n", ch);
   return 0;
}

Posted in | Leave a comment

C- Program - Putc Example


Putc Example


#include <stdio.h>

int main(void)
{
   char msg[] = "Hello world\n";
   int i = 0;

   while (msg[i])
      putc(msg[i++], stdout);
   return 0;
}

Posted in | Leave a comment

C - Program - Getc Example

Getc Example


#include <stdio.h>

int main(void)
{
   char ch;

   printf("Input a character:");
/* read a character from the standard input stream */
   ch = getc(stdin);
   printf("The character input was: '%c'\n", ch);
   return 0;
}

Posted in | Leave a comment