sprintf behaviour on Redhat linux.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manjup
    New Member
    • May 2007
    • 2

    sprintf behaviour on Redhat linux.

    Hi,

    I'm using sprintf to add leading zeros to the left of variable, but looks like it's adding spaces instead of zeros. The same works on AIX.

    //here is code snippet.

    char act[10]="12345";
    char act1[10];

    sprintf(act1, "%010s",act );
    sprintf("the value of second array '%s'\n",act1);

    Program output : ' 12345'

    expected result : '0000012345'

    thanks,
    Manju.
  • manjup
    New Member
    • May 2007
    • 2

    #2
    i got the solution..
    this is how i implemented it..

    sprintf(acct1, "%010ld",atol(a ct));

    regds,
    manju.

    Comment

    Working...