Could anyone help me with an issue that I have? I have a program that reads from a data file using an array and the data is structured as a long interger. I am trying to break up a long interger in to pairs i.e 141251 into 14:12:15 using c++.
Ccrobinson001
0
Light Poster
Recommended Answers
Jump to PostThis is a math problem. You want to separate a number into hundreds.
141251 / 100 = 1412 R 51
and
1412 / 100 = 14 R 12
and
14 / 100 = 0 R 14
The C++ remainder operator is %.
Hope …
Jump to Post>This is a math problem.
No, it's not. Reading the data as an integer strikes me as dangerous in this case. I can easily see integer overflow being a potential problem, and that serious affects the robustness of the code. Something like this would be better:#include …
All 5 Replies
Duoas
1,025
Postaholic
Featured Poster
Narue
5,707
Bad Cop
Team Colleague
Ccrobinson001
0
Light Poster
Narue
5,707
Bad Cop
Team Colleague
Ccrobinson001
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.