473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

sprintf behaviour on Redhat linux.

2
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.
May 12 '07 #1
1 2445
manjup
2
i got the solution..
this is how i implemented it..

sprintf(acct1, "%010ld",atol(act));

regds,
manju.
May 12 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: tim | last post by:
I was trying to install Oracle on a Linux box with Redhat and got an error message saying the OS had to be Redhat 2.1 or 3.0 (plus some other non-Redhat versions). Does anyone know what I have to...
4
by: D. Dante Lorenso | last post by:
This isn't entirely PG related, but... Does anyone know what the natural upgrade path from RedHat 9 is? I'm wondering if anyone on the PostgreSQL team is working with redhat to package and...
3
by: hrishy | last post by:
Hi Does anybody have the steps to install db2v8.1 on redhat advanced server 3.0.THe db2 i have is form the linux starter kit available freely on developerworks for learning purpose. I tried...
4
by: hari | last post by:
Hi, is the sprintf() implemetation OS specific or ANSI standard? for eg. in a code like sprintf(variable,"%s%s",str1,str2); in windows OS using VC++, if in case i pass NULL in str1 no problem,...
15
by: Ivan78 | last post by:
Hi everybody, I happened the following thing using sprintf function on different machine : on Digital Alpha s1="PIPPO" and s2="PLUTO" sprintf(s1, "%s%s", s1,s2) -> s1 is equal PIPPOPLUTO while...
10
by: Saurabh | last post by:
Hi all, I am working on RedHat Linux GCC 3.0. I am trying to convert a long to string through sprintf. but i m getting segmantation fault. I tried snprintf also but no avail.here is the piece...
12
by: Henryk | last post by:
Hey there, I have some problems with the following code snippet on a Virtex-4 PowerPC with a GCC based compiler char chData; sprintf(&chData, "%+05.0f", -0.038f); --I get "-000" ???...
285
by: Sheth Raxit | last post by:
Machine 1 : bash-3.00$ uname -a SunOS <hostname5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R bash-3.00$ gcc -v Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/...
173
by: Ron Ford | last post by:
I'm looking for a freeware c99 compiler for windows. I had intended to use MS's Visual C++ Express and use its C capability. In the past with my MS products, I've simply needed to make .c the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.