I 've decided it's time to move from fortran to c++, but i cant find
out if c++ supposrts I/O format commands like the ones in fortran 77.
I would be gratefull for any help.
Thank you 20 3003
maria wrote: I 've decided it's time to move from fortran to c++, but i cant find out if c++ supposrts I/O format commands like the ones in fortran 77. I would be gratefull for any help. Thank you
You assume we know Fortran. Why not describe how the IO should behave
first?
Jacques
On 13 Jan 2004 19:40:25 -0800 in comp.lang.c++, ma*****@hotpop. com
(maria) was alleged to have written: I 've decided it's time to move from fortran to c++, but i cant find out if c++ supposrts I/O format commands like the ones in fortran 77.
The printf(), scanf(), etc. library functions, that C++ inherits
from C, provide formatted I/O somewhat reminiscent of Fortran formatted
I/O. Most C++ programmers prefer the standard iostreams library for
type safety and extensibility.
See the section "[15] Input/output via <iostream> and <cstdio>" in
Marshall Cline's C++ FAQ. It is always good to check the FAQ before
posting. You can get the FAQ at: http://www.parashift.com/c++-faq-lite/
maria wrote: I 've decided that it's time to move from Fortran to C++ but I can't find out if C++ supports I/O format commands like the ones in fortran 77.
Why can't you find out?
Do you have a C++ text book?
The C computer programming language has format *strings*
PRINTF(3) Linux Programmer’s Manual PRINTF(3)
NAME
printf, fprintf, sprintf, snprintf, vprintf, vfprintf,
vsprintf, vsnprintf - formatted output conversion
SYNOPSIS
#include <stdio.h>
int printf(const char *format, ...);
int fprintf(FILE *stream, const char *format, ...);
int sprintf(char *str, const char *format, ...);
int snprintf(char *str, size_t size, const char *format, ...);
"David Harmon" <so****@netcom. com> wrote in message
news:40******** *******@news.we st.earthlink.ne t... On 13 Jan 2004 19:40:25 -0800 in comp.lang.c++, ma*****@hotpop. com (maria) was alleged to have written:I 've decided it's time to move from fortran to c++, but i cant find out if c++ supposrts I/O format commands like the ones in fortran 77. The printf(), scanf(), etc. library functions, that C++ inherits from C, provide formatted I/O somewhat reminiscent of Fortran formatted I/O. Most C++ programmers prefer the standard iostreams library for type safety and extensibility.
Do they really?
I think it depends on what you mean by formatted. Personally I find them
extremely clunky for doing what I usualy think of
as formatted I/O i.e. the difference between 0x%06x and %d.
Putting aside the biggest problem which is properly saving and restoring the
base and fill character, including iomanip,
upper versus lower case hex letters and the std namespace you still have:
cout << x << hex << "0x" << setw(6) << setfill('0') << y << dec;
versus
printf("%d 0x%06x",x,y);
I think that the standard should actualy supply a class to save and restore
all this 'stuff' automatically in ctor/dtor e.g.
std::format_sta te fs(cout);
This is in no way intended to deny that they are wonderful for printing
classes where C has nothing.
See the section "[15] Input/output via <iostream> and <cstdio>" in Marshall Cline's C++ FAQ. It is always good to check the FAQ before posting. You can get the FAQ at: http://www.parashift.com/c++-faq-lite/
On Wed, 14 Jan 2004 06:45:06 -0000 in comp.lang.c++, "Nick Hounsome"
<nh***@blueyond er.co.uk> was alleged to have written: I/O. Most C++ programmers prefer the standard iostreams library for type safety and extensibility. Do they really?
Yes.
I think it depends on what you mean by formatted.
Formatted means converted to or from a legible character representation.
printf() and scanf() are formatted. read() and write() are raw or
unformatted. <iostream>'s operator<<() and operator>>() are formatted.
Personally I find them extremely clunky for doing what I usualy think of as formatted I/O i.e. the difference between 0x%06x and %d.
Both of those are formatted. Come on, this isn't rocket science.
"Nick Hounsome" <nh***@blueyond er.co.uk> wrote in message
news:Hy******** *******@news-binary.blueyond er.co.uk... "David Harmon" <so****@netcom. com> wrote in message news:40******** *******@news.we st.earthlink.ne t... On 13 Jan 2004 19:40:25 -0800 in comp.lang.c++, ma*****@hotpop. com (maria) was alleged to have written:I 've decided it's time to move from fortran to c++, but i cant find out if c++ supposrts I/O format commands like the ones in fortran 77. The printf(), scanf(), etc. library functions, that C++ inherits from C, provide formatted I/O somewhat reminiscent of Fortran formatted I/O. Most C++ programmers prefer the standard iostreams library for type safety and extensibility.
Do they really?
I think it depends on what you mean by formatted. Personally I find them extremely clunky for doing what I usualy think of as formatted I/O i.e. the difference between 0x%06x and %d.
Putting aside the biggest problem which is properly saving and restoring
the base and fill character, including iomanip, upper versus lower case hex letters and the std namespace you still have: cout << x << hex << "0x" << setw(6) << setfill('0') << y << dec; versus printf("%d 0x%06x",x,y);
I think that the standard should actualy supply a class to save and
restore all this 'stuff' automatically in ctor/dtor e.g. std::format_sta te fs(cout);
See http://www.boost.org/libs/io/doc/ios_state.html which saves the state as
you desire. If you still insist on printf, see http://www.boost.org/libs/format/index.htm for a typesafe version.
Jeff F
"Jeff Flinn" <NO****@nowhere .com> wrote in message
news:bu******** **@bluegill.adi .com... "Nick Hounsome" <nh***@blueyond er.co.uk> wrote in message news:Hy******** *******@news-binary.blueyond er.co.uk... "David Harmon" <so****@netcom. com> wrote in message news:40******** *******@news.we st.earthlink.ne t... On 13 Jan 2004 19:40:25 -0800 in comp.lang.c++, ma*****@hotpop. com (maria) was alleged to have written: >I 've decided it's time to move from fortran to c++, but i cant find >out if c++ supposrts I/O format commands like the ones in fortran 77.
The printf(), scanf(), etc. library functions, that C++ inherits from C, provide formatted I/O somewhat reminiscent of Fortran
formatted I/O. Most C++ programmers prefer the standard iostreams library for type safety and extensibility.
Do they really?
I think it depends on what you mean by formatted. Personally I find them extremely clunky for doing what I usualy think of as formatted I/O i.e. the difference between 0x%06x and %d.
Putting aside the biggest problem which is properly saving and restoring the base and fill character, including iomanip, upper versus lower case hex letters and the std namespace you still
have: cout << x << hex << "0x" << setw(6) << setfill('0') << y << dec; versus printf("%d 0x%06x",x,y);
I think that the standard should actualy supply a class to save and restore all this 'stuff' automatically in ctor/dtor e.g. std::format_sta te fs(cout);
See http://www.boost.org/libs/io/doc/ios_state.html which saves the state
as you desire. If you still insist on printf, see http://www.boost.org/libs/format/index.htm for a typesafe version.
Jeff F
Great but you will see that I said "I think that the standard should actualy
supply ...."
Nick Hounsome wrote in
news:Hy******** *******@news-binary.blueyond er.co.uk: I think that the standard should actualy supply a class to save and restore all this 'stuff' automatically in ctor/dtor e.g. std::format_sta te fs(cout);
void f( int i )
{
std::ostream os( cout.rdbuf() );
os << std::hex << i;
}
Rob.
-- http://www.victim-prime.dsl.pipex.com/
.... Putting aside the biggest problem which is properly saving and
restoring the base and fill character, including iomanip, upper versus lower case hex letters and the std namespace you still
.... See http://www.boost.org/libs/io/doc/ios_state.html which saves the
state as you desire. If you still insist on printf, see http://www.boost.org/libs/format/index.htm for a typesafe version.
Great but you will see that I said "I think that the standard should
actualy supply ...."
Considering the large number of facilities from boost that have been
proposed in TR1, perhaps with a little prodding the ios_state could be
proposed for TR2, then your wish could be reality.
Jeff F This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Anonymous |
last post by:
I have a mixed-language pgm (Fortran and C++) which needs to pass a few
hundred values from C++ to Fortran. One way to do this is to have a
Fortran module and a C++ structure (or class) with an identical data
layout. I have used this idea with no problem, but it necessitates
making changes very carefully to the Fortran module and the C++
structure to keep them "in sync".
I am looking for a program which translates source files between...
|
by: NM |
last post by:
Sometimes ago I was having a problem in linking between C++ and Fortran
program. That was solved (using input from this newsgroup) using the Fortran
keyword "sequence" with the derived types (to assume contiguous space).
Now I am having problem again. In order to show the problem I have created
small program and this time there is no data straucture being passed between
C++ and Fortran.
Here is how the program looks like
|
by: google |
last post by:
first, a little background...
i have a C program which preprocesses some data, and then outputs the
results into a text file. that text file, in turn, is used as input
to a FORTRAN computational fluid dynamics (CFD) program. the FORTRAN
program goes to work on the provided data, and outputs a text file
which i read back in with another C program to postprocess the data
and analyze the results of the CFD run.
now on to the problem. ...
|
by: Matt |
last post by:
I have 2 questions:
1. strlen returns an unsigned (size_t) quantity. Why is an unsigned
value more approprate than a signed value? Why is unsighned value less
appropriate?
2. Would there be any advantage in having strcat and strcpy return a
pointer to the "end" of the destination string rather than returning a
|
by: purushotammr |
last post by:
Hi Can anyone guide me by providing me the code ,for the following
requirement:
desining parser for fortran language(parsing fortran)
| |
by: Tyler |
last post by:
Hello All:
After trying to find an open source alternative to Matlab (or IDL), I
am currently getting acquainted with Python and, in particular SciPy,
NumPy, and Matplotlib. While I await the delivery of Travis Oliphant's
NumPy manual, I have a quick question (hopefully) regarding how to read
in Fortran written data.
The data files are not binary, but ASCII text files with no formatting
and mixed data types (strings, integers,...
|
by: Nomad.C |
last post by:
Hi
I've been thinking of learning Fortran as number crunching kinda
language for my Physics degree......but then looking around the
internet, people are saying that the libraries/ Algorithms once used
for number crunching is now slowly converting into C, so do you think
I should stick with C, since I know C already, or should I proceed
learning fortran??
Any advice??
Thanks
|
by: nitusa |
last post by:
Hey Everyone,
I am doing a VB6 to C# conversion and everything was going smoothly until I realized that I needed to call a Fortran 77 (.for) .dll inside my code. I have looked through everything I have found using Google and have still been unable to get it to successfully work. Currently the following call works about 75% of the time, but the other 25% of the time my program just calls the .dll and then it simply exits; no...
|
by: john |
last post by:
I wrapped some fortran code using F2PY and need to be able to catch
fortran runtime errors to run the following:
# "grid" is a wrapped fortran module
# no runtime errors incurred when run with the correct inputs for
filetype
#-------------------------------
def readGrid( self, coord='xyz' ):
mg = ( '.FALSE.', '.TRUE.' )
form = ( 'FORMATTED', 'UNFORMATTED' )
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |