473,382 Members | 1,420 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,382 software developers and data experts.

printing a leading zero

hi,
I am trying to write a hexadecimal value to a file using the hex flag. but this does not print the leading zeros.

For example, i need to print 0F instead of F and 00 instead of 0.

my code is

ofstream outputVxlStream;
outputVxlStream.open(temp_filename);
outputVxlStream <<x<<" "<<y<<" "<<z<<" "<<"0x"<<hex<<(int)(r*255)<<hex<<(int)(g*255)<<hex <<(int)(b*255)<<hex<<(int)(a*255)<<endl;

where r,g,b,a are float values between 0 and 1.

can anyone help me with this.

Thank you...
Apr 8 '08 #1
2 2709
Banfa
9,065 Expert Mod 8TB
I think you can manage that with a combination of the io manipulators setw and setfill.
Apr 8 '08 #2
hi,
Thanks a lot.. Its working :)

regards,
AM
Apr 8 '08 #3

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

Similar topics

6
by: david | last post by:
Hi, I have an application as follows: MySQL database Back-Eend linked to MS Access Front-End and ASP Web Application. I require users to enter Serial Numbers such as: 0105123567 (10...
7
by: david | last post by:
Hi, I have 2 text boxes on an ASP form. A user enters a Serial Number in TB1 such as 0105123456, presses tab to move to TB2, TB2 then displays the value of TB1 after a calculation has been...
1
by: Joshua Ammann | last post by:
Hello, I'm trying to export a query containing contact information, including a field. Some zip codes have one or two leading zeros, for example, San Juan, PR (00927) and Springfield, MA...
11
by: jt | last post by:
Here is my code below, it doesn't printf. But I step it thru using the for statement and use putchar to the display, its there... How can I get it to use printf? If the problem is needing a null...
3
by: Candace | last post by:
I have a program that performs calculations and displays a four digit number. Sometimes the calculation results in a number like 0854, but my program displays it as 854. How can I force the program...
5
by: GarryJones | last post by:
I have code numbers in 2 fields from a table which correspond to month and date. (Month, Code number) Field name = ml_mna 1 2 3 etc up to 12 (Data is entered without a leading zero)
8
by: Andrew Poulos | last post by:
In my limited testing with FF 2, IE 6 and Opera 9 when I divided a positive integer, that is less than 100, by 100 I get a leading zero in front of the decimal point. For example 80/100 gives...
4
by: bobm2005 | last post by:
Whatever format I try in Printf, an 'E' format number nearly always has a leading non-zero:- 1.2345E7 -9.3456E8 etc. Is it possible to force it (printf) always to have leading zero? ...
6
by: JimmyKoolPantz | last post by:
Task: Customer wants a script of the data that was processed in a "CSV" file. Problem: Zip-Code leading zeros are dropped Basically we have a client that has requested a custom script for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.