CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 29 of 29
  1. #16
    Join Date
    Mar 2011
    Posts
    20

    Re: need help please

    gggggggggggg
    Last edited by sadam; May 8th, 2011 at 12:18 PM.

  2. #17
    Join Date
    Nov 2008
    Location
    England
    Posts
    748

    Re: need help please

    Most bugs dont cause the compiler to spit out an error. Most occur during runtime. For this you need to attach the debugger and step through your code watching the variables closely as i have already told you. You need to know what to expect, so as to see when something went wrong. When you find variables that hold values that are unexpected, if you are singlestepping your code you will see exactly where it happens and so be able to start working on solving the errors.
    In future as you write each function, test it to ensure what you think is happening is actually what is happening.
    Why cant you debug your code? What compiler and debugger and IDE are you using? Look in the docs for it to see how to work the debugger. Its time for you to learn.
    Get Microsoft Visual C++ Express here or CodeBlocks here.
    Get STLFilt here to radically improve error messages when using the STL.
    Get these two can't live without C++ libraries, BOOST here and Loki here.
    Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
    Always use [code] code tags [/code] to make code legible and preserve indentation.
    Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.

  3. #18
    Join Date
    Mar 2011
    Posts
    20

    Re: need help please

    kkkkkkk
    Last edited by sadam; May 8th, 2011 at 12:19 PM.

  4. #19
    Join Date
    Nov 2008
    Location
    England
    Posts
    748

    Re: need help please

    Nope. Not wierd at all. Learn to use your debugger. Use your debugger.
    Watch this.
    Get Microsoft Visual C++ Express here or CodeBlocks here.
    Get STLFilt here to radically improve error messages when using the STL.
    Get these two can't live without C++ libraries, BOOST here and Loki here.
    Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
    Always use [code] code tags [/code] to make code legible and preserve indentation.
    Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.

  5. #20
    Join Date
    Mar 2011
    Posts
    20

    Re: need help please

    nnn
    Last edited by sadam; May 8th, 2011 at 12:19 PM.

  6. #21
    Join Date
    Apr 1999
    Posts
    27,449

    Re: need help please

    Quote Originally Posted by sadam View Post
    i can't debug my own code because the compiler doesn't post me any error!!
    the error that i have - and as i can see nobody knows how to solve it- is that when i try to run the program, it stops working
    Everyone who has responded to you can solve the issue. The problem is can you solve it? That requires you to just sit down and learn how to debug your program using the debugger that comes with your compiler.

    You didn't do that -- the only thing you did was write a big program, tried to run it, and want us to fix it without any effort on your part to see what is wrong.

    Even if you didn't have a debugger, where are the cout statements to help you to know what the values of variables are, what lines of code you're executing, etc.? This is the harder way to debug, but at least it's something, but you didn't even do that.

    Regards,

    Paul McKenzie

  7. #22
    Join Date
    Apr 1999
    Posts
    27,449

    Re: need help please

    Quote Originally Posted by sadam View Post
    i am using the codeblocks as you told me the previous time, it's weird for a program to have no errors and while running it this stops working, isn't it?
    Code:
    #include <iostream>
    
    int main()
    {
       double x = 1.0;
       double y = x / (x - 1.0);
       std::cout << y;
    }
    This program compiles OK. What do you think happens when y is computed (i.e. a divide by zero happens)? Will the program get to the cout statement?
    Code:
    #include <iostream>
    
    int main()
    {
       char *p = 0;
       *p = 'x';
       std::cout << p;
    }
    This program compiles fine. What do you think happens when you assign a value to a NULL address?

    Just because a program compiles doesn't mean when you run it, everything is OK. Is that what you were expecting, that all programs "work", and there is no need to debug them?

    Regards,

    Paul McKenzie

  8. #23
    Join Date
    Mar 2011
    Posts
    20

    Re: need help please

    rrrrr
    Last edited by sadam; May 8th, 2011 at 12:20 PM.

  9. #24
    Join Date
    Mar 2011
    Posts
    20

    Re: need help please

    tttttt
    Last edited by sadam; May 8th, 2011 at 12:20 PM.

  10. #25
    Join Date
    Aug 2009
    Posts
    440

    Re: need help please

    One, we wouldn't be able to just look at the code and tell what is wrong. We would need to debug it. An IDE will have an option to debug your program. You can set a breakpoint at a line. From there, you will have options to step through the code. When you get to a function, you can either step over that function or step into that function. Really, if you are going to program in C++, using the debugger is a must.

  11. #26
    Join Date
    Mar 2011
    Posts
    20

    Re: need help please

    aaaaaaa
    Last edited by sadam; May 8th, 2011 at 12:21 PM.

  12. #27
    Join Date
    Apr 1999
    Posts
    27,449

    Re: need help please

    Quote Originally Posted by sadam View Post
    after being familiar with the debugger i have managed to use it and it posts me this results:
    Those are not warnings from the debugger. Those are warnings from the compiler when you are building your program.

    The debugger is used when your program has been built, and you are running your program, and you are seeing how your program runs by inspecting the value of variables, setting breakpoints, etc.

    Regards,

    Paul McKenzie

  13. #28
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: need help please

    Quote Originally Posted by sadam View Post
    aaaaaaa
    Someone's thrown their toys out the pram
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  14. #29
    Join Date
    Dec 2009
    Posts
    596

    Re: need help please

    I thought it was to keep the teacher and classmates out of it.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured