daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/io.h>
  4.  
  5.  
  6. void main(int argc,char *argv[]){
  7.         int num,i,j;
  8.         char str[5],check_ch,err=0;
  9.  
  10.         if(argc != 2 ){
  11.                 printf("Please enter argument!!\n ex: ./beep 5\n");
  12.                 return ;
  13.         }
  14.  
  15.         for (i=0;i<5;i++){
  16.                 if(argv[1][i] == '\0')
  17.                         break;
  18.                 str[i] = argv[1][i];
  19.         }
  20.         for (j=0;j<i;j++){
  21.                 check_ch = str[j];
  22.                 if((check_ch < 48) || (check_ch > 57)){
  23.             err=1;
  24.             printf("Error!! Please enter the integer argument!!\n");
  25.             return ;
  26.         }
  27.     }
  28.        
  29.     num=atoi(argv[1]);
  30.     iopl(3);
  31.     outb(0x4e, 0xa05);
  32.     outb(0x04, 0xa06);
  33.     outb(0x53, 0xa05);
  34.     outb(0x20, 0xa06);
  35.     sleep(num);
  36.  
  37.     outb(0x53, 0xa05);
  38.     outb(0x00, 0xa06);
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top