Jump to content

atoi(), strtod(), itoa(), itoa(), etc APIs issue


Ujwal Rao

Recommended Posts

Hi,

I'm working in a product based company and the product is deployed on Windows 2000. Our product has been running at the customers site for quite a while now (say around 2-3 yrs). Suddenly we have started getting a lot of issues with atoi(), itoa(), atof(), atol(), strtod(), strtol(), itoa(), etc APIs. They dont work sometimes and sometimes they result in a crash. We have started replacing all these APIs with sscanf() & sprintf().

I want to know why this issue started happening suddenly.

Is it because of some windows update/patch that resulted in the crash?

Is it because of some hardware issue?

Please let me know as this issue has started happening at many of our customer places all over the world and we don't have a clue on this one :huh:

Note: There is nothing wrong with the code as it's working perfectly on other Windows 2000 machines for quite a while now!

Link to comment
Share on other sites

  • 2 weeks later...

At least some of these are deprecated as of the Visual C 8.0 runtimes (Visual Studio 2005 timeframe), so I'm wondering what kinds of things were installed (or removed) before the problem occurred. APIs don't just "break" ;).

Link to comment
Share on other sites

Thanks guys for the reply. These APIs have been used in Visual C++ 6.0

I know APIs don't break like that..but we have suddenly started getting the issues on these APIs.

For Eg:

We recently had a crash issue with the following code:

virtual void SetDataText(CString &strText, int intAdditionInfo) { m_fdata = atof((LPCSTR)strText);}

The same above piece of code was working for more than 2 yrs. Suddenly it has started crashing!!!

We fixed the issue by replacing atof with sscanf:

virtual void SetDataText(CString &strText, int intAdditionInfo) { sscanf((LPCSTR)strText, "%f", &m_fdata);}

After this there was no more crash! There have been reports of crash on these APIs at different parts of code where they are used!

cluberti,

Could you explain me "so I'm wondering what kinds of things were installed (or removed) before the problem occurred"? Would installing any software cause any problem?

I really appreciate your help!

Edited by Ujwal Rao
Link to comment
Share on other sites

Certainly - if someone installed updated C runtimes onto the OS running the app, you could get odd behavior. You should check and see which version of the C runtime redist is installed on machines having the issues.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...