P
portergrouptx
I am trying to pad a string with leading character zeros. There seems
to be a difference between the behavior of sprintf on Windows
(Microsoft Visual C++ .NET) and on MVS. Can anyone explain the reason
for this? Or am I doing something incorrectly? Thanks in advance!
---
On Windows:
---
string s = "BB";
char buf[5];
sprintf(buf, "%04s", s.c_str());
// after sprintf: buf = "00BB" <========!!!
---
On MVS:
---
string s = "BB";
char buf[5];
sprintf(buf, "%04s", s.c_str());
// after sprintf: buf = " BB" <========!!!
to be a difference between the behavior of sprintf on Windows
(Microsoft Visual C++ .NET) and on MVS. Can anyone explain the reason
for this? Or am I doing something incorrectly? Thanks in advance!
---
On Windows:
---
string s = "BB";
char buf[5];
sprintf(buf, "%04s", s.c_str());
// after sprintf: buf = "00BB" <========!!!
---
On MVS:
---
string s = "BB";
char buf[5];
sprintf(buf, "%04s", s.c_str());
// after sprintf: buf = " BB" <========!!!