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

problem with setw(X) and library <iomanip.h>

Hi,
I'd like to obtain an output looking as follows:

name number phone address
Caroline 233 34234 White St. 12
Anna 929043 093284 Brown St. 325

To do this (I mean to obtain constant field length for data of the same
type, even if strings are of different lengths) I tried to use setw(X)
from <iomanip.h>, so I wrote something like this:
cout << "name " << "phone " << "address" << endl;
cout << setw(15) << name << setw(10) << << number << setw(10)
phone << setw(20) << address << endl;

The problem is that the compiler returns a warning:
#warning This file includes at least one deprecated or antiquated
header. \
Please consider using one of the 32 headers found in section 17.4.1.2
of the \
C++ standard. Examples include substituting the <X> header for the
<X.h> \
header for C++ includes, or <iostream> instead of the deprecated header
\
<iostream.h>. To disable this warning use -Wno-deprecated.

What can I do to avoid it? Is there any other method for formatting the
output?

May 17 '06 #1
4 8847
alternativa wrote:
Hi,
I'd like to obtain an output looking as follows:

name number phone address
Caroline 233 34234 White St. 12
Anna 929043 093284 Brown St. 325

To do this (I mean to obtain constant field length for data of the same
type, even if strings are of different lengths) I tried to use setw(X)
from <iomanip.h>, so I wrote something like this:
cout << "name " << "phone " << "address" << endl;
cout << setw(15) << name << setw(10) << << number << setw(10)
phone << setw(20) << address << endl;

The problem is that the compiler returns a warning:
#warning This file includes at least one deprecated or antiquated
header. \
Please consider using one of the 32 headers found in section 17.4.1.2
of the \
C++ standard. Examples include substituting the <X> header for the
<X.h> \
header for C++ includes, or <iostream> instead of the deprecated header
\
<iostream.h>. To disable this warning use -Wno-deprecated.

What can I do to avoid it? Is there any other method for formatting the
output?


Use <iomanip>, not <iomanip.h>. You will also either have to qualify
things as being in the std namespace or put a "using namespace std;"
after your headers in your .cpp/.cc/.C file.

Cheers! --M

May 17 '06 #2
alternativa wrote:
[..] I tried to use
setw(X) from <iomanip.h>
There is no <iomanip.h> in the Standard C++ library. Only <iomanip>.
Try it. You may need to add 'std::' to your manipulators or add some
kind of 'using' declaration or directive. Read about "std" namespace.
[...]

What can I do to avoid it?
Stop using non-standard (deprecated) headers. It's been eight years
since standard has been in place, it's time for you to learn to use
standard headers.
Is there any other method for formatting
the output?


You could use printf...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 17 '06 #3
alternativa wrote:
[snipped]
The problem is that the compiler returns a warning:
#warning This file includes at least one deprecated or antiquated
header. \
Please consider using one of the 32 headers found in section 17.4.1.2
of the \
C++ standard. Examples include substituting the <X> header for the
<X.h> \
header for C++ includes, or <iostream> instead of the deprecated header
\
<iostream.h>. To disable this warning use -Wno-deprecated.

What can I do to avoid it? Is there any other method for formatting the
output?


try:
#include <iostream>
#include <iomanip>

instead of
#include <iostream.h>
#include <iomanip.h>

Alan
May 17 '06 #4
alternativa <al***********@wp.pl> wrote:
Hi,
I'd like to obtain an output looking as follows:

name number phone address
Caroline 233 34234 White St. 12
Anna 929043 093284 Brown St. 325

To do this (I mean to obtain constant field length for data of the same
type, even if strings are of different lengths) I tried to use setw(X)
from <iomanip.h>, so I wrote something like this: [snip]
The problem is that the compiler returns a warning:
#warning This file includes at least one deprecated or antiquated
header. \
Please consider using one of the 32 headers found in section 17.4.1.2
of the \
C++ standard. Examples include substituting the <X> header for the
<X.h> \
header for C++ includes, or <iostream> instead of the deprecated header
\
<iostream.h>.


You are including the nonstandard <iomanip.h>. Instead, try #including
<iomanip> (no .h on the end). Note that a common convention for these
headers is that <iomanip.h> had symbols in the global namespace but
<iomanip> has them in namespace std, so you may need to:

1. Fully qualify the names (e.g., std::setw(10) instead of setw(10))
2. Use using-declarations (e.g., using std::setw;)
3. Use a using-directive (e.g., using namespace std)

I put these in my personal preference order, but see the FAQ for more
information.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
May 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
2
by: rupert | last post by:
i've got the following code: #include <iostream> #include <string> #include <vector> #include <iomanip> using namespace std; int main(double argc, char* argv) { double r = 0.01;
1
by: Ezmeralda | last post by:
Hello, I need to an TCP/IP Interface for communication with an embedded device. Since I have two different design ideas in mind, I am wondering whether you could give me some hints to decide:...
3
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt,...
14
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the...
3
by: newbie | last post by:
Same thing g++ complains when using hash_map<>, but is happy with map<--I understand hahs_map is not standardized, but since the compiler didn't complain something like 'hash_map<not defined', I...
2
by: Markus Dehmann | last post by:
I have two integers i1 and i2, the second of which is guaranteed to be between 0 and 99, and I encode them into one double: double encoded = (double)i1 + (double)i2 / (double)100; So, for...
6
by: Bernd Gaertner | last post by:
Dear experts, according to the standard, manipulators like noskipws are declared in the header ios (). But when I look at code that is around, I usually see #include<iomanipbeing used. What is...
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
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...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.