Quick question

This is a discussion on Quick question within the C++ Programming forums, part of the General Programming Boards category; Hi, I am getting into pointer and linked lists now! Here is my question, Code: int *x; int *y = ...

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    40

    Quick question

    Hi, I am getting into pointer and linked lists now!
    Here is my question,

    Code:
    int *x;
    int *y = new int;
    If I am reading this chapter right, this just allocates memory it does not initialize memory, am I right???
    Thanks!!!

  2. #2
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    yea thats right... the memory you allocated might hold some junk value..

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >am I right???
    You are indeed. Or to be more precise, x is uninitialized and points to nothing usable and y points to enough memory for an integer.
    My best code is written with the delete key.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >"char" by default is signed, right?
    No, char could be either signed or unsigned by default.
    My best code is written with the delete key.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    > "char" by default is signed, right?
    You don't listen very well do you?
    2 simple questions
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >You don't listen very well do you?
    No, I just think he fills his brain up with all kinds of trivia and then forgets.
    My best code is written with the delete key.

  7. #7
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    I'd be surprised if he's written a single program yet, I think he's skipping that part and going straight to the "I'm gonna write a programming encyclopedia" part. No offense C++Forever.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  8. #8
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >I think he's skipping that part and going straight to the "I'm gonna write a programming encyclopedia" part.
    He's doing such a good job of picking my brain it's either that or he's testing us here at Cprogramming to see what we know.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM

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