Thread: Header File process.h

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    19

    Header File process.h

    I wrote this program and my teacher wont accept this because i used
    Code:
    #include<process.h>
    . How can i make this program run without this header.
    Can i replace it with something else



    Code:
    #include <stdio.h>
    #include <math.h>
    #include<process.h>
    
    
    int main()
    {
        char variable;
        float d= 0.00;
        float sqvelocity =0.00;
        float sqtime =0.00;
        clrscr();
        do
        {
            printf("\nEnter a value for distance:");
            scanf("%f",&d);
            sqvelocity= sqrt(2*9.8*d);
            sqtime= sqrt((2*d)/9.8);
            printf("\nEnter variable for desired computation, \nv (velocity) or \nt (time) \ne (exit) \n\t");
            scanf(" %c", &variable);
            
            switch(variable)
            {
                case 'v': printf("the velocity is: %lf.\n", sqvelocity);
                    break;
                case 't': printf("the time is: %lf.\n", sqtime);
                    break;
                case 'e': exit(1);
                    break;
                default: printf("\nEnter right choice");
            }
        }while(1);
        getch();
        return (0);
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Then get rid of that header inclusion since you don't need it here. You also don't need clrscr and getch, so get rid of them. Since you use exit, you should #include <stdlib.h>, but then it would be simpler to just return 1;
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    29
    If you want to remove
    Code:
    #include<process.h>
    Simply remove the
    Code:
    exit(1);
    from your code as you already used
    Code:
    break; //in case 'e'
    It'll work fine.

  4. #4
    Registered User
    Join Date
    Oct 2012
    Posts
    19
    thanks

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    exit() is in stdlib.h, if that's what you want to do.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 30
    Last Post: 06-19-2006, 12:35 AM
  2. Including header file with in the header file
    By Arafat_211184 in forum C Programming
    Replies: 13
    Last Post: 12-19-2005, 10:03 AM
  3. Replies: 4
    Last Post: 12-14-2005, 02:21 PM
  4. Process sending file descriptors to another process
    By Yasir_Malik in forum C Programming
    Replies: 4
    Last Post: 04-07-2005, 07:36 PM
  5. Replies: 6
    Last Post: 04-02-2002, 05:46 AM