473,387 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Using clrscr() without conio.h header file

hi friends,
I've a small doubt. can u help me? is it possible for clrscr() to work without conio header file.I found its working but i dono how its possible.If u've answer pls reply.
Nov 14 '08 #1
8 11812
r035198x
13,262 8TB
You can define your own function called clrscr() and it would "work".
Nov 14 '08 #2
its not about defining our own functions for clrscr(). I jus found that clrscr function working without conio(header file). and i jus want to know is it possible? and how?
Nov 14 '08 #3
r035198x
13,262 8TB
It's not a standard function. You have to have included some header file where it was defined for it to work.
Nov 14 '08 #4
Banfa
9,065 Expert Mod 8TB
Actually in C there is no requirement for a function to be declared before it is called if the required library is included in the link then there would be no need to include the header in the source.

Doing this is very very bad practice.
Nov 14 '08 #5
yes it is true that clrscr() function will be in conio.h
but some times compiler will include this hedder file automatically, i have faced same situation 2years back.Still its our responsibility to include all hedder files where our function definitions are there.
so dont waste time on this things.
Nov 14 '08 #6
arnaudk
424 256MB
yes it is true that clrscr() function will be in conio.h
but some times compiler will include this hedder file automatically, i have faced same situation 2years back.Still its our responsibility to include all hedder files where our function definitions are there.
so dont waste time on this things.
Including the header file is not the issue. Read post #5 carefully. So long as the required library is linked then the code will work in principle, although this is a really sloppy way of doing things.
If you turn more compiler warnings, your compiler will probably warn you that you are using a function without declaring it which is bad practice.

Aside from this, it's possible that the conio.h header is included anyway by some other headers but don't take that for granted.
Nov 14 '08 #7
Thanks for ur replies.i found them really helpful.
Nov 15 '08 #8
Step1: backup conio.h in "Include" folder of compiler.
Step2: Overwrite following code in to conio.h:

Expand|Select|Wrap|Line Numbers
  1. /*  conio.h
  2.  
  3.     Direct MSDOS console input/output.
  4.  
  5.     Copyright (c) 1987, 1992 by Borland International
  6.     All Rights Reserved.
  7. */
  8.  
  9. #if !defined(__CONIO_H)
  10. #define __CONIO_H
  11.  
  12. #if !defined(___DEFS_H)
  13. #include <_defs.h>
  14. #endif
  15.  
  16. #if !defined(_Windows)
  17.  
  18. #define _NOCURSOR      0
  19. #define _SOLIDCURSOR   1
  20. #define _NORMALCURSOR  2
  21.  
  22. struct text_info {
  23.     unsigned char winleft;
  24.     unsigned char wintop;
  25.     unsigned char winright;
  26.     unsigned char winbottom;
  27.     unsigned char attribute;
  28.     unsigned char normattr;
  29.     unsigned char currmode;
  30.     unsigned char screenheight;
  31.     unsigned char screenwidth;
  32.     unsigned char curx;
  33.     unsigned char cury;
  34. };
  35.  
  36. enum text_modes { LASTMODE=-1, BW40=0, C40, BW80, C80, MONO=7, C4350=64 };
  37.  
  38. #if !defined(__COLORS)
  39. #define __COLORS
  40.  
  41. enum COLORS {
  42.     BLACK,          /* dark colors */
  43.     BLUE,
  44.     GREEN,
  45.     CYAN,
  46.     RED,
  47.     MAGENTA,
  48.     BROWN,
  49.     LIGHTGRAY,
  50.     DARKGRAY,       /* light colors */
  51.     LIGHTBLUE,
  52.     LIGHTGREEN,
  53.     LIGHTCYAN,
  54.     LIGHTRED,
  55.     LIGHTMAGENTA,
  56.     YELLOW,
  57.     WHITE
  58. };
  59. #endif
  60.  
  61. #define BLINK       128 /* blink bit */
  62.  
  63. extern   int _Cdecl directvideo;
  64. extern   int _Cdecl _wscroll;
  65.  
  66. #endif   /* !_Windows */
  67.  
  68. #ifdef __cplusplus
  69. extern "C" {
  70. #endif
  71.  
  72. void        _Cdecl clreol( void );
  73. void        _Cdecl clrscr( void );
  74. void        _Cdecl gotoxy( int __x, int __y );
  75. int         _Cdecl wherex( void );
  76. int         _Cdecl wherey( void );
  77. int         _Cdecl getch( void );
  78. int         _Cdecl getche( void );
  79. int         _Cdecl kbhit( void );
  80. int         _Cdecl putch( int __c );
  81.  
  82. #ifndef _PORT_DEFS
  83. unsigned char   _Cdecl inportb( unsigned __portid );
  84. unsigned        _Cdecl inport ( unsigned __portid );
  85. int             _Cdecl inp( unsigned __portid );
  86. unsigned        _Cdecl inpw( unsigned __portid );
  87. void            _Cdecl outportb( unsigned __portid, unsigned char __value );
  88. void            _Cdecl outport ( unsigned __portid, unsigned __value );
  89. int             _Cdecl outp( unsigned __portid, int __value );
  90. unsigned        _Cdecl outpw( unsigned __portid, unsigned __value );
  91. #endif  /* !_PORT_DEFS */
  92.  
  93. #if !defined(_Windows)
  94.  
  95. void        _Cdecl delline( void );
  96. int         _Cdecl gettext( int __left, int __top,
  97.                             int __right, int __bottom,
  98.                             void *__destin);
  99. void        _Cdecl gettextinfo (struct text_info *__r );
  100. void        _Cdecl highvideo( void );
  101. void        _Cdecl insline( void );
  102. void        _Cdecl lowvideo( void );
  103. int         _Cdecl movetext( int __left, int __top,
  104.                              int __right, int __bottom,
  105.                              int __destleft, int __desttop );
  106. void        _Cdecl normvideo( void );
  107. int         _Cdecl puttext( int __left, int __top,
  108.                             int __right, int __bottom,
  109.                             void *__source );
  110. void        _Cdecl textattr( int __newattr );
  111. void        _Cdecl textbackground( int __newcolor );
  112. void        _Cdecl textcolor( int __newcolor );
  113. void        _Cdecl textmode( int __newmode );
  114. void        _Cdecl window( int __left, int __top, int __right, int __bottom);
  115.  
  116. void        _Cdecl _setcursortype( int __cur_t );
  117. char * _Cdecl cgets( char *__str );
  118. int         _Cdecl cprintf( const char *__format, ... );
  119. int         _Cdecl cputs( const char *__str );
  120. int         _Cdecl cscanf( const char *__format, ... );
  121. char * _Cdecl getpass( const char *__prompt );
  122. int         _Cdecl ungetch( int __ch );
  123.  
  124. #endif  /* !_Windows */
  125.  
  126. #ifndef _PORT_DEFS
  127. #define _PORT_DEFS
  128.  
  129.     /* These are in-line functions.  These prototypes just clean up
  130.        some syntax checks and code generation.
  131.      */
  132. unsigned char   _Cdecl  __inportb__ (unsigned __portid);
  133. unsigned        _Cdecl  __inportw__ (unsigned __portid);
  134. unsigned char   _Cdecl  __outportb__(unsigned __portid, unsigned char __value);
  135. unsigned        _Cdecl  __outportw__(unsigned __portid, unsigned __value);
  136.  
  137. #define inportb(__portid)           __inportb__(__portid)
  138. #define outportb(__portid, __value) ((void) __outportb__(__portid, __value))
  139. #define inport(__portid)            __inportw__(__portid)
  140. #define outport(__portid, __value)  ((void) __outportw__(__portid, __value))
  141.  
  142. /* MSC-compatible macros for port I/O */
  143. #define inp(__portid)               __inportb__ (__portid)
  144. #define outp(__portid, __value)     __outportb__(__portid, (unsigned char)__value)
  145. #define inpw(__portid)              __inportw__ (__portid)
  146. #define outpw(__portid, __value)    __outportw__(__portid, __value)
  147.  
  148. #endif  /* _PORT_DEFS */
  149.  
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153.  
  154.  
  155. #endif  /* __CONIO_H */
  156.  
Step3: Save conio.h and restart compiling.
Enjoy!
--
Oct 8 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

31
by: Developwebsites | last post by:
/* why doesnt char* city; work when entering a string, but char city; does? I have to store city names and their temps in an array, and then output all info. how do i utilize arrays in this...
1
by: AHR | last post by:
Hi NG I am learning MFC but only use the command promt at the moment to run my C++ programs. My problem is that i cant use clrscr() even if i include <conio.h>. I get this error: ****
6
by: hpy_awad | last post by:
I am writing stings ((*cust).name),((*cust).address)to a file using fgets but rabish is being wrote to that file ? Look to my source please and help me finding the reason why this rabish is being...
2
by: lavender | last post by:
In C programming, izzit got this function 1. clrscr( ); ? what header file I should use? 2. <conio.h> I donnon C programming have this header file or not, which I know is in ...
1
by: bluesteel | last post by:
Hi guys. I have programmed in c and use clrscr() from conio.h. The problem was that, when i started programming under c++ i found that clrscr is nonexistant! Even if i include conio.h it will not...
13
by: Albert | last post by:
Hi I'm using the lcc compiler for win32. I tried compiling a program but there's an error stating: "cpp: Can't open input file clrscr()" I don't get it - I've included <tcconio.h>. (strange why...
3
by: rahul1989 | last post by:
can we use clrscr() function without using conio.h header file
2
by: naughtysriram | last post by:
what are the equivalent library functions found in conio.h (turbo c++) for other gnu c++ variations.. i need functions like gotoxy(), clrscr(), getch()...etc. thanks in advance
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.