_itoa vs _itoa_s
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: _itoa vs _itoa_s

  1. #1
    Join Date
    Dec 2004

    _itoa vs _itoa_s

    I have requiremnt where someone is passing me pointer to a buffer and I have to return value converted to that bufffer. I'm worried about buffer overrun. Here are two functions available for this..
    _itoa(int value,char *buffer,size_t, int radix);
    _itoa_s(int value,char *buffer,size_t, sizeInCharacters,int radix);

    Here is my current function :
    DWORD GetMessageSize(char *FileName, char *Size){
    int intsize;
    // do operation on file and get intsize
    return 0;

    Since I don't know the size of buffer and if I use _itoa_s then how do I handle "sizeInCharacters" ?

    Any help appreciated.

  2. #2
    Join Date
    Jan 2003
    Cambridge, UK

    Re: _itoa vs _itoa_s

    you have to change a definition of GetMessageSize() function to have buffer length parameter along with pointer to buffer inself, otherwise you can't use _itoa_s().

    besides, why don't you return intsize directly from that function? is it some requirement?

    Please rate this post if you find it helpful

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This a Codeguru.com survey!

On-Demand Webinars (sponsored)