iostream

Reading streams from image on a web page in asp.net

孤街浪徒 提交于 2019-12-12 03:00:58
问题 I have an image bound in the image control in my asp.net website. I am using C# to develop it. Below the code to bind the image. byte[] imageBytes = System.IO.File.ReadAllBytes("filepath"); string base64String = Convert.ToBase64String(imageBytes, 0, imageBytes.Length); this.testImage.Src = "data:image/jpeg;base64," + base64String; Now I want to take the streams from that image control (testImage) in another event. I dont want to save the image in any server path. How Can I do that? Thanks in

Can a custom stream buffer automatically flush at program exit and when requesting input?

大兔子大兔子 提交于 2019-12-12 02:28:15
问题 Loki Astari provides this custom steam buffer. How can I change the class to automatically flush when reading from cin::cin or when the application exists? For example: int main () { MyStream myStream(std::cout); myStream << "This does not print."; } and int main() { MyStream myStream(std::cout); myStream << "This does not print."; std::cin.get(); } whereas std::cout << "This does print."; and std::cout << "This does print."; std::cin.get(); If I force it myStream << "This will now print." <<

Stuck in loop while trying to get input from cin

只愿长相守 提交于 2019-12-11 23:42:10
问题 Okay I'm very new to C++, I'm experianced with C# and I don't really know what is wrong in my code. I'm just trying to figure out how to check whether the user's input is a integer or string. But when I type 'a' or some other string, the while loop never ends. #include <iostream> using namespace std; int main () { int number; goto skip; do { cout << "Wrong input. Try again."; skip: cout << "Number: "; cin >> number; } while (!cin); cout << "Correct input."; system("PAUSE"); } 回答1: Once your

Visual C++ not allowing iostream

痴心易碎 提交于 2019-12-11 18:03:52
问题 I just started C++ I am reading the ebook Starting out with C++ 7th edition. I copied the code from the book and put it into Visual, under new project w32 console app with precompiled headers. Well When I use the iostream in the preprocessor directive line i get.. I searched around and do not understand why the iostream won't work, any help? 1>------ Build started: Project: dd, Configuration: Debug Win32 ------ 1> stdafx.cpp 1> dd.cpp 1>c:\documents and settings\leon\my documents\visual

proper way to read user input from command line in java

蓝咒 提交于 2019-12-11 16:47:49
问题 I was hoping to get some opinions regarding best practices and comments on the way I read user input from the command line. Is there a recommended way to do this, am I using the try/catch blocks properly? My example here works fine, but would still like to hear if there is a 'cleaner' way to do this. Many thanks. For example are he return statements in each catch block necessary? Or, should I put my logic (the conditionals) within the try block? public class Client { public static void main

C++ After I use getline to read from a file I can no longer write to the txt file

南楼画角 提交于 2019-12-11 15:04:23
问题 I am able to write to a text file then I use getline and I can no longer write to the file. #include <iostream> #include <fstream> #include <string> using namespace std; int main(){ ifstream infile; fstream crypto; ofstream hacker; string tempString; string tempString2; string plaintext; string line; string dec; . . . crypto<<"hello";//write some stuff to file here use getline(crypto, line, '\n') crypto<<"hi";//Doesnt write to file anymore. 回答1: Files have a single error status and a shared

Mixing formatted input extractors with getline causes cout display to stick together

泪湿孤枕 提交于 2019-12-11 14:33:20
问题 The following code seves to establish a movie database and query through it. It works as intended except for the first cout statements being clumped together. The code is as follows. // array of structures #include <iostream> #include <string> #include <sstream> #include <stdio.h> #include <cctype> using namespace std; #define NUM_MOVIES 6 //structure struct movies_iit{ string title; int year; } films [NUM_MOVIES]; //global variables char title [20], y, n; int year; string search; //function

Boost asio ip tcp iostream Error Detection

我们两清 提交于 2019-12-11 12:46:41
问题 Greetings. I'm just getting started with the boost::asio library and have run into some early difficulty related to boost::asio::ip::tcp::iostream. My question has two parts: 1.) How does one connect an iostream using simply host and port number? I can make the client and server [boost.org] examples work fine as coded. The server specifies the port explicitly: boost::asio::io_service io_service; tcp::endpoint endpoint(tcp::v4(), 13); tcp::acceptor acceptor(io_service, endpoint); Port 13 is a

no match for ‘operator<<’ for std::endl after overload

早过忘川 提交于 2019-12-11 10:38:53
问题 I am sorry that I duplicate this question, but I don't have the reputation required to comment there and the answers there are not convincing for me. #include<iostream> class my_ostream : public std::ostream { public: std::string prefix; my_ostream():prefix("*"){} my_ostream& operator<<(const std::string &s){ std::cout << this->prefix << s; return *this; } }; int main(){ my_ostream s; std::string str("text"); s << str << std::endl; } Here I get: no match for ‘operator<<’ in ‘s.my_ostream:

Does ostringstream inserter use current locale?

六眼飞鱼酱① 提交于 2019-12-11 10:25:26
问题 To convert double to string without scientific notation, the suggested way is std::ostringstream strStream; strStream << std::fixed; strStream << value; std::string str = strStream.str(); as in Prevent scientific notation in ostream when using << with double & How do I convert a double into a string in C++? I want to convert double to string without any separator and Dot/Full-stop as the decimal point, i.e. ignoring locale. From description of ostringstream, std::fixed and showpoint, I couldn