Rusty with c++ need some help with errors involving pointers and stuff

This is a discussion on Rusty with c++ need some help with errors involving pointers and stuff within the C++ Programming forums, part of the General Programming Boards category; - thats just ugly and more work than required and since its now almost 2 a.m. and i'm running on ...

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,313
    - thats just ugly and more work than required and since its now almost 2 a.m. and i'm running on 2 hours of sleep definately feeling lazy :-P
    As you wish. I will not be helping you until you fix that. Global variables make your code more difficult to trace.

    - actually the assignment description says to call them that.... sure i doubt i'd lose points if i did use something else, but i've also got this algorithm memorized with pi, d, and f so works for me
    Okay, in that case you should at least provide comments to state their proper names.

    -doesn't matter for this class...
    As you wish. I will not be helping you until you fix that. Your lecturer chose C++ instead of Java, so write your C++ code like C++, not Java.

    -int option=0;
    while (option!=3)
    nope looks initialized before use to me :-P
    In your updated code, yes. That's good.

    It is quite simple: if you want help, do things correctly when asked to do so. If not, then as you have admitted, you are lazy and do not deserve help.

    EDIT:
    In fact, I suspect that the use of global variables is indirectly related to your current problem. You are simply having difficulty tracing the code yourself.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Registered User
    Join Date
    Mar 2008
    Posts
    25
    well thats pretty cruel..... thanks for the help you did give me

    guess i'll hope someone else is willing to figure out why color[u->data]="gray"; is causing a seg fault, or i'll seek help elsewhere

    for now i desperately need sleep

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,033
    For now, you desperately need to fix your problems. If you don't, you will not learn. This is C++, not Java. Welcome to C++.
    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.

  4. #19
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,313
    well thats pretty cruel.....
    Not really. If I were to start helping you any further, the first thing I would do is fix those problems so I can understand your code more easily.

    thanks for the help you did give me
    You're welcome.

    for now i desperately need sleep
    Yeah, rest is usually a good idea if you need it
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #20
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by JJJIrish05 View Post
    guess i'll hope someone else is willing to figure out why color[u->data]="gray"; is causing a seg fault
    What compiler are you using? Do you know how to use an interactive debugger? My guess is that you are either accessing color out of bounds (what is the value of u->data?), or u is NULL or points to some random address.

  6. #21
    Registered User
    Join Date
    Mar 2008
    Posts
    25
    added the deletes to fix that stuff.....

    &u->data prints out 0 and u->data seg faults.... why?

    I'm using gcc on a linux machine to compile, never used a debugger

  7. #22
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by JJJIrish05 View Post
    &u->data prints out 0 and u->data seg faults.... why?
    Because u doesn't point to anything, it is 0. 0->data is what is causing your seg fault.

    I'm using gcc on a linux machine to compile, never used a debugger
    You should learn how to use gdb, the Gnu debugger.

  8. #23
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,033
    I won't testify as to which debugger is the best, but I prefer Visual Studio. Easy to setup, easy to get used to.
    No need to remember command lines or search for an appropriate gui for it.
    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.

  9. #24
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,657
    If you require a graphical debugger under *nix, you can also use ddd, or Code::Blocks, which is cross-platform.

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

Similar Threads

  1. returning pointers
    By spudval in forum C++ Programming
    Replies: 4
    Last Post: 07-11-2007, 03:12 PM
  2. References vs Pointer vs copying and storing stuff in classes
    By Monkeymagic in forum C++ Programming
    Replies: 20
    Last Post: 09-01-2006, 10:40 AM
  3. kinda wierd stuff with pointers...
    By Noobwaker in forum C Programming
    Replies: 4
    Last Post: 04-17-2006, 03:21 PM
  4. delete and delete[]
    By Hunter2 in forum C++ Programming
    Replies: 13
    Last Post: 06-26-2003, 05:40 AM

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