Skip to content

Commit

Permalink
Add comment about sprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Jul 22, 2024
1 parent a821852 commit 53f1faa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cplusplus/p0004.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ unsigned int p0004() {
for (j = 100; j < 1000; j++) {
prod = i * j;
char buf[8] = {};
// I know snprintf exists, but it isn't defined in C++98,
// and this isn't taking in user input
sprintf(buf, "%u", prod);
std::string forward(buf);
std::string reverse = forward;
Expand Down
2 changes: 2 additions & 0 deletions cplusplus/p0034.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ unsigned long long p0034() {
for (unsigned long i = 10; i < 100000; i++) {
sum = 0;
char buf[8] = {};
// I know snprintf exists, but it isn't defined in C++98,
// and this isn't taking in user input
sprintf(buf, "%lu", i);
for (unsigned char j = 0; j < 8; j++) {
if (!buf[j]) break;
Expand Down

0 comments on commit 53f1faa

Please sign in to comment.