Bad Practice??

This is a discussion on Bad Practice?? within the C Programming forums, part of the General Programming Boards category; Hi Below is the start of a small piece of code with just two includes. Time is to seed the ...

  1. #1
    Unregistered
    Guest

    Unhappy Bad Practice??

    Hi
    Below is the start of a small piece of code with just two includes.
    Time is to seed the random number and conio.c is for every thing
    else.Is it right to just use conio.c as this includes stdio.h ,conio.h or by including conio.c am I making the
    compiler do more work than it should ???

  2. #2
    Unregistered
    Guest

    Unhappy

    opps forgot the code snippet

    #include <time.h>
    #include <conio.c>
    int main (void)
    {
    int counter = 0;
    int x;
    srand( (unsigned)time( NULL ) );

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,420
    > am I making the compiler do more work than it should ???
    Probably - you should not include .c files, but instead add them to the project or makefile.

    Whatever includes conio.c has shouldn't matter (nor should you care), and you certainly shouldn't depend on it including specific things.

    In your main.c, if you need
    #include <stdio.h>
    #include <time.h>
    #include <conio.h>
    Then you should do so, and you are free to remove them if you no longer require that .h file (to compile the current file).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How bad is bad
    By caroundw5h in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 11-12-2004, 08:26 AM
  2. Bad practice or acceptable?
    By Noose in forum C++ Programming
    Replies: 6
    Last Post: 06-09-2004, 01:43 AM
  3. Replies: 11
    Last Post: 11-13-2002, 12:29 PM
  4. good news and bad news
    By Garfield in forum A Brief History of Cprogramming.com
    Replies: 25
    Last Post: 10-27-2001, 07:31 AM
  5. Bad code or bad compiler?
    By musayume in forum C Programming
    Replies: 3
    Last Post: 10-22-2001, 09:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21