Modifying stdio.h

This is a discussion on Modifying stdio.h within the C Programming forums, part of the General Programming Boards category; after creating a function, is it possible to put it in the stdio.h library or is it better to create ...

  1. #1
    Registered User Spectrum48k's Avatar
    Join Date
    May 2002
    Posts
    66

    Question Modifying stdio.h

    after creating a function, is it possible to put it in the stdio.h library or is it better to create a diferent library of functions ?
    (eg stdio2.h wich will be the modified stdio.h)
    i am kinda new programming, i am far from doing stuff like this, but i am just curious.

    Thnx in advance !

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    Never modify anything which comes with the compiler.

    If you've got something useful you want to reuse, create your own header and library files

  3. #3
    Registered User Spectrum48k's Avatar
    Join Date
    May 2002
    Posts
    66

    stdio.h

    so is it ok to say:

    #include <stdio.h>
    #include <custom.h>

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    Looks good

  5. #5
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > or is it better to create a diferent library of functions ?
    Could we see what you plan on putting in the header file?
    You may want to just put your reusable code in a source file, and just link it to the rest of your program.

    Lets see what you plan on putting in your actual custom.h file first though.
    If you need help on other stuff, we can give a general explanation.
    The world is waiting. I must leave you now.

  6. #6
    Registered User Spectrum48k's Avatar
    Join Date
    May 2002
    Posts
    66

    Shadow

    i dont intend to modify anything at this point. because i know functions are sort of like sub-programs, and cound be used over and over, i was curious if they could be put in a "custom" library to be re-used in other programs i write (well, the programs i one day wish to be able to write)

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Actually, this is exactly what I do. I group the functions by type an store them in appropriately named custom headers.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  8. #8
    Registered User alpha561's Avatar
    Join Date
    May 2002
    Posts
    18
    >>i dont intend to modify anything at this point. because i know functions are sort of like sub- programs, and cound be used over and over, i was curious if they could be put in a "custom" library to be re-used in other programs i write (well, the programs i one day wish to be able to write<<

    With any non-trivial program it is always good to keep your main code as small as possible. You should just then call in functions from another file.

    Example:

    Code:
    #include <stdio.h>
    #include "common.h"       /* commonly used routines */
    #include "insertionsort.h"/* list operations and insertion sort function */
    alpha561

    "You don't want to sell me death sticks"

  9. #9
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    I NEED to say something!


    first off: it depends on the compiler if you are allowed to do this.
    Some compilers actually read the Standard headerfiles for the prototypes and actually get the rest from object files. (some compilers)
    otherwise you should be able to however, I am going to strongly request that you do not.
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  10. #10
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225

    Lightbulb

    You can store your function bodies in headers. I usually do that. After all, I use the compiler's IDE, not the command-line.
    All men are created equal. But some are more equal than others.

    Visit me at http://www.angelfire.com/my/billholm

  11. #11
    *
    Guest
    You can modify compiler headers if there is a bug in them. Comment out the bad info, and tell _why_ and _when_ the change was made.

    Otherwise, if you want to have a custom set of reusable functions, create your on library and matching headerfile. Put them in their own directory in the compiler's path.

    Never put sourcecode in a headerfile, unless it is a macro. Sourcecode _always_ belongs in '.c' files. Headers are for the Linker's use, to satisfy symbol-table address and references.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error: stdio.h: No such file or directory
    By MindLess in forum C Programming
    Replies: 9
    Last Post: 12-20-2007, 08:11 AM
  2. getting error "unable to open include stdio.h
    By coolgal in forum C Programming
    Replies: 18
    Last Post: 12-07-2007, 01:36 AM
  3. stdio.h
    By Vertex34 in forum C Programming
    Replies: 2
    Last Post: 07-12-2004, 11:18 AM
  4. error in -stdio.h __VALIST
    By JaWiB in forum C++ Programming
    Replies: 3
    Last Post: 09-20-2003, 01:22 PM
  5. modifying strings
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 10-13-2001, 01:36 PM

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