Thread: Program on typedef - work around

  1. #1
    Registered User
    Join Date
    Jul 2009
    Kerala, India

    Thumbs up Program on typedef - work around


    Kindly see the snippet below

    typedef int *ptr;
    const ptr p;
    In this p is constant and not the value pointed to by p;

    Suppose if we want to make the value pointed to by p, a constant, what is to be done?

    Last edited by thelink123; 07-24-2009 at 01:29 AM. Reason: Not the explantion, but the work around that is required

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Sydney, Australia
    I believe your only choice is to change the typedef or create a new typedef or not use it:
    typedef const int *ptr;
    ptr p;

  3. #3
    Registered User
    Join Date
    Jul 2009
    Kerala, India
    Thanks cwr

  4. #4
    Join Date
    Oct 2007
    It is best not to use pointers with typedefs because they generally cause confusion. Typedef the actual type, but not the pointer part of the type.
    typedef int myint;
    const myint* p;
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Releasing a program - what is needed? A few Q's
    By ulillillia in forum Tech Board
    Replies: 9
    Last Post: 04-28-2007, 12:18 AM
  2. Replies: 15
    Last Post: 05-13-2006, 09:28 PM
  3. Program closes prematurely. Help needed
    By strategicman in forum C++ Programming
    Replies: 3
    Last Post: 04-12-2006, 03:09 PM
  4. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 08:22 AM
  5. Bug favour needed re: C++ Program
    By Nicole in forum C++ Programming
    Replies: 2
    Last Post: 12-05-2001, 06:13 AM

Tags for this Thread