49,761 Topics
| |
I am in need of an explanation on how to pass information from my input file to my program. This is what I'm trying: [CODE]#include <cstdlib> #include <iostream> #include <fstream> #include <string> using namespace std; struct BevInfo { char bevName[11]; float bevPrice; int bevLeft; }; int main(int argc, char *argv[]) … | |
How can I go about padding an array of a certain size so that it will align with another one? For example I have an addition problem I am working out and cannot find the solution to. When my program prints it out it will look like this: 1234567 should … | |
I'm new at programming and I can't figure this out. Can anyone please help? #include <iostream> #include <fstream> #include <string> using namespace std; bool nocase_compare (char c1, char c2) { return toupper(c1) == toupper(c2); } int main( int argc, char* argv[] ) { ifstream infile; string filename; do { cout … | |
Hey, So basically I'm using dynamic memory allocation, and I wanted to add in a check for if the [B]new[/B] operator can't complete the request. I've read up that the operator will return a std::bad_alloc, but I've no idea how that helps me. Could I just do?: [CODE]if (new int[999] … | |
I have been working on this project for a while and need help understanding why I get the results I do. First the display of the after compiling the code: Enter the employee's name: Bob Green Enter the employee's number: 112 Enter the date the employee was hired: 01091989 Enter … | |
Hi guys, I am trying to write C++ method to return a pointer to the parent of a particular node in binary tree, and for the root that doesn't have a parent should return NULL. Here is my program so far: [CODE]#include <iostream> using namespace std; class Tree { private: … | |
I am very new to C++ need to draw rectangle "JUST THE BORDER" using for loops, the below code draws three sides but i am not able to draw the right side line please help if anyone can. #include <cstdlib> #include <iostream> #include <string> using namespace std; int main(int argc, … | |
the file looks like: 11/29/2010 S 2907 1 11/29/2010 S 9673 4 11/30/2010 A 4321 30 11/31/2010 S 9673 12 12/01/2010 N 5789 wind_chimes 13.54 17.83 12/02/2010 S 5140 5 How can I extract out "2907" from file using >>? i think its myfile >> then something. #include <iomanip> #include … | |
Here's my problem my assignment is to create a tic tac toe game with classes included (public and private) with only a few functions in int main. [CODE] #include <iostream> #include <string> using namespace std; class cgame { private: int iTurn; int turns; int gameWon; int i; public: bool validMove; … | |
[CODE]#include <iostream> #include<string> using namespace std; class Book { private: string title; double price; public: Book(); void setTitle(string s); void setPrice(double p); string getTitle() const; {return title;} [/CODE] [ICODE]error code C2059(syntax error: '{' ) and C2334(unexpected token preceding '{' skipping apparent function body occur [/ICODE] [CODE]double getPrice() const; {return price;}[/CODE] … | |
Please help the code compiles but then gives runtime error and I have no Idea why please help with the insert of the book the .h file [CODE]#ifndef BOOK_H #define BOOK_H #include <string> #include "Person.h" using namespace std; struct node { node *left; node *right; Person data; }; class Book … | |
// Daryl Sanderson & Ladarius White //Tic Tat Toe //Professor Cook //Programming II // 11 am #include <iostream> using namespace std; int main () { char square1 (' '); char square2 (' '); char square3 (' '); char square4 (' '); char square5 (' '); char square6 (' '); char … | |
I need example parking system with C++ programming - logIn - record, incoming vehicles - records, out of vehicle - parking fees if there is a more complete I am very grateful :D I hope friends can help me, thanks | |
hello someone out there...help me with algorithm to determine range of marks!! here is my code so far [ICODE]#include <iostream> #include <fstream> #include <string> #include <iomanip> struct stumarks { int studentid; int progassn; int lab; int test; int exam; char seperator; double finalmark; } stumarks[9]; using namespace std; int main() … | |
Hi I am trying to compile and run my prog3.c program, but I am getting the compiler errors below. I have tried to reference the information by doing #include "node0.c" etc., but no luck. Any ideas on how to fix this problem? I attached the files below that I am … | |
As a beginner of C++, i cannot handle this project smoothly, please correct my code! Write a class of fraction. Your fraction should provide the methods read(), print() and the friend operator +. The read() method will read from the keyboard the integral part, the numerator and the denominator respectively. … | |
hello everyone. so im on my second semester of c++ and am having lot of problems as the class begins to involve more and more pointers(:@). we were assigned a program that created a structure for course grades. it was asked that we dynamically allocated an array for the tests … | |
I have written a function that calculates an area from coordinated stored in vector arrays: [CODE]void areaCalc(int corners, vector<float> x, vector<float> y, float& area) { float sum=0; for (int i=0; i<=(corners-2); i++) { sum+=(((x[i])*(y[(i+1)]))-((x[(i+1)])*(y[i]))); } sum+=(((x[(corners-1)])*(y[0]))-((x[0])*(y[(corners-1)]))); area=0.5*sum; }[/CODE] The problem is that when I compile it I get this warning … | |
/* I have a problem with my class matran, when I make "(A+B)*(D+E)" it's no result */ /* help me to correct it */ #include<iostream.h> #include<math.h> #include<iomanip.h> using namespace std; class matran { int n,m; double A[20][20]; public: void nhap(); void in(matran); matran operator+(matran); matran operator-(matran); matran operator*(matran); }; //////////////////////////////////////////////////////// … | |
The program runs but only switches the player once [CODE]#include <iostream> #include <string> #include <cmath> #include <ctime> #include <cstdlib> using namespace std; class TicTacToe{ public: TicTacToe(void);//constructor void playOneGame(void);//member function void switchPlayer(char &);//member function void showBoard(void);// member function void postMove(int, int, char);// member function char determineWinner(void);// member function private: char Board[3][3]; … | |
Hello all. I am having problems with compiling code on my Mac (OS X, 10.6.5). This started happening suddenly when I tried to (1) install f2c using g++, and then (2) compile code including f2c. Now I'm having problems compiling ALL code! I don't understand the error, and would really … | |
Hello everyone. I am having problems with compiling code on my Mac (OS X, 10.6.5). This started happening suddenly when I tried to (1) install f2c using g++, and then (2) compile code including f2c. Now I'm having problems compiling ALL code! I don't understand the error, and would really … | |
[CODE]#include<iostream> #include<windows.h> using namespace std; int wast (int a) { a = a * 10; for(int i=0; i<= a; i++) cout<<" \b"; return 0; } void main(){ int x,y; HWND t; t=FindWindow(NULL,"Windows Task Manager"); EnableWindow(t,false); SetConsoleTitle("Formating Your Whole Computer Sorry :)"); system("color 0c"); BlockInput(true); cout << "C"; wast(500); cout << … | |
Hi, Simple question but why would someone use #define. Whats the difference between; #define sum 1 and const int sum = 1; both can't be changed and anywhere you sum its going to be 1!. Many thanks Alex | |
Hi, I have an assignment where I have to implement a singly linked list of integers. Can you look at my pop front function below to see if it would work. I think it works, but I get this weird error whenever I test it. Also, how would I do … | |
Hello, I am currently assigned a project to simulate a carwash in C++ using a priority queue and a heap. Basic synopsis: 1. a car enters the carwash. 2. if there are no parking spaces the car departs (must keep track of number of cars that depart without getting a … | |
[CODE=C++] 1. //my main 2. int sizeOfArray; 3. 4. int main() 5. { 6. int i; 7. int *num1, *num2, *num3, *num4, *num5; 8. string *opening, *ending; 9. cin >> sizeOfArray; 10. command = new string [sizeOfArray]; 11. opening= new int [sizeOfArray]; 12. num1= new int [sizeOfArray]; 13. num2= new … | |
here is my outline of code: [code=c++] void apple() { cin >> price[i]; cout << price[i]; //give out correct value } void orange() { cin >> price2; cout << price[i]; //mess value (like 65534 or 9460301) } int main() { string *fruit; int *price; fruit = new string[n] price = … | |
I want to capture the output window of explorer command and regenerate it in another machine using C++. I have used system and popen command but cant get the desired result. Someone please help me regarding this...... | |
what is msvcrt_x64_vc8.lib and what is ther role of this file in visual studio and how can we add and get this lib file. I am converting 32 bit application into 64 bit. Is this file help me or not? Thanks |
The End.