vsprintf overrun -> _vscprintf?

This is a discussion on vsprintf overrun -> _vscprintf? within the C Programming forums, part of the General Programming Boards category; Hi, I'm using vsprintf, but I'm having trouble with large strings. This is because I use a static buffer size ...

  1. #1
    Mox
    Mox is offline
    Registered User
    Join Date
    Aug 2001
    Posts
    41

    vsprintf overrun -> _vscprintf?

    Hi,

    I'm using vsprintf, but I'm having trouble with large strings. This is because I use a static buffer size and when the string i want to create is larger than this, vsprintf overruns the buffer.
    So I searched and found _vscprintf. This returns the length of the buffer needed. But it doesn't seem te be in the runtime libraries on my computer as it isn't defined in the header files.
    Is there a way to use this function anyway?

    Thanks.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Nope.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    eh ya hoser, got a beer? stumon's Avatar
    Join Date
    Feb 2003
    Posts
    323
    If you found that function, find out what library its in and add that library to your collection.
    The keyboard is the standard device used to cause computer errors!

  4. #4
    Mox
    Mox is offline
    Registered User
    Join Date
    Aug 2001
    Posts
    41
    I also found vsnprintf, but that isn't what I want, because then I can't get the rest of the string. But it will get rid of the overrun...
    And where could I search for the library?

    Thanks for your help...

  5. #5
    Mox
    Mox is offline
    Registered User
    Join Date
    Aug 2001
    Posts
    41
    Nice, but...
    I'm using vc++ and it only has _vsnprintf which doesn't follow that specification and just returns -1 when it would overrun the buffer. So that won't work either

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    1) - Make the buffer bigger
    2) - At runtime, determine the required buffer size, and malloc() up yourself some memory dynamically. Even if you're not sure of the exact length, you should be able to get an optimised best guess.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. small -> big -> bigger -> bigger than bigger -> ?
    By happyclown in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 03-11-2009, 12:12 PM
  2. Creating buffer overrun
    By suckss in forum C Programming
    Replies: 2
    Last Post: 11-10-2006, 04:21 AM
  3. Dev-C++ -> Tools - > Editor -> Syntax
    By Yuri2 in forum C++ Programming
    Replies: 19
    Last Post: 07-03-2006, 07:48 AM
  4. > > > Urgent Help < < <
    By CodeCypher in forum C Programming
    Replies: 2
    Last Post: 01-31-2006, 01:06 PM

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