Thread: Exam question help

  1. #106
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by Overworked_PhD View Post
    This is the same reason why the standard uses the term 'object' instead of 'variable'. This is because a variable is a specific example of an object. However, there are objects, aren't variables. For example, what gets returned by malloc().
    Speaking of malloc, guess what malloc returns.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  2. #107
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Quote Originally Posted by claudiu View Post
    Speaking of malloc, guess what malloc returns.
    Hahahahaha. I knew that was coming.

  3. #108
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by Overworked_PhD View Post
    MK27 cited the standard. If there was zero possibility of a pointer holding something other than an address, then this would have been stated. But it isn't.
    Ok, so then you should be able to give me an example yes?
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  4. #109
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Quote Originally Posted by claudiu View Post
    Ok, so then you should be able to give me an example yes?
    Geeze man, yet you say that I'm the uneducated one when it comes to computer programming.

  5. #110
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by Overworked_PhD View Post
    Geeze man, yet you say that I'm the uneducated one when it comes to computer programming.
    That's because you are.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  6. #111
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Well, the standard does not say that not saying something makes it false, just that the standard doesn't promise it's true. Of course, if you were to do some more in depth analysis (which the standard is not all that interesting) you might be able to demonstrate something logically about a pointer being equivalent to a memory address.

    BUT, IMO memory addresses are not really significant in normative C programming. What is significant it the concept of "reference to" an existing entity of some type.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  7. #112
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Quote Originally Posted by Overworked_PhD View Post
    Geeze man, yet you say that I'm the uneducated one when it comes to computer programming.
    So in other words, you aren't going to tell us what's up.

    I don't know what you're problem is specifically with me but I just want to understand what you're talking about. Don't get bent out of shape about what side I'm on, I think you're older than that. I'm simply asking for additional knowledge and if you don't want to share it then kindly don't bring it up in a public forum to brag.

  8. #113
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Quote Originally Posted by MK27 View Post
    Well, the standard does not say that not saying something makes it false, just that the standard doesn't promise it's true. Of course, if you were to do some more in depth analysis (which the standard is not all that interesting) you might be able to demonstrate something logically about a pointer being equivalent to a memory address.

    BUT, IMO memory addresses are not really significant in normative C programming. What is significant it the concept of "reference to" an existing entity of some type.
    I guess I don't see the significance of such an exercise. Who knows. I'll sleep on this tonight. Maybe when I wake up in the morning, I will see the significance of it. But right now, I don't.

  9. #114
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by Overworked_PhD View Post
    I guess I don't see the significance of such an exercise. Who knows. I'll sleep on this tonight. Maybe when I wake up in the morning, I will see the significance of it. But right now, I don't.
    Try not to troll-bomb a thread into 8 pages of nonsense next time you don't see the point of something. You will be argued with if you say stupid things.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  10. #115
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Maybe when I wake up in the morning, I will see the significance of it.
    Actually bub, all you're going to see from now on is 6 letters beginning with 'b'.

    Consider this an opportunity to be less overworked.

    Bye troll.
    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.

  11. #116
    Registered User
    Join Date
    Apr 2010
    Posts
    16
    Uhh... Am I still in the right thread?

    But seriously, could someone give me an answer so I can see where I'm going wrong please?

  12. #117
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    ÉireKarl, I apologise on behalf of this community for the mess that this thread has become. I am going to close this thread. I suggest that you start a new one with your current question.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  3. sort problem for an exam
    By rjeff1804 in forum C Programming
    Replies: 10
    Last Post: 02-12-2003, 10:33 PM
  4. another exam question
    By rjeff1804 in forum C Programming
    Replies: 4
    Last Post: 02-12-2003, 10:29 PM
  5. The AP Exam.....
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 32
    Last Post: 02-10-2003, 09:46 PM

Tags for this Thread