Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. problem with _vsntprintf_s

problem with _vsntprintf_s

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hansipet
    wrote on last edited by
    #1

    Hello, I have a strange problem. When I use the function _vsntprintf_s in my program. the program finishes without any error messages.. if I use _vsntprintf the whole things works as expected. Has anyone an idea? I want to use the secure verision because here I have the possibilty to use _TRUNCATE, which I really need... dwLen = _vsntprintf((TCHAR*)logEntry.message, sizeof(logEntry.message) / sizeof(TCHAR), szFormatString, args); dwLen = _vsntprintf_s((TCHAR*)logEntry.message, sizeof(logEntry.message), _TRUNCATE, szFormatString, args); //doesn't work best regards Hansjörg

    M 1 Reply Last reply
    0
    • H hansipet

      Hello, I have a strange problem. When I use the function _vsntprintf_s in my program. the program finishes without any error messages.. if I use _vsntprintf the whole things works as expected. Has anyone an idea? I want to use the secure verision because here I have the possibilty to use _TRUNCATE, which I really need... dwLen = _vsntprintf((TCHAR*)logEntry.message, sizeof(logEntry.message) / sizeof(TCHAR), szFormatString, args); dwLen = _vsntprintf_s((TCHAR*)logEntry.message, sizeof(logEntry.message), _TRUNCATE, szFormatString, args); //doesn't work best regards Hansjörg

      M Offline
      M Offline
      Matthew Faithfull
      wrote on last edited by
      #2

      As it's compiling and the call to _vsntprintf_s is happening then there's really only two possible causes. One is the data/paramters you are passing and the other is that previous lines of code have caused some horrible corruption which is killing the process but has essentially nothing to do with _vsntprintf_s. I'd guess at the former but I agree that this shouldn't be happening. Possibly you've hit some nasty corner case where the CRT simply calls abort(); and for some reason you're not seeing anything in the debug trace. Remember the same code, called by _vsntprintf_s is going to be used to format that debug trace output, so if you trash it badly enough you won't see any debugging info ;) I would recommending installing the CRT sources which is an option on your Visual Studio installation, if you didn't already, and then adding the path e.g. C:\Program Files\Microsoft Visual Studio 8\VC\crt\src to the include search path of your project so you can step into the _vsntprintf_s call and debug what's going on. It get's pretty deep in there but it shouldn't take too long to find where it's dropping out. You could always wrap the call in some exception handling as well if you thing the CRT might be throwing at you. Obvious the first port of call is to thoroughly check your parameters but I'm guessing you did that already :)

      Nothing is exactly what it seems but everything with seems can be unpicked.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups