49,757 Topics
| |
I have a strange bug in vs2008. ostream open fails when called in the following manner: [CODE=c++]ofstream filestr; filestr.open((filename.c_str()),ios::in|ios::out);[/CODE] when called like this it works without a hitch: [CODE=c++]ofstream filestr; filestr.open("blahblah.txt",ios::in|ios::out);[/CODE] Any ideas? Thanks | |
Hi I got a code that in pseudo dos something like [CODE] ifstream os; while(os.oef()){ os.getline(buffer,length); } [/CODE] If some condition is met, I'd like to be able to jump back to the previous line, such that the next getline will give the line just-read in, at a later time … | |
Hi, I have some questions on vector. Please consider the code below. I use g++ compiler on Linux. [CODE=c++] #include<iostream> #include<vector> using namespace std; class Sampler { int a; int b; }; int main() { vector <int> vec1; vector<float> vec2; vector<Sampler> vec3; cout << sizeof(vec1) << " " << sizeof(vec2) … | |
The age old issue of string parsing comes up again ... I have a text file that contains lines that are SUPPOSED to follow a set format, specifically: string, string, long string int string double int The delimiters are therefore: Comma (,) for the first two fields Spaces for all … | |
Not sure this is going to be easy to explain but ... I have a class (A) that needs to have access to a map (mapCodes), this map is the same for all instances of class(A), therefore I don't want to create an instance of the map for each instance … | |
[code] string s; cout<< "Enter name: "; cin >> s; cout<<"\n"<<s; [/code] on running this i need: Enter name: Tejesh Kinariwala Tejesh Kinariwala it is showing: Enter name: Tejesh Kinariwala Tejesh so how to get the input till user hits return key, instead of breaking it at space | |
i've wrote a code that read and write to some files, and i have a segmentation fault when i'm running it in the g++ (in the visual studio i don't have any problem like that..) anyway, i think the fault may come from this line, can anyone tell me if … | |
Hi i have to make this work... [code=cplusplus] //INFO: -eingabeprüfung auf buchstabe/zahl // -eingabeprüfung auf zahlenbereich // -wiederholung einbauen vill... #include <iostream> using namespace std; int main() { int eingabe; cout<<"Geben sie eine zahl ein> "; cin>>eingabe; if(eingabe>0 && eingabe<13) { switch(eingabe) { case 1: cout<<"eins"<<endl; break; case 2: cout<<"zwei"<<endl; … | |
gives me error main /* The purpose of this lab is to open a text file and then make a copy of it */ #include <iostream> #include <fstream> #include "Interface.h" using namespace std; int main() { //open up file to be read from string input; ifstream in; cout<<"enter file name … | |
I'm trying to write a program that asks the user for a number between 1 and 10, then prints a line of that many “X"s. The program compiles, but I cannot figure out how to make the variable 'total' print X's instead of a the actual number, if that makes … | |
I need to write a program that decides if you can apply for the job or not. After asking a series of questions (all the questions) the program then needs to print out whether you can apply or not. Here are the requirments for the job • If you are … | |
I'm having a lot of trouble finding enough RAM for a program I'm writing on Vista 64 Ultimate system, even though the system has 8GB RAM and only 2GB is used. I tried to see how many 10 million byte blocks I could allocate using malloc(), and the compiled program … | |
Help, am a c++ student who is completely stuck. I know that there are some stupid errors in this, I've been working all day on this and I still can't find them. I'm supposed to create a class, copy constructor, and than create an instance in main and then create … | |
I have a slight homework problem that is giving me some trouble. We have to write the algorithm for subtraction using different bases as a possibility in a program that uses calculator registers. The following is the provided prototype: bool subtractRegisters( int registerX[], int registerY[], int registerZ[], int base ); … | |
Hi there! With reference to the annoyance of this problem, I've spent some time searching the web as well as on here however, with few ways to extract useful threads from those less useful when typing 'RegSetValueEx int' or the like, posting was a final solution. Apologies if this type … | |
how can I use a loop to sum random numbers together? it needs to be able to sum any amount of numbers determined by the user. I can generate the random numbers but adding them is a different story. I tried to make an inner loop (if that makes sense) … | |
I often hear the saying that iostream is inefficient in terms of performance, and it is better to use printf family if type-safe is not concern. But as far as I know, the static type checking (is this thing people call the 'type-safe' do?) is done in the compilation, and … | |
Hello, I happen to be a novice in the realm of C++, and I'm currently confused due to this error when trying to run my application: "Assertion Failed. Expression 'stream != NULL' ". I've looked it up, and nothing that comes up can answer why it gives me said error. … | |
Has anyone tried to write [URL="http://support.microsoft.com/kb/307398"]this tutorial [/URL]using VC++ 2008 Express? The article claims to be written with VC++ 2005. But I thought 2005 and 2008 used compatible versions of CLR language. I'm getting all kinds of compiler errors -- for example [icode]String* str;[/icode] instead of using [icode]String^ str;[/icode] and … | |
Please need some help on what servers in windows/linux can c++ applications be deployed? Is the .exe file deployed or a library is created out of the application for deployment? thank you | |
I have to open a file whose name i am constructing by concatenating various inputs from the user. If I write: [code] string s = "filename.csv"; ofstream fout; fout.open(s,ios::app); [/code] it gives error for using s in fout.open(). It says it is a wrong form. I need to use a … | |
The problem that i couldn't know if the mistake from the code or from the compiler? i have been setup cygwin.........as starting to learn Linux and into it as a start to learn c++ i want to compile a (hello world) code ================== [code] #include<iostream.h> void main() { cout<<"helloworld"; } … | |
I'm a newbie to C++ and am wanting to make a game where Zombies come after you and you slay them, along with jumping, running, shooting, stabbing, well you get the point but idk how. also i have a main menu done but i don't know how to preview it … | |
Hello, I am trying to compile a set of files. I got fustrated to the point of taking the actually instructor files from the book and compiled them. I am using AndLinux and the g++ compile to run my programs. If anyone is familiar with the book "Accelerated C++" I … | |
Here is my final product: [code] #include <iostream> #include <fstream> #include <iomanip> #include <string> using namespace std; void printGrade(int oneScore, float average); void printTable(int scores[], int id[], int count); float computeAverage(int scores[], int count); const int MAX_SIZE = 21; void readStudentData(ifstream &rss, int scores[], int id[], int &count, bool &tooMany) … | |
If anyone have "bus reservation system" c++ code in classes format then please give it to me. | |
[code=CPP]#include <iostream> using std::cout; using std::cin; using std::endl; void Calculate( double ); int main() { int worked; double salary; double pay; cout << "Enter the hours worked: (-1 to end)" << endl; cin >> worked; cout << "Enter the salary: " << endl; cin >> salary; while( worked > 0 … | |
Hi Guys, Please help me in doing this. I am trying to read a file using fstream, but my prof wants me to do the same using hash table, which i have know idea. Please tell me hw can i do the same. The file contains huge data like the … | |
Hello again, My assignment is to calculate a 10% bonus based on sales figures. I have to use a main() function, obviously, and 3 void functions, getSales(), calcBonus(), and displayBonus(). I'm pretty sure I have the functions coded correctly, I'm just having some issues getting them to actually run correctly … |
The End.