¡@

Home 

c++ Programming Glossary: io

Using scanf() in C++ programs is faster than using cin?

http://stackoverflow.com/questions/1042110/using-scanf-in-c-programs-is-faster-than-using-cin

providing sites I found something that poke my attention Check your input output methods. In C using cin and cout is.. specific though I am just learning C ... c c performance io share improve this question Probably scanf is somewhat faster.. C ... c c performance io share improve this question Probably scanf is somewhat faster than using streams. Although..

Getting a FILE* from a std::fstream

http://stackoverflow.com/questions/109449/getting-a-file-from-a-stdfstream

my C library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE . c c file.. to use a C library that accepts a FILE . c c file file io fstream share improve this question The short answer is.. FILE . c c file file io fstream share improve this question The short answer is no. The reason is because the std fstream..

Writing a binary file in C++ very fast

http://stackoverflow.com/questions/11563963/writing-a-binary-file-in-c-very-fast

by huge amounts I mean 80GB. I browsed the web for solutions but the best I came up with was this #include fstream using.. a size int main fstream myfile myfile fstream file.binary ios out ios binary Here would be some error handling for int i.. int main fstream myfile myfile fstream file.binary ios out ios binary Here would be some error handling for int i 0 i 32 i..

What is the most elegant way to read a text file with c++?

http://stackoverflow.com/questions/195323/what-is-the-most-elegant-way-to-read-a-text-file-with-c

way to read a text file with C Thanks. c text file io share improve this question There are many ways you pick.. with C Thanks. c text file io share improve this question There are many ways you pick which is the most elegant for.. elegant for you. Reading into char ifstream file file.txt ios in ios binary ios ate if file.is_open file.seekg 0 ios end..

checking for eof in string::getline

http://stackoverflow.com/questions/2251433/checking-for-eof-in-stringgetline

do I check for end of file using the string getline function Coz using .eof is not recommended as it wont signal eof until.. signal eof until I attempt to read beyond eof. c file io getline share improve this question The canonical reading.. beyond eof. c file io getline share improve this question The canonical reading loop in C is while getline cin str..

Difference between files writen in binary and text mode

http://stackoverflow.com/questions/229924/difference-between-files-writen-in-binary-and-text-mode

between files writen in binary and text mode What translation occurs when writing to a file that was opened in text mode.. filename wt fwrite buffer size count fp_text c c file io share improve this question I believe that most platforms.. size count fp_text c c file io share improve this question I believe that most platforms will ignore the t option or..

C++ alignment when printing cout <<

http://stackoverflow.com/questions/2485963/c-alignment-when-printing-cout

c stdout cout text alignment share improve this question The ISO C standard way to do it is to #include iomanip and.. question The ISO C standard way to do it is to #include iomanip and use io manipulators like std setw . However that said.. ISO C standard way to do it is to #include iomanip and use io manipulators like std setw . However that said those io manipulators..

How do I flush the cin buffer?

http://stackoverflow.com/questions/257091/how-do-i-flush-the-cin-buffer

the cin buffer How do I clear the cin buffer in C c cin io buffering share improve this question possibly std cin.ignore.. buffer in C c cin io buffering share improve this question possibly std cin.ignore INT_MAX this would read in and ignore..

Read whole ASCII file into C++ std::string

http://stackoverflow.com/questions/2602013/read-whole-ascii-file-into-c-stdstring

t int length t.open file.txt open input file t.seekg 0 std ios end go to the end length t.tellg report location this is the.. 0 std ios end go to the end length t.tellg report location this is the length t.seekg 0 std ios beg go back to the beginning.. t.tellg report location this is the length t.seekg 0 std ios beg go back to the beginning buffer new char length allocate..

Why don't the std::fstream classes take a std::string?

http://stackoverflow.com/questions/32332/why-dont-the-stdfstream-classes-take-a-stdstring

classes take a std string This isn't a design question really though it may seem like it. Well okay it's kind of a.. it may seem like it. Well okay it's kind of a design question . What I'm wondering is why the C std fstream classes don't.. or open methods. Everyone loves code examples so #include iostream #include fstream #include string int main std string filename..

mmap() vs. reading blocks

http://stackoverflow.com/questions/45972/mmap-vs-reading-blocks

of variable length records. I've got a first implementation up and running and am now looking towards improving performance.. sized boundaries. How can I decide between these two options without actually writing up a complete implementation first.. options without actually writing up a complete implementation first Any rules of thumb e.g. mmap is 2x faster or simple tests..

Boost::Asio : io_service.run() vs poll() or how do I integrate boost::asio in mainloop

http://stackoverflow.com/questions/4705411/boostasio-io-service-run-vs-poll-or-how-do-i-integrate-boostasio-in-ma

Asio io_service.run vs poll or how do I integrate boost asio in mainloop.. Asio io_service.run vs poll or how do I integrate boost asio in mainloop.. Asio io_service.run vs poll or how do I integrate boost asio in mainloop I am currently trying to use boost asio for some..

Printing double without losing precision

http://stackoverflow.com/questions/4738768/printing-double-without-losing-precision

double without losing precision So how do you print a double to a stream so that when it is.. a stream so that when it is read in you don't lose precision I tried std stringstream ss double v 0.1 0.1 ss std setprecision.. tried std stringstream ss double v 0.1 0.1 ss std setprecision std numeric_limits T digits10 v double u ss u std cout precision..

Elegant ways to count the frequency of words in a file

http://stackoverflow.com/questions/4888879/elegant-ways-to-count-the-frequency-of-words-in-a-file

count the frequency of each english word in a file c file io share improve this question First of all I define letter_only.. word in a file c file io share improve this question First of all I define letter_only std locale so as to ignore.. I define letter_only std locale so as to ignore punctuations coming from the stream and to read only valid english letters..

Using boost::iostreams::tee_device?

http://stackoverflow.com/questions/670465/using-boostiostreamstee-device

boost iostreams tee_device Can someone help me I am trying to do something.. trying to do something like the following #include boost iostreams tee.hpp #include boost iostreams stream.hpp #include.. following #include boost iostreams tee.hpp #include boost iostreams stream.hpp #include sstream #include cassert namespace..

What's preferred pattern for reading lines from a file in C++?

http://stackoverflow.com/questions/7219062/whats-preferred-pattern-for-reading-lines-from-a-file-in-c

that the file exists and is opened. Other than the exception handling is there a reason to prefer the more verbose first.. first pattern What's your standard practice c file io share improve this question while std getline fs line This.. standard practice c file io share improve this question while std getline fs line This is not only correct but preferable..

C++: Read file line by line

http://stackoverflow.com/questions/7868936/c-read-file-line-by-line

of the file ofstream myfile myfile.open text.txt c file io share improve this question First make an ifstream #include.. myfile.open text.txt c file io share improve this question First make an ifstream #include fstream std ifstream infile.. doesn't gobble up newlines so you may end up with spurious empty lines if you use getline after token based extraction..

Using scanf() in C++ programs is faster than using cin?

http://stackoverflow.com/questions/1042110/using-scanf-in-c-programs-is-faster-than-using-cin

of things that would affect performance between C style IO and C style. The main difference with the formatters tended..

Why does wide file-stream in C++ narrow written data by default?

http://stackoverflow.com/questions/1509277/why-does-wide-file-stream-in-c-narrow-written-data-by-default

from C and so dates back to at least 1989. Two main points IO is done in term of char. it is the job of the locale to determine.. wide character and we get notified of the problem as the IO failed. If I run ask an UTF 8 locale I get env LC_ALL en_US.utf8..

How do I guarantee fast shutdown of my win32 app?

http://stackoverflow.com/questions/209086/how-do-i-guarantee-fast-shutdown-of-my-win32-app

that has a number of threads that might be busy doing IO HTTP calls etc when the user wants to shutdown the application... a new version can be installed over it. The only disk IO I'm doing is in a transactional db so I'm not terribly concerned.. winapi exit share improve this question Use overlapped IO so that you're always in control of the threads that are dealing..

checking for eof in string::getline

http://stackoverflow.com/questions/2251433/checking-for-eof-in-stringgetline

reading loop in C is while getline cin str if cin.bad IO error else if cin.eof format error not possible with getline..

Best documentation for Boost:asio?

http://stackoverflow.com/questions/244453/best-documentation-for-boostasio

to document for something as low level as an Asynchronous IO Library. The examples give more away than the tutorials do... a standard library technical report for an asynchronous IO library in the STL in the future. share improve this answer..

Is 'volatile' needed in this multi-threaded C++ code?

http://stackoverflow.com/questions/3612505/is-volatile-needed-in-this-multi-threaded-c-code

barriers. Volatile should only be used for memory mapped IO where multiple reads may return different values. Similarly..

Convert bitmap to PNG in-memory in C++ (win32)

http://stackoverflow.com/questions/366768/convert-bitmap-to-png-in-memory-in-c-win32

I always use it via the much cleaner boost gil PNG IO extension but unfortunately that takes char filenames and if..

What techniques can be used to speed up C++ compilation times?

http://stackoverflow.com/questions/373142/what-techniques-can-be-used-to-speed-up-c-compilation-times

effect making this way slower than they need to be. The IO streams are particularly known for slowing down builds. If you..

What Rules does compiler have to follow when dealing with volatile memory locations?

http://stackoverflow.com/questions/4136900/what-rules-does-compiler-have-to-follow-when-dealing-with-volatile-memory-locati

memory. Why is this useful On some architectures certain IO devices map their inputs or outputs to a memory location i.e...

“\n” or '\n' or std::endl to std::cout?

http://stackoverflow.com/questions/8311058/n-or-n-or-stdendl-to-stdcout

than outputting a single character. Of course when doing IO this rarely matters but if in doubt when you want to output..

writing a matrix into a single txt file with mpi

http://stackoverflow.com/questions/9777828/writing-a-matrix-into-a-single-txt-file-with-mpi

you're going to write as text or binary you can use MPI IO to coordinate your output to the file to generate one large.. file. We have a little tutorial on the topic using MPI IO HDF5 and NetCDF here . For MPI IO the trick is to define a type.. on the topic using MPI IO HDF5 and NetCDF here . For MPI IO the trick is to define a type here a subarray to describe the..