Results 1 to 5 of 5

Thread: How should the #include statement be used?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,238

    How should the #include statement be used?

    Is it like this?
    Code:
    #include "thing to be included"
    or this?
    Code:
    #include <thing to be included>
    I've seen both, but I'm not sure which is correct.

    And also what is the "using" statement for? How is it different than "include"? I've seen it used in code examples before but I don't know what it does.

  2. #2
    Addicted Member KingSatan's Avatar
    Join Date
    Feb 2006
    Posts
    185

    Re: How should the #include statement be used?

    im sure both can be used but i usually use <>

    like
    #include<iostream>
    or
    #include<math.h>

  3. #3
    Hyperactive Member Max Peck's Avatar
    Join Date
    Oct 2007
    Posts
    384

    Re: How should the #include statement be used?

    It's been a few years since I used C ... OK, ten ... but the difference is the location in which the included resource is found:

    #include <stdio.h> // Locates and loads stdio.h in where the LIB environment variable points to.
    #include "stdio.h" // Loads stdio.h in the current directory.

    -Max
    The name's "Peck" .... "Max Peck"

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,238

    Re: How should the #include statement be used?

    Quote Originally Posted by Max Peck View Post
    It's been a few years since I used C ... OK, ten ... but the difference is the location in which the included resource is found:

    #include <stdio.h> // Locates and loads stdio.h in where the LIB environment variable points to.
    #include "stdio.h" // Loads stdio.h in the current directory.

    -Max
    In which situation should I use each? They both seem to work when I tried it for the same use in the program.

  5. #5
    Hyperactive Member Max Peck's Avatar
    Join Date
    Oct 2007
    Posts
    384

    Re: How should the #include statement be used?

    Quote Originally Posted by Ben321 View Post
    In which situation should I use each? They both seem to work when I tried it for the same use in the program.
    I would use #include "resource.h" with header files I've created because I'll generally place them in the same folder with the project.

    #include <resource.h> is for standard library includes that you don't modify.

    -Max
    The name's "Peck" .... "Max Peck"

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width