General C++ Programming - September 2018

Help with files and counter
 
This code is suppose to read a file with student ids and their test scores which then gets an average and put all the information in another file. The problem i...
[1 reply] : Let's look at this snippet: void readscore (int &id, int &test, int &... (by jlb)
by Lyrix
Which one cause std::bad_alloc
 
Thx class Solution { public: vector<string> solution; vector<string> findItinerary(vector<pair<string, string>> tickets) { ...
[1 reply] : The scope of solution is incorrect. Your bad_alloc can happen in s... (by kbw)
problem with a cubic function code
 
I am a beginner with c++ and am experimenting with functions. I am trying to create a code that gives you the zero(s) of a cubic functions when you enter the a,...
[6 replies] Last: You can find the full method here: https://imgur.com/a/kX2mno3 Coded,... (by lastchance)
SIGSEGV on codechef
 
I submitted this code for this challenge https://www.codechef.com/problems/CHEFCHR and got a SIGSEGV fault though the code works fine on my VS 2017 - though I d...
[3 replies] Last: @Peter87, @keskiverto, thanks it's working now. I even got 100% :) He... (by Thomas1965)
Constructors
 
In c++ if I define a class to have a default constructor as well as a parameter based constructor but in the main I only instantiate an instance of the class us...
[2 replies] Last: Look at the C++14 tab in http://www.cplusplus.com/reference/vector/vec... (by keskiverto)
Pass data of pointer to pointer
 
Hi, I am creating a function that will take a void * and pass its value to another void * Here is code: bool test(void* datatoadd, unsigned long long siz...
[3 replies] Last: You should work out why you're trying to write over memory that doesn'... (by Repeater)
by ram000
A simple question about why it always tells me character constant is too long
 
here is my code... #include <iostream> #include <string> using namespace std; int main() { int x; cout << "welcome"; cout << " code please?"...
[3 replies] Last: Thanks so much! I learned a lot today. (by ram000)
Need Help with my logic error for wind chill factor program.
 
Hello Community, I have an issue with my source code. I believe everything is in order when I do the math on paper it comes out a different result then what I a...
[5 replies] Last: Thanks for that it was another arithmetic issue. Enter a value for F... (by NCCspartan85)
How would be resolved this typedef?
 
I have here a piece of code from a state machine, extracted from https://www.codeproject.com/Articles/1087619/State-Machine-Design-in-Cplusplus StateMachin...
[4 replies] Last: First, I thank you for your 'repairing', I fiddled at the code a more ... (by nuderobmonkey)
Class hierarchy
 
I have the following problem. I have an abstract class with a virtual function. < class A{ public: virtual double GetTotalPrice() = 0; }; > A derived...
[6 replies] Last: > So no need to create these pointers, right? We are creating pointe... (by JLBorges)
by Kyoto
Cannot convert 'char(*)[20]' to 'char*' in initialization.
 
#include <stdio.h> #include <stdlib.h> #include <ctime> char location = {"south with beaches", "mountains", "city", "country", "suburbs"}; char color ...
[1 reply] : char* Plocation = location[rand()%5]; //try this. I didn't explain la... (by jonnin)
by kada17
Converting text from file into operations
 
I am writing a program that simulate an assembly language (MIPS). What it does is read binary strings from a file and then convert those into instructions and t...
[2 replies] Last: Thank you for the array tip, I think I know what to do now. (by kada17)
pragma once and circular includes
 
I am used to using defines and #if directive to make sure that already included headers are not included again. On my rewrite of a C++ project I haven't worked...
[8 replies] Last: That doesn't work the way you think. (but it would if you used ifndef... (by poteto)
Unresolved external errors
 
Hi there. I am trying to do a program for school but am getting 4 unresolved external errors having to do with my function call in the main. Please help for the...
[2 replies] Last: Got it, I did that for all of my functions and it works now! Thank you... (by thechamp1202)
Function pointers to operators
 
Just curious. Question within code. #include <iostream> using namespace std; struct Int{ int x; }; int operator +( Int a, Int b ){ return a.x + b.x; } int ...
[8 replies] Last: Thanks @coder777. A catch-22 situation indeed. (by lastchance)
Freind class function inaccessible because of template
 
So function from class A is not available to class B because B has a template type and A can't recognize which type to be friended. Does anyone know what is the...
[2 replies] Last: Remove <N> template<typename N> friend class B<N>; (by Peter87)
Reading Text File with Delimiter.
 
So the file contains integers, string, and a delimiter ','. It looks like this in the file 1234, Whitney Frost, 10, 11, 12, 13, 14 There are 10 students and 5...
[3 replies] Last: You do have: int studentIds ; ifstream inputFile; getline( inputFi... (by keskiverto)
by Vemund
I need a new challenge
 
Hi, I am a hobby C++ coder and used some years now with Arduino. I want to say goodbye to wires and hardware and only code for the windows platform. I am a ...
[1 reply] : AFAIK plugins for GIMP are written in python. Small practical tools f... (by Thomas1965)
Need Help
 
been working on this wage calculator for a while and i cannot get it to print the tax and net pay. please someone tell me what ive done wrong. #include <...
[5 replies] Last: Your tax_rate is 27.0. If your wage has no decimals and hours has no ... (by keskiverto)
cout won't work from within function (ambiguos)
 
Hello everyone, I am new to this site and decently new to programming. I am working on a school assignment and keep getting the "cout is ambiguous" error whene...
[1 reply] : We need to see your code to be able to help. Be sure you post the code... (by jlb)
September 2018 Pages: 123... 9
  Archived months: [aug2018] [oct2018]

This is an archived page. To post a new message, go to the current page.