49,761 Topics
| |
Hello, I'm trying to have my program locate any duplicate strings in an array, say, there were two instances of the word 'man', it would add 1 to the Word Amount of that word, and move the duplicate to the back of the array in some way. The problem is, … | |
My initial thoughts on the default constructor are that it was called automatically. From what I can see, it seems that this is so but a constructor called automatically doesn't initialize int or char variables for exampe, to Zero as I originally thought. It appears that they initialize the variable … | |
I am trying to find the minimum number when the user enters any 5 numbers I am not sure why this code is not working, every time I run this function I always get 0. Can someone please tell me what is wrong! int i; int num1 = 5; int … | |
Im trying to increase a dynamic array by 1 element and assign a integer variable to it but recieve a heap overload error. Any advice would be appreciated. void CardSet::AddCard(int cardNum) { int* tmp; nCards++; tmp = new int[nCards]; for(int i = 0; i < (nCards - 1); i++) { … | |
///Can someone tell me why I am having an issue calling my functions?!?!?! #include <iostream> #include <iomanip> #include <string> using namespace std; struct Players { string name; int numPlayer; //Number of the Player int numPoints; //Point's scored by Player }; const int SIZE = 50; const int MAXPLAYERS =3; typedef … | |
Hello, I learned a lot of basic C++ programming through Code Blocks and I think it is a fantastic IDE. I decided to switch to VS2010 Professional for various reasons, and because I am able to get it free from Dreamspark. I had created another post a while back similar … | |
program in which we calculate total marks in a course and print a course grade by using if-else conditions. However check, if user enters correct marks or not, for example midterm marks is between 0 to 20. If user enters midterm marks less than 0 or greater than 20 then … | |
Hi, I've been trying to send a long integer from an Arduino to my C++ program via the serial port. There seems to be many examples of this when i search, but I've not had much luck except for one example. This example seems to work, but not when I … | |
Hi. I am trying to assign the value returned by asctime(struct tm \*) to a string. But when the program is run, I got segmentation fault. GDB shows: Program received signal SIGSEGV, Segmentation fault. 0x0000003e6d6aa192 in __offtime () from /lib64/libc.so.6 What could be the reason? Can't we assign the value … | |
Hello, I am having trouble passing a file into parallel arrays. Based on the code below, I get a bunch of jumbled numbers on my cout screen that don't even show up in the input file. I have attached a PNG of the console output. I am at a loss … | |
I am trying to learn multi-dimensional arrays in C/C++, but am not having much luck. I think I understand the way this type of array works, but I am having problems. [code]#include <stdio.h> #include <stdlib.h> #define MAX_NAME_COUNT 10 #define MAX_NAME_LEN 100 int main(){ char *names[MAX_NAME_COUNT][MAX_NAME_LEN]; int x; printf("enter the names … | |
//This programm is for testing function overloading #include <string> #include <fstream> #include <iostream> using namespace std; class Text { string str; public: Text (); Text (string); string contents (); }; Text::Text (string st) { ifstream in (st); getline (in, str); } string Text::contents () { string ret; ret=str; return ret; … | |
void getScores(float **scores, int num) Can someone help me understand what this means? Especially the **scores.... I know what a float is and that it is to get scores inputed in by the user. Thanks | |
I am having trouble getting MS Visual C++ to recognize my input for the 2nd getline I have listed. It already recognizes getline(cin, firstName) and allows for input, but won't recognize the second instance of getline. When the program gets to that line of output, it bunches the next two … | |
I started coding C++ this past week, and yesterday I challenged myself to write something original that my book doesn't have hints on. It is a program that prompts the user to think of a number between 1 and 100, and proceeds to guess the user's number. The user tells … | |
I have written a program for the 8-Queens problem.It prints all possible solutions. queens() finds all the possible solutions. ok() tells whether the given column and row is safe or not. The very strange problem is: 'Count' won't increment. I have no idea why. #include<iostream.h> #include<stdlib.h> #include<conio.h> int arr[8][8]={0}; int … | |
Hi, I'm making a program using Visual Studio 2010. I'm strugging with how to correctly use classes and their instances. For example; What is the difference between using the following ways to call function from one class within another... Example 1: Dialog.h #include OtherClass.h MyOtherClass myClass; Dialog.cpp myClass.MyFunction(); Example 2: … | |
Hi all. I'm working my way through "Accelerated C++" have a question regarding chapter 5. The program calculates students final grades by taking a median of the homework grades. I am trying to alter this program so that it uses *list* instead of *vector*. The issue I'm having is with … | |
My school and the education board uses Turbo C++ as the compiler. I have Windows 7 64 bit. Can anyone tell me how can I install Turbo C++ on my computer. | |
So I am trying to write a program that will tell you the lowest grade and the highest grade out of the 3 wthat you put in and also tell you the current average you have in the class. I got the lowest and highest part taken care of but … | |
I've been trying to get this to build for hours, I have no idea what's wrong. Any help is appreciated, thank you. Here's the code: main.cpp #include "SDL/SDL.h" #include "Core.h" #include "GameStates.h" #include "globals.h" int main(int argc, char** args) { if(core.Initilization(640, 480, 32, SDL_SWSURFACE) == -1) { SDL_Quit(); } while(core.desiredstate … | |
**this is my displacement.h** #ifndef DISPLACEMENT_H #define DISPLACEMENT_H class displacement { public: displacement(double, double, double); double getvalue(); private: double s,t,a,v ; } #endif **this is my displacement.cpp** #include "displacement.h" ;using namespace std; displacement::displacement(double t1,double a1,double v1) { t=t1; a=a1; v=v1; s = v * t -(0.5) * a * t … | |
im very new to c++ and was just wondering if its possible to make a simple program where you type the name of the file and when you press enter it downloads that file from the internet to a certain place on your computer. where would the files be stored? … | |
Hi All, I am new to C++ on linux enviroment and am trying to use the png++ library for a project. The problem i am facing is that that a simple program i write using png++ incudes does not work and shows me the following errors > AProg.o: In function … | |
Hello All! To check for return values from a function and setting error flags, i am currently using the following approach: bool fine = true; fine &= func1(); fine &= func2(); .. and so on. if (!fine) { // error } Could anyone please let me know if there is … | |
Hi! I want to execute a method without pressing the enter key, what I want to do is get the press key an save it in an array while the user is typing, but I dont know how to execute an event without pressing the enter key here is my … | |
Hello forum, I believe that i have the design problem that i need to discuss about. Intersectable is the super-class; Triangle and Sphere are the sub-classes of the Intersectable i believe that you already realized class inheritance structure. I have the following pure virtual functions declared inside the INTERSECTABLE virtual … | |
There are N horses in the stable. The skill of the horse i is represented by an integer S[i]. The Chef needs to pick 2 horses for the race such that the difference in their skills is minimum. This way, he would be able to host a very interesting race. … | |
I'm trying to read from a text file. Pretty simple, right? I guess not. It gives me this error message: Debug Assertion Failed! Program: F:\Debug\lab1431.exe File: fscanf.c Expression: stream != NULL For information on how your program can cause assertion failure, see the Visual C++ documentation on asserts. [code] #include … |
The End.