iostream

Set filename of the Pdf that is streamed back to the browser

风流意气都作罢 提交于 2019-12-03 13:54:34
问题 I have a Java webapp creating a pdf and streaming it back to the browser. byte[] pdf = report.exportPdfToArray(user); response.setContentType("application/pdf"); response.setHeader("content-disposition", "inline; filename=\"My.pdf\""); outStream = response.getOutputStream(); outStream.write(pdf); outStream.flush(); outStream.close(); The report is executed and it is sent back to the browser, but I can not control the name of the file even though I set the content-disposition . I am using

read part of a file with iostreams

筅森魡賤 提交于 2019-12-03 13:33:00
Can I open an ifstream (or set an existing one in any way) to only read part of a file? For example, I would like to have my ifstream read a file from byte 10 to 50. Seeking to position 0 would be position 10 in reality, reading past position 40 (50 in reality) would resualt in an EOF , etc. Is this possible in any way? It definetly can be done by implementing a filtering stream buffer: you would derive from std::streambuf and take the range you want to expose and the underlying stream buffer (well, a pointer to it) as arguments. Then you would seek to the start location. An overridden

Create an iostream using boost asio specifying ip and port

白昼怎懂夜的黑 提交于 2019-12-03 13:31:25
问题 I have a problem concerning boost asio libraries. I successfully tried to create a socket between a client and a server, this involves creation of resolvers in order to specify ip and port to the server (the server only requires port) and other objects, but, most importantly, it is necessary to use write and read_some as functions to read and write from/in the socket. I would really appreciate to use a stream, and this is possible in boost asio, but that's strange... In almost all examples

Should I switch to C++ I/O streams? [closed]

廉价感情. 提交于 2019-12-03 12:20:55
I've never been much to use C++ I/O streams and have always opted for what I know. i.e. the printf functions. I know there are some benefits to using I/O streams, but I'm looking for some tips from the stackoverflow community to help me (or convince me) to switch. Because I still prefer printf and I think the printf style is so much easier to read and quicker to type. I would still like to be familiar with it even if I still continue to use printf. Edit. Interestingly, google C++ coding style forbids the use of streams except for logging. See: http://google-styleguide.googlecode.com/svn/trunk

#include iostream in C?

冷暖自知 提交于 2019-12-03 11:03:39
In C++ we always put the following at the top of the program #include <iostream> What about for C? AraK Well, this is called the standard I/O header. In C you have: #include <stdio.h> It's not an analog to <iostream> . There is no analog to iostream in C -- it lacks objects and types. If you're using C++, it's the analog to <cstdio> . stdio man page GNU documentation on Input/Output on Streams See also this fantastic question and its answer, 'printf' vs. 'cout' in C++ #include <stdio.h> iostream is a C++ library for input-output. The C equivalent would be stdio.h #include <stdio.h> C Standard

Redirect std::cout to a QTextEdit [duplicate]

好久不见. 提交于 2019-12-03 08:54:49
This question already has an answer here: redirect std::cout to QTextEdit 2 answers I'm new to Qt application development, I would appreciate your help. This is a re-post of redirect std::cout to QTextEdit I'm trying to redirect std::cout to a QTextEdit and I've seen and tried to test the example provided in the following link. Reference Link 1: http://lists.trolltech.com/qt-interest/2005-06/thread00166-0.html Using Qt Creator 2.4.1 to test the example from Reference Link 1. untiled1.pro SOURCES += \ main.cpp HEADERS += \ qdebugstream.h qdebugstream.h #ifndef QDEBUGSTREAM_H #define

iostream not found in Xcode

匿名 (未验证) 提交于 2019-12-03 08:42:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have problem including ZXing in my App. I get error: "iostream file not found". I have done everything like in ZXing instruction but i can't get this working. I'm including this in .mm file. I use story boards this project is for iOS 6.0 This is error i get: In file included from /Users/adam/Developer/project/project/SecondViewController.mm:11: In file included from zxing/iphone/ZXingWidget/Classes/QRCodeReader.h:10: In file included from zxing/iphone/ZXingWidget/Classes/FormatReader.h:22: zxing/cpp/core/src/zxing/common/Counted.h:23:10:

Fatal error: iostream: No such file or directory in compiling C program using GCC

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Why when I wan to compile the following multi thread merge sorting C program, I receive this error: ap@sharifvm:~/forTHE04a$ gcc -g -Wall -o mer mer.c -lpthread mer.c:4:20: fatal error: iostream: No such file or directory #include <iostream> ^ compilation terminated. ap@sharifvm:~/forTHE04a$ gcc -g -Wall -o mer mer.c -lpthread mer.c:4:22: fatal error: iostream.h: No such file or directory #include <iostream.h> ^ compilation terminated. My program: #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <iostream> using namespace

How to write a streaming 'operator<<' that can take arbitary containers (of type 'X')?

不想你离开。 提交于 2019-12-03 07:27:08
I have a C++ class " X " which would have special meaning if a container of them were to be sent to a std::ostream . I originally implemented it specifically for std::vector<X> : std::ostream& operator << ( std::ostream &os, const std::vector<X> &c ) { // The specialized logic here expects c to be a "container" in simple // terms - only that c.begin() and c.end() return input iterators to X } If I wanted to support std::ostream << std::deque<X> or std::ostream << std::set<X> or any similar container type, the only solution I know of is to copy-paste the entire function and change only the

Colored output in C++

大城市里の小女人 提交于 2019-12-03 07:12:24
问题 Is there a way to print colored output using iostream and Xcode? I'd like to be able to, for example, print Hello World! with Hello red, World blue and ! yellow. How can I do that? 回答1: You need the terminal color codes. For linux it's the following (your system might be different, look it up): //the following are UBUNTU/LINUX, and MacOS ONLY terminal color codes. #define RESET "\033[0m" #define BLACK "\033[30m" /* Black */ #define RED "\033[31m" /* Red */ #define GREEN "\033[32m" /* Green */