iostream

Why can't g++ find iostream.h?

匿名 (未验证) 提交于 2019-12-03 02:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm trying to understand how to compile C++ programs from the command line using g++ and (eventually) Clang on Ubuntu. I found a webpage which explains MakeFiles and I am following their directions. http://mrbook.org/tutorials/make/ I downloaded the four example files into their own directory. main.cpp hello.cpp factorial.cpp functions.h I then went ahead and ran their example of how to manually compile without a MakeFile. g ++ main . cpp hello . cpp factorial . cpp - o hello When I ran the command from above, I received the

error C2065: 'cout' : undeclared identifier

匿名 (未验证) 提交于 2019-12-03 01:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am working on the 'driver' part of my programing assignment and i keep getting this absurd error: error C2065: 'cout' : undeclared identifier I have even tried using the std::cout but i get another error that says: IntelliSense: namespace "std" has no member "cout" when i have declared using namespace std, included iostream + i even tried to use ostream I know it's a standard noob question but this has stumped me and I'm a novice (meaning: I've programed before...) #include using namespace std ; int main () { cout << "hey" <<

error C2065: &#039;cout&#039; : undeclared identifier

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on the 'driver' part of my programing assignment and i keep getting this absurd error: error C2065: 'cout' : undeclared identifier I have even tried using the std::cout but i get another error that says: IntelliSense: namespace "std" has no member "cout" when i have declared using namespace std, included iostream + i even tried to use ostream I know it's a standard noob question but this has stumped me and I'm a novice (meaning: I've programed before...) #include using namespace std; int main () { cout I'm using Visual Studio

Why std::cout instead of simply cout?

怎甘沉沦 提交于 2019-12-03 00:53:20
问题 I get these error messages for all cout and endl : main.cc:17:5: error: ‘cout’ was not declared in this scope main.cc:17:5: note: suggested alternative: /usr/include/c++/4.6/iostream:62:18: note: ‘std::cout’ After following the suggestion, everything is fine. Now I am curious, why I had to do that. We used C++ in classes before, but I never had to write a std:: before any of those commands. What might be different on this system? 回答1: It seems possible your class may have been using pre

undefined reference to `std::ios_base::Init::Init()&#039;

匿名 (未验证) 提交于 2019-12-03 00:46:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I write this code to read 3 files, TM is the size of square matrix, LER the No. of rows of an array and from last value define a non-square matrix of (ler/2)*2 Then... the code read a file with some relations, all are numbers and are assign to C[ler]. Then ... C[ler] is assigned to B[ler/2][2]. Those coordinates, per row, in B[ler/2][2] are assign to a and b. a and b are the row and the column of the matrix A[tm][tm] where to add 1. My code crashes and I don't see what the error is. When I try to compile it, the compiler gcc -g -o MatSim

Why does ofstream(“log.txt”, ios::app|ios::trunc); always fail?

℡╲_俬逩灬. 提交于 2019-12-03 00:22:54
The following code was compiled with VC++ Nov 2012 CTP on Windows 7 x64. #include <fstream> using namespace std; int main() { ofstream fout("log.txt", ios::app|ios::trunc); if (!fout) { cout << "An error occurred!" << endl; // Always go here! Why? } } The cppreference.com website doesn't say that ios::app cannot be combined with ios::trunc . What are the exact semantics of ios::app and ios::trunc ? The filebuf constructor to which these flags are passed † has behaviours based on those flags defined in Table 132 in C++11: +-----------------------------------+-------------------+ | ios_base flag

Colored output in C++

放肆的年华 提交于 2019-12-02 23:05:17
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? shuttle87 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 */ #define YELLOW "\033[33m" /* Yellow */ #define BLUE "\033[34m" /* Blue */ #define MAGENTA "\033

read equivalent for filebuf?

霸气de小男生 提交于 2019-12-02 19:46:06
问题 typedef struct { char c[20]; int i; } header; void foo(std::string s) { std::ifstream ifs(s.c_str(), std::ios_base::binary | std::ios_base::in); if (ifs) { std::filebuf* pbuf = ifs.rdbuf(); pbuf->pubseekpos(std::ios_base::beg); // ... ? } } I'm trying to read a file in binary mode the C++ way, I can't identify the right method to call for reading the bits from the file, there is a read for ifstream but if I'm supposed to use that method, what is the point of filebuf ? To simplify things I

How to read numbers from an ASCII file (C++)

我们两清 提交于 2019-12-02 18:41:19
I need to read in data files which look like this: * SZA: 10.00 2.648 2.648 2.648 2.648 2.648 2.648 2.648 2.649 2.650 2.650 2.652 2.653 2.652 2.653 2.654 2.654 2.654 2.654 2.654 2.654 2.654 2.654 2.654 2.655 2.656 2.656 2.657 2.657 2.657 2.656 2.656 2.655 2.655 2.653 2.653 2.653 2.654 2.658 2.669 2.669 2.667 2.666 2.666 2.664 2.663 2.663 2.663 2.662 2.663 2.663 2.663 2.663 2.663 2.663 2.662 2.660 2.656 2.657 2.657 2.657 2.654 2.653 2.652 2.651 2.648 2.647 2.646 2.642 2.641 2.637 2.636 2.636 2.634 2.635 2.635 2.635 2.635 2.634 2.633 2.633 2.633 2.634 2.634 2.635 2.637 2.638 2.637 2.639 2.640 2

iOS app with real-time updates from server: Socket (using streams) or Apple Push Notification service?

自闭症网瘾萝莉.ら 提交于 2019-12-02 18:23:48
I'm trying to make an iOS 5 app that features real-time things coming from the server. It will only use these whilst the app is running. To make it real-time without polling I have been evaluating two design routes: Creating a socket from the app to the server, and exchanging information via streams. Pros: Relatively simple and would not involve a 3rd party. Cons: Battery life drain. For an overview of how this might work, check out this excellent tutorial: http://www.raywenderlich.com/3932/how-to-create-a-socket-based-iphone-app-and-server Using standard HTTP to communicate with the server,