Thread: Debug assertion failed error

  1. #1
    Registered User
    Join Date
    Jan 2013

    Debug assertion failed error

    i m using visual studio 2012 and i pass three command line arguments as 10 20 30 and when i m compile the program get error.....need help
    main(int n,char **p)
    	int sum=0,i;

  2. #2

  3. #3
    Registered User
    Join Date
    Jun 2005
    The reason is probably that p[n] will be NULL (so says the standard) so atoi(p[n]) gives undefined behaviour.


    1) it is a bad idea to leave the return type (int) off main().
    2) Neither <conio.h> and getch() are standard in C.
    3) p[0] will (usually) be a string representing the name of the program when run. atoi(p[0]) is valid (as atoi() returns an error if it can't convert its argument to an int) but is probably not a good idea (say, if the first character of the program name contains a digit).
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. One more Debug Assertion Failed! Error
    By ilerleartik in forum C Programming
    Replies: 8
    Last Post: 03-17-2012, 04:49 PM
  2. debug assertion failed
    By khoavo123 in forum C Programming
    Replies: 1
    Last Post: 04-15-2011, 08:21 AM
  3. Debug Assertion Failed error
    By frankchester in forum C Programming
    Replies: 7
    Last Post: 12-02-2010, 09:55 AM
  4. debug assertion failed
    By rahulsk1947 in forum C++ Programming
    Replies: 7
    Last Post: 06-14-2009, 03:36 PM
  5. Debug assertion failed
    By Bajanine in forum Windows Programming
    Replies: 4
    Last Post: 10-17-2002, 04:34 PM