trying to do simple math with float and int type

This is a discussion on trying to do simple math with float and int type within the C Programming forums, part of the General Programming Boards category; Originally Posted by citizen There is no reason to "beware of pointers;" they are not treated differently than any other ...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,420
    Quote Originally Posted by citizen View Post
    There is no reason to "beware of pointers;" they are not treated differently than any other variable if we are discussing implications of local scope. Copies of pointers are generated if they are arguments to functions, too.
    I was thinking of that pointers can actually store addresses of variables, and pointers can generally hold a heap allocation, thus breaking the whole local chain.
    Even if you pass a pointer to some stuff, none is to say that this pointer is used elsewhere, too.
    Pointers are flexible and powerful and therefore comes at a price.

    Absolutely C knows the types of variables passed to functions because that information is available from the parameter list. The only contexts in which it isn't available include variadic functions (such as printf) and macro functions. Just wanted to clear that up, since this piece of advice is more about printf than it is about C or variables in general.
    Oh yes, good point.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,627
    Quote Originally Posted by Elysia View Post
    I was thinking of that pointers can actually store addresses of variables, and pointers can generally hold a heap allocation, thus breaking the whole local chain.
    Even if you pass a pointer to some stuff, none is to say that this pointer is used elsewhere, too.
    Pointers are flexible and powerful and therefore comes at a price.
    The memory a pointer points to may be from the heap but that is practically irrelevant since the pointer itself can have a different, more defined scope. If it were not so, then you could not incur a memory leak because some pointer fell out of scope.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 12:05 PM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 04:26 PM

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