49,761 Topics
| |
Basically I need to writed a program that asks for a double and if the user inputs something keep going, but if the user just presses enter then the program should end. The problem is i can't get it to do anything after the person presses inter eg double value; … | |
Hi. I was wondering if someone could help me out with a project. The assignment says to call a void function called InsertIntoArray passing the array, the entry the user entered and place the positive integer into the correct element of the array so that the array is always in … | |
am new to c++, and am having trouble with if else statement for this code i am writing a program that makes the computer guess a number you the user has choosen my program works fine, but when i get in trouble is when my range gets down to zero … | |
beginning in c++, i have a question of a recent program for this program i am trying to create a game where the computer try's to guess a number 1-100 that the user has chosen and i have it running good. but where i have a problem is at the … | |
Im trying to make a C++ program to calculate the resistance in a parallel electric circuit. The formula is Total = 1 / (1/resistor1)+ (1/resistor2).... + (1/resistorN) I have made the program however when I compile it it has the "linker error" Can you please help me spot the mistake … | |
How do I prevent holding when reading stdin? I'm creating a program with glut that uses the terminal for input and using fscanf() is holding up the process. How can I check the stream before calling fscanf()? | |
I'm having trouble reading in values from a file. I know how to get all of the values in the file, but I only need some of them. This is my code (a snippet) so far. [CODE] ifstream myStream( file ); // file is the file name . while (true) … | |
Got a code failiure. I tried making a code that does this. Grade calculator. Assume max points are 300. make the user submit 3 numbers between 0-100 and have them added together and divided by 300 to get a decimal to the possible nearest Hundredth or whole number. 3 numbers … | |
I'm taking an advanced C++ class now, and everything up to now has been pretty simple (mostly review stuff), but now we got to binary file io and it's kicking my butt. This program is supposed to read from a file called "Hardware.dat" (or create it if it doesn't exist), … | |
long seats; long no_of_guests; long fact=1; cout<<"Enter the number of seats nn"; cin>>seats; cout<<"nnEnter the number of guestsnn"; cin>>no_of_guests; for(int i=0;i<seats;i++) { fact*=no_of_guests; no_of_guests--; } cout<<"the possible combinations : "<<fact<<"nn"; this code has run successfully but there is a something that I couldn't get first this program will run this … | |
[QUOTE] I want to have two classes one for creating the dataset as a factory class and the other is my Dataset class. factory class could read data from files or memory address and also it can create random data and finally returns a dataset. first i want to implement … | |
Could you please tell me how to arrange my code so that the invalid statement like in my displayed output will only show up if some enters a wrong character. Here is my code: #include <iostream> #include <fstream> #include <iomanip> #include <cmath> using namespace std; int main() { //(1) Declare … | |
Hello, I am new to C++ programming. I need to do this problem for a class but I'm a bit stuck, it's giving me many errors, could anyone point out what the problem is please? This is the problem: A country club, which currently charges $2,500 per year for membership, … | |
I am newbie in programing, and learning it... I need to know how do i make that program: Examples will help... I need to use UDP communication to connect to server by client and search, at server,for the longest directory, get the longest directory path and number of deepest level, … | |
on line 32 how would i go about inputting a file name to be called by my function which im using a const char pointer for the file name line 33) error C2664: 'calculationOutput' : cannot convert parameter 1 from 'char' to 'const char *' [CODE]#include<iostream> #include<fstream> #include<string> #include<iomanip> using … | |
Hi...I have a problem.. I need a function which is able to remove a word from string and replace it with other word (string).. I have nice working function in pure c++ but I dunno how to do that in visual c++ ;( 10x for help! [code] void FindAndReplace( std::string& … | |
how would i go about doing the std output to a file for this line? to be more clear i want it to append to the file not overwrite because i run the function multiple times outputting to the same file [CODE]std::outFile << "The area with the highest average temperature … | |
Sir, i have done this code but an error is coming...... [B]the function getline should have a prototype undefined symbol 'string' [/B] what shoul i do? I am compiling this code in turbo c++ compiler..... [CODE]#include<string.h> #include<iostream.h> #include<conio.h> using namespace std; int main() { string number; string name; cout << … | |
Hi .. i want to print this pattern of number using loops . if input is 5 then output should be ... 155555 224444 333333 444422 555551 i have solved 1 22 333 4444 55555 but another reflection is not coming in my mind ... and making me confuse need … | |
I have been trying to capture the enter key in a windows.net textbox but i have no idea how to do it, i googled searched but the only examples i find are visualbasic and c# ones and when i try to do thesame thing in c++ in doesnt work. I … | |
Hi, I'm working on a linked list filled with class objects and I've encountered a weird problem that I cannot see how to resolve. I declare 2 self-referential pointers within my 2 classes and the error: In file included from prog2.cpp:16: employeedatalist.cpp: In function âvoid getData(std::fstream&)â: employeedatalist.cpp:15: error: âheadâ was … | |
is there another way to write this code other than using bool for validation [CODE]bool isValid = true;[/CODE] | |
Hi all, I'm trying to implement a blob coloring/region labeling algorithm to find and label all blobs/objects in a given image so that at the end of it, I can eliminate all but the largest object. I represented the image by a mask matrix (int binary[image size]) where zero co-ordinate … | |
i put the numbers into my calculator and i receive a number that is about $1 greater than the actual value. why? [CODE] #include<iostream> #ifndef Tips_H #define Tips_H using namespace std; class Tips { private: long double taxRate, bill, gratuity; public: Tips() { taxRate = 0; bill = 0; gratuity … | |
Well, Hello Again! I'm now using pure C++, too hard But well. I just love how you can manage everything Windows have, is like owning Windows. But well, i have some issues: [CODE] extern "C" __declspec(dllexport) char *getValue(char *valueName) { HKEY hKey = HKEY_LOCAL_MACHINE; LPCSTR lpSubKey = "SOFTWARE\\Dantom\\BYOND"; PHKEY phkResult; … | |
#include <iostream> #include <fstream> #include <iomanip> #include <cmath> using namespace std; int main() { char fare; char choice='Y'; int hrIn, minIn, hrOut, minOut; int hours; int minutes; int total_minutes; double cost; float charge; float additionalTime; while(choice=='Y'||choice=='y'){ cout << "\nThis program will calculate a single, couple, or group " << "\nfare … | |
ok i have i want to summarize only the first collum [CODE]int counter=1; int totalvertical=0; int i=7,k=4; int array[i][k]={random values}; for (int x=1;x<7;x++) { for (int y=0;y<4;y++) { cout<<"["<<x<<"]["<<y<<"]="<<array[i][j]<<" "; totalvertical=array[counter][0]; cout<<totalvertical; } counter++; cout<<endl; }[/CODE] line 12 prints me normaly what is at array[1][0] then array[2][0] then array[3][0] etc … | |
i dont see how this is possible but....is there a way i can have a literal value in my program....such as the number "1" represent a specific variable? for example int sum; sum = 1 + 3; <--- i want my program to read this as add "3" to the … | |
[CODE]void Form1::textBox9_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) { if(!Char::IsDigit(e->KeyChar) && (e->KeyChar != 0x08)) e->Handled = true; }[/CODE]Thats the code i got, but, how could i allow CTRL+V. [CODE] if(Char::IsDigit(e->KeyChar)) return; if(e->KeyChar=='\b') return; if(e->KeyChar=='\v') return; if(e->KeyChar=='CTRL') return; e->Handled=true;[/CODE] This also doesn't work ._. (Im using Visual Studio 2010) | |
[CODE]void Rational::reduce(Rational &f3){ int tnum, tden, temp, gcd; tnum = labs(numerator); // use non-negative copies tden = labs(denominator); // (needs cmath) if(tden==0 ){ // check for n/0 cout << "Illegal fraction: division by 0"; exit(1); } else if( tnum==0 ){ // check for 0/n numerator=0; denominator = 1; return; } … |
The End.