|
Minus sign in printf format string doesn't work.
Hi every body,
I am migrating C code from HP-UX to LINUX RHEL5.
Minus sign flag for left justifying in printf doesn't work.
Could you have a look:
On the HP-UX side :
[gidtdev/oracle-gidtdev2]/users/devt/gidt/src/pc>uname -r
B.11.23
[gidtdev/oracle-gidtdev2]/users/devt/gidt/src/pc>uname
HP-UX
[gidtdev/oracle-gidtdev2]/users/devt/gidt/src/pc>more format.c
#include <string.h>
#include <stdio.h>
main( )
{
char chaine[ 5 ];
strcpy( chaine, "-----" );
printf( "|%10-s|\n", chaine );
printf( "lg=%d\n", strlen( chaine ) );
exit( 0 );
}
[gidtdev/oracle-gidtdev2]/users/devt/gidt/src/pc>cc format.c -o format
[gidtdev/oracle-gidtdev2]/users/devt/gidt/src/pc>format
|----- |
lg=5
----------On the LINUX REHL5 SIDE NOW
[gidtdevt.latelec.gl.local/gidt]/users/devt/gidt/src/pc>
uname
Linux
[gidtdevt.latelec.gl.local/gidt]/users/devt/gidt/src/pc>
more format.c
#include <string.h>
#include <stdio.h>
main( )
{
char chaine[ 5 ];
strcpy( chaine, "-----" );
printf( "|%10-s|\n", chaine );
printf( "lg=%d\n", strlen( chaine ) );
exit( 0 );
}
[gidtdevt.latelec.gl.local/gidt]/users/devt/gidt/src/pc>
gcc format.c -ldl -lm -o format
[gidtdevt.latelec.gl.local/gidt]/users/devt/gidt/src/pc>
format
|%10-s|
lg=5[gidtdevt.latelec.gl.local/gidt]/users/devt/gidt/src/pc>
[gidtdevt.latelec.gl.local/gidt]/users/devt/gidt/src/pc>
gcc format.c -ldl -lm -o format
[gidtdevt.latelec.gl.local/gidt]/users/devt/gidt/src/pc>
format
|%10-s|
| -----|
lg=5[/i][/b]
Can anybody help ?
I wish to avoid changing the code.
I hope it exists some compilation options.
|