49,761 Topics
| |
I'm getting the error message "Error: expected initializer before 'sum' " from line 9 of my code when I try to compile my program. I can't seem to figure out why it would be throwing this error. Any help would be great. Thanks! [CODE] #include <iostream> using namespace std; struct … | |
I`m trying to program this tic tac toe game, I have the screan printing like I want it to, but I don`t know how to take the user`s input and change the numbers in the array to an "X" or "O" depending on the user`s input, and upgrade the grid, … | |
I am trying to create a dictionary program, just for fun. I doubt I will ever get past twenty words. But this program has a problem. It always goes to the word, no matter what I type in, or press. Here is the source code: [code=c++] #include <iostream> using namespace … | |
Hey guys, I'm working on my final project for first semester of Freshmen year and I have a favor to ask of you guys. This project is very important for the final grade, so I'd love to know if I've made any errors so far? The program works, but I … | |
I am tring to convert std:string to char* in several way, however non of these work: first way: [CODE] char* c_levelMapFile = new char[levelMapFile.length() + 1]; strcpy(c_levelMapFile, levelMapFile.c_str()); ifstream myfile(c_levelMapFile); myfile.is_open(); // returns false [/CODE] second way: [CODE] const char* c_levelMapFile = levelMapFile.append("\0"); ifstream myfile(c_levelMapFile); myfile.is_open(); // returns false [/CODE] … | |
[QUOTE]I have an assignment that requires me to use an array, menuList, of struct menuItemType with members string menuItem and double menuPrice. I have to display the menu, let the customer order, total the bill including tax and print the check. Function getData had to load the data into the … | |
Hi i have a question about inputting to char*. For instance,i have made a class "Name",and am passing my constructors in as follows [CODE] Name* n1 = new Name("Nelly the elephant"); [/CODE] [CODE]Name::Name(char* name){ this->name = name; }[/CODE] But i am confused as to how i would code my addName().Ideally … | |
I have a blackjack game(console game with visual c++), and I was wondering, how do I put in multiplayer? | |
Compiler: DEV BloodShed C++ (latest release) I am following this windows api tutorial and am at this step [url]http://www.winprog.org/tutorial/menus.html[/url] [CODE] //FILE: resource.h // the below code is in a resource.h file // as stated in the instructions. #define IDR_MYMENU 101 #define IDI_MYICON 201 #define ID_FILE_EXIT 9001 #define ID_STUFF_GO 9002 [/CODE] … | |
why subscript operator ([]) must be overloaded in member function?? one may say that because it will take one argument , but operation needs two operands...one the base address and second is index(offset). cdnt it be , if cd have been treated like binary operator as well like this class … | |
Hello everyone: I am a C++ newbie. I aim to use C++ in my work on coupled fluid flow-chemical reaction problems. I would very much appreciate some help to get me on the right track! I apologize in advance for what is probably a very simple question. My goal is … | |
Looks like I miss something, so I need your help, guys. [CODE] #include <iostream> using namespace std; int main() { int* ptr=new int(2); const int* constPtr=ptr; int** ptr2; //... do memory stuff for ptr2 const int** constPtr2=ptr2; typedef int** intPtr; const intPtr ptr3 = ptr2; return 0; } [/CODE] Questions: … | |
How to open c++ using the command prompt so that I can start programming in c++? Thanks! | |
I declared a map of the form [CODE]map<pair<int,int>,int> net;[/CODE] and inserted elements in the following way [CODE]net.insert( make_pair( make_pair(c1,c2 ),cost ));[/CODE] I could access the second element (cost, in the above code) using iter->second. But, I want to know how to access the two elements that form the first pair … | |
I have started to learn C++ and would like to know where to go from now. I have been getting helped by MattyRobot. I have done Hello World, Input, Sqaure of Numbers, Making decisions, Cmd games, Operators, Repeated question and started to make a window. I would like some help … | |
I am trying to read the contents from the specified file into a char array and then send that to the client. The problem i get is that getline() wont take a char array as a parameter and strcat() wont take a string as a parameter so I dont know … | |
Write a program to assign passengers seats in an airplane. Assume a small airplane with seat numbering as follows: A 1 2 3 4 5 B 1 2 3 4 5 C 1 2 3 4 5 D 1 2 3 4 5 E 1 2 3 4 5 The … | |
Sorry, my first post on this forum is a question, but I'm pretty confused about this. There's a few steps in my question, and I'm confused about several. So, here we go: [CODE]baseClass *base; derivedClass *derived; base = (derivedClass *) malloc(sizeof(derived)); memcpy(base, derived, sizeof(derived);[/CODE] Would the memcpy statement work? Would … | |
I'm trying this in Visual Studio 2005 (VC++) [CODE]#include <stdio.h> #include <stdlib.h> #include <string.h> #include <bitset> #include <sstream> #include <conio.h> #include <iostream> using namespace std; #include <time.h> string tot_msg, message, to_be_sent_msg, sent_msg, msg_to_be_sent; char * transport_layer_data_header; char * transport_layer_data_msg; bool whole_msg_sent=false; int actual_len, i, seq_num=0; char * mynode = "2"; … | |
so i wrote a program that is suppose to have a array that has random numbers in it. sort the array, and then do a binary search and interpolation search to find the number and how many comparisons it took. i get it to work sometimes but the comparisons are … | |
[CODE]#include <iostream> #include <ctime> #include <cstdlib> #include <string> #include <vector> #include <fstream> #include <algorithm> using namespace std; class letter{ private: int genre; int price; string adress; public: letter(); ~letter(); }; class parcel{ private: int genre; int price; string adress; public: parcel(); ~parcel(); }; class post{ private: letter** LETTERS; parcel** PARCELS; … | |
i am currently making a project in Data Structures which checks similarities between two c++ source codes....i am going to use the tokenization approch to do it.... [U]but i am having trouble in finding an efficient way of parcing source code [/U]so that i can turn it in the form … | |
Hi everyone. I'm a reta-I mean a beginner and 98% of my bugs are something really obvious... but I've checked this so much and I don't know what to do. This is my function to create an Employee object, called when the user wants to add a new employee to … | |
I am trying to draw a hollow square and I am having a problem with nesting while loops within while loops. Is this possible? The quoted part of code is the trouble part. #include <iostream> using namespace std; int main(void) { int sides, t=2, h=0, b=0, s; cout<<"Size of square: … | |
I have this code that uses epoll and it has a problem. When I run it, it gives output: Server-socket() is OK... Server-bind() is OK... 3 4 accept: Invalid argument I'm running it on ubuntu linux, system updated, both as limited user and root what is wrong with the input … | |
Its showing size of type is unknown or zero [code=c++]#include<conio.h> #include<stdio.h> #include<graphics.h> #include<iostream.h> #include<math.h> int gc,gd=DETECT; int x[3][4],tx,ty,i=0; float turn[3][4]; void draw() { moveto(x[0][0],x[1][0]); for(i=1;i<4;i++) { lineto(x[0][i],x[1][i]); x[2][i]=1; } lineto(x[0][0],x[1][0]); } void rot() {double ang; float rot[3][3]; cout<<"enter the angle through which u want to rotate the figure\n"; cin>>ang; rot[2][2]=1; … | |
I have an assignment to write an ATM program (it just needs to be basic) and I am getting one error when I try to compile: On line 28, I get an `expected unqualified-id before '{'`. I don't know that it's the only thing wrong with it, but any ideas … | |
I made the following function for my Sudoku solver but the answers keep turning out wrong (some of the numbers are showing as doubles right next to eachother). Can somebody help please? [code=c++] void reduction_candidateLines(void) { /* * declarations */ //drives loop int k, j, x, y, z, t; //counts … | |
/*This is an assignment for school. The main is part of the assignment. The program will work sometimes, sometimes it will not count the longest word if it is at the end of a sentence.*/ #include<iostream> using std::cout; using std::cin; // Prototype for the longest_word function that you need to … | |
I can not get the program to read the entire sentence. The main is part of the assignment. Any suggestions would be a great help! [CODE]#include<iostream> using std::cout; using std::cin; // Prototype for the longest_word function that you need to write. // Add consts where necessary to obey the principle … |
The End.