Thread: What is used instead of dos.h header file

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    208

    What is used instead of dos.h header file

    I have a question I get this error can't include dos.h header.
    I am compiling on a 64 bit computer with a amd processor using window 7 trying to make a 64 bit.exe.

    here's the code, actually I got this from a book and can't get it to run.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #include <dos.h>
    
    #define FACE 0x01
    #define LOOP 100
    #define PAUSE 150000
    #define VIDEO 0x10
    #define COLS 80
    #define ROWS 25
    
    void cls(void);
    void locate(int col, int row);
    int rnd(int range);
    void seedrnd(void);
    
    void main();
    {
    	int t,x,y;
    	unsigned long p;
    
    	cls();
    	seedrnd();
    
    	for(t=0;t<LOOP;t++)
    	{
    		x=rnd(80)+1;
    		y=rnd(25)+1;
    		locate(x,y);
    		putchar(FACE);
    	}
    
    	void cls(void)
    	{
    		union REGS regs;
    
    		regs.h.ah=0x06;
    		regs.h.al=0x00;
    		regs.h.bh=0x07;
    		regs.h.ch=0x00;
    		regs.h.cl=0x00;
    		regs.h.dh=ROWS 1;
    		regs.h.dl=COLS 1;
    		int86(VIDEO,&regs,&regs);
    		locate(0,0);
    	}
    
    	void locate(int col, int row)
    	{
    		union REGS regs;
    
    		regs.h.ah=0x02;
    		regs.h.bh=0x00;
    		regs.h.dh=row;
    		regs.h.dl=col;
    		int86(VIDEO, &regs,&regs);
    	}
    
    	int rnd(int range)
    	{
    		int r;
    		r=rand()%range;
    		return(r);
    	}
    
    	void seedrnd(void)
    	{
    		srand((unsigned)time(NULL));
    	}

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    I doubt dos.h can be used (or is part of the library that comes) with any modern compilers. That header was designed for use with DOS, an old operating system. Probably Turbo C or another old school compiler will allow it.

  3. #3
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Show us the actual errors and maybe we can help find modern alternatives. This is the problem with legacy platform-specific code: there can be some really cool nuggets of functionality lost to the sands of time due to reliance on old build environments. I am guessing the int86() call is biting you in the bum...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    208

    Here's the error

    Building Dibble.obj.
    C:\Users\artist\Documents\Pelles C Projects\Dibble.c\Dibble.c(4): fatal error #1035: Can't find include file <dos.h>.
    *** Error code: 1 ***
    Done.
    I'm using pelles c compiler

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    208

    I have a bad feeling about this program

    I guessing the code would have to be totally rewritten to implement this program I shouldn't have bought this book but sometimes you can learn things from old books

  6. #6
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by artistunknown View Post
    I guessing the code would have to be totally rewritten to implement this program I shouldn't have bought this book but sometimes you can learn things from old books
    Yeah, like history, which can be interesting but may not get you to work on time. Are those nested functions in main()? I don't think this is legal in C anymore.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    208
    I forgot the last } but yeah its in main() oh well do you guys have any suggestions for a modern C book. I could buy.

  8. #8
    Registered User
    Join Date
    Jan 2010
    Posts
    208
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #include <dos.h>
    
    #define FACE 0x01
    #define LOOP 100
    #define PAUSE 150000
    #define VIDEO 0x10
    #define COLS 80
    #define ROWS 25
    
    void cls(void);
    void locate(int col, int row);
    int rnd(int range);
    void seedrnd(void);
    
    void main();
    {
    	int t,x,y;
    	unsigned long p;
    
    	cls();
    	seedrnd();
    
    	for(t=0;t<LOOP;t++)
    	{
    		x=rnd(80)+1;
    		y=rnd(25)+1;
    		locate(x,y);
    		putchar(FACE);
    
    		for(p=0;p<PAUSE;p++)
    	}
    }
    
    	void cls(void)
    	{
    		union REGS regs;
    
    		regs.h.ah=0x06;
    		regs.h.al=0x00;
    		regs.h.bh=0x07;
    		regs.h.ch=0x00;
    		regs.h.cl=0x00;
    		regs.h.dh=ROWS 1;
    		regs.h.dl=COLS 1;
    		int86(VIDEO,&regs,&regs);
    		locate(0,0);
    	}
    
    	void locate(int col, int row)
    	{
    		union REGS regs;
    
    		regs.h.ah=0x02;
    		regs.h.bh=0x00;
    		regs.h.dh=row;
    		regs.h.dl=col;
    		int86(VIDEO, &regs,&regs);
    	}
    
    	int rnd(int range)
    	{
    		int r;
    		r=rand()%range;
    		return(r);
    	}
    
    	void seedrnd(void)
    	{
    		srand((unsigned)time(NULL));
    	}
    
    
    I didn't copy the code correctly and all the function are suppose to be outside of main() sorry about that sometimes I get in a rush

  9. #9
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Out of pure curiosity what book is this?

    Anyway, there's this book on line:
    The C Book - Table of Contents

    Maybe it is not so good if you are a complete beginner to programming*, or if you could not put up with this:
    The input from so many varied sources has spawned a language a bit like a cross-bred terrier: inelegant in places, but a tenacious brute that the family is fond of. Biologists refer to this phenomenon as ‘hybrid vigour’. They might also draw your attention to the ‘chimera’, an artificial crossbreed of creatures such as a sheep and a goat. If it gives wool and milk, fine, but it might equally well just bleat and stink!

    At the coarsest level, an obvious feature is the multi-file structure of a program. The language permits separate compilation, where the parts of a complete program can be kept in one or more source files and compiled independently of each other.
    Also the "K&R" book seems to have beneficial impact:
    http://en.wikipedia.org/wiki/The_C_P...Language_(book)
    I'm sure that's available cheaply online if not at some library somewhere.

    * in that case maybe go for a "teach yourself C in 30 days" kind of book.
    Last edited by MK27; 04-18-2010 at 04:21 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  10. #10
    Registered User
    Join Date
    Jan 2010
    Posts
    208

    I check out your other suggestions

    That's over my head! hee hee!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  4. Replies: 6
    Last Post: 04-02-2002, 05:46 AM