[Trouble shoot] atol and Atoll

Source: Internet
Author: User

The final result is actually a small error.

But it takes a long time to locate the error...

Background: The error code is a program running on a Linux server. The main function of the program is to process bank POS Card swiping records and perform some calculations, and finally summarize and format the output.

The company deals with banks, and the projects it receives are all banks.


The next day I came to the company (the first day I was familiar with the environment and didn't do anything), the boss gave me a pure C program with over 2000 lines, A test document with test errors and output results with errors.

For historical reasons ..... This section of the program has been supplemented by many people, a master file without header files, wood code reuse, more than 2000 lines ......

In addition, I have just been unable to understand business knowledge and even test cases, like reading tianshu.

I tried to use vs to open the program. I rely on it and cannot run it in windows. It calls many library functions in Linux ....

Fortunately, I will use Linux, and I have cygwin installed on Windows ....

The program running environment is not a problem, and can run normally. I will start to track bugs. I don't know where the errors are. I don't understand the business knowledge, I don't know what the correct result is... Decisively ask the boss, where the results are not much ....

Okay, you know where the error is. Next, locate it. It's good to read the code in Vim. Now you should be familiar with vim, I can't understand the variable name and function name in the code. I can't understand the business knowledge of programmers... Bite your head,


Find some variables related to the error information and start GDB debugging ..........

.....

Finally, the error location of the problem is locked: atol function... Haha ....

This section of the program means that the processed data is obtained from the bank, such as pos card consumption information... There are big numbers in it. The atol () function only supports 8 bits. If it is changed to Atoll (), it will be pulled ....

Summary:

Overflow will not cause errors in the program, but will lead to incorrect results. Be sure to accept the lessons learned this time.

[Trouble shoot] atol and Atoll

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.