Assertion Failure w/ sprintf

This is a discussion on Assertion Failure w/ sprintf within the Windows Programming forums, part of the Platform Specific Boards category; OK, im using sprintf, what im doing is taking what's in my combo box and edit boxes, and putting them ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    215

    Assertion Failure w/ sprintf

    OK, im using sprintf, what im doing is taking what's in my combo box and edit boxes, and putting them into one char array, so im using sprint f, and all the things are there in the chars. but it keeps giving me an assertion failure.

    here's the code:

    Code:
    sprintf(time_on,"%s%s%s%s%s%s",year,month,day,hour,min,sec);
    in this year is equal to 2004, month is equal to january and so on. i used the debugger to check if the data was coming in, and they all were. time_on is equal to "". i dont know if thats whats causing it, but i hope someone can help me.

    thanks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    Are year,month,day,hour,min,sec all strings?
    If not, then change some of the %s to reflect the data types you want to format
    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.

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    215
    Yeah, they are all strings

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    > time_on is equal to "".
    Paste what you mean then

    It needs to be
    char time_on[1000];
    or something like it

    char *time_on = "";
    Simply isn't good enough
    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.

  5. #5
    Registered User
    Join Date
    May 2004
    Posts
    215
    I made it the way you stated about like this:

    Code:
    char time_on[1000];
    i still get the same thing, its crashing every time it hits the sprintf statement.

  6. #6
    Registered User
    Join Date
    May 2004
    Posts
    215
    ok i got it to work, thanks :-)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File I/O Assertion Failure in VS2008
    By clegs in forum C Programming
    Replies: 5
    Last Post: 12-25-2008, 04:47 AM
  2. Debug Assertion Error on a sprintf call
    By INFERNO2K in forum C++ Programming
    Replies: 3
    Last Post: 11-25-2005, 10:09 PM
  3. delete Assertion Failure
    By cunnus88 in forum C++ Programming
    Replies: 8
    Last Post: 11-12-2005, 11:38 PM
  4. Assertion failure while creating window
    By roktsyntst in forum Windows Programming
    Replies: 0
    Last Post: 02-10-2003, 08:18 PM
  5. Assertion Failure
    By drdroid in forum Game Programming
    Replies: 9
    Last Post: 01-04-2003, 07:02 PM

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