49,757 Topics

Member Avatar for
Member Avatar for noamco

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

Member Avatar for noamco
0
167
Member Avatar for monkey_king

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 …

Member Avatar for mvmalderen
0
476
Member Avatar for mrinal.s2008

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) …

Member Avatar for jencas
0
100
Member Avatar for Shaitan00

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 …

Member Avatar for jencas
0
190
Member Avatar for Shaitan00

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 …

Member Avatar for jencas
0
139
Member Avatar for whotookmyname

[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

Member Avatar for whotookmyname
0
77
Member Avatar for anilopo

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 …

Member Avatar for anilopo
0
85
Member Avatar for Darkmorgaine

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; …

Member Avatar for sotvisal
0
224
Member Avatar for lotrsimp12345

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 …

Member Avatar for lotrsimp12345
0
195
Member Avatar for mrnutty
Member Avatar for qkslvr1621

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 …

Member Avatar for qkslvr1621
0
98
Member Avatar for qkslvr1621

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 …

Member Avatar for qkslvr1621
1
91
Member Avatar for Kadence

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 …

Member Avatar for jbennet
0
152
Member Avatar for ivanhuk

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 …

Member Avatar for ivanhuk
0
173
Member Avatar for mrgreen108

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 ); …

Member Avatar for vmanes
0
193
Member Avatar for kirennian

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 …

Member Avatar for wildgoose
0
650
Member Avatar for zeus1216gw

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) …

Member Avatar for zeus1216gw
0
98
Member Avatar for Samuelandjw

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 …

Member Avatar for MosaicFuneral
0
1K
Member Avatar for Michael_Tanner

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. …

Member Avatar for Michael_Tanner
0
2K
Member Avatar for Ancient Dragon

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 …

Member Avatar for Ancient Dragon
0
192
Member Avatar for GECKA

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

Member Avatar for GECKA
0
78
Member Avatar for whotookmyname

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 …

Member Avatar for sureronald
0
86
Member Avatar for TarekSliem

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"; } …

Member Avatar for ankitloud
0
248
Member Avatar for Zachster

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 …

Member Avatar for shadwickman
-1
54
Member Avatar for Democles

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 …

Member Avatar for TimeFractal
0
154
Member Avatar for _dragonwolf_

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) …

Member Avatar for _dragonwolf_
0
134
Member Avatar for reyaanhelp

If anyone have "bus reservation system" c++ code in classes format then please give it to me.

Member Avatar for Salem
-1
65
Member Avatar for TheSilverFox

[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 …

Member Avatar for csurfer
1
103
Member Avatar for doublebond

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 …

Member Avatar for csurfer
0
994
Member Avatar for Cloneminds

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 …

Member Avatar for wildgoose
0
223

The End.