Beginners - February 2022 (Page 4)

by n00b1e
Problem with generic struct
 
I need to return type that is implicit conversion of type A and type B. Fox example : double a + int b → implicit conversion is double how can I do that, bec...
[2 replies] Last: template < typename A, typename B > constexpr auto operator+(const A... (by seeplus)
by janac
Sharing variable value between threads
 
I want one thread to be constantly updating a variable and have a second thread respond when the variable is a certain value. The second thread isn't responding...
[2 replies] Last: the second thread doesn't seem to be detecting when the variable equa... (by coder777)
This program works fine but I'm wondering if the value in the switch statement in question
 
Is the value in the switch statement is correctly placed? The program works fine and any changes to the value in the switch statement results in run-time errors...
[13 replies] Last: Thanks Againtry, that is an interesting way of using switch statements... (by Julius Caesar1)
My cout seems to be cutting first character (1,2)
 
Hi, I just picked up c++ and just running through some basic tutorial. Code is using cout and cin and the main difference that I did was put the printing in a ...
[20 replies] Last: > the globals (which don't have a constructor) aren't initialized by t... (by JLBorges)
How do i write if input equals string or if input equals integer?
 
when user inputs a string, code goes berserk. i want it to go to the very last else but instead it loops 0 as the input #include <cstdlib> #include <ctime>...
[4 replies] Last: Have a look at getinp() in http://www.cplusplus.com/forum/lounge/27995... (by seeplus)
by Kizzle
Nonsensical errors
 
I've been working on my first c++ project and started getting some build errors with this code but they don't make any sense to me. #pragma once #include...
[6 replies] Last: Thanks! I'll have to watch for those unnecessary includes If the ext... (by mbozzi)
Segmentation Fault after declaring char* inside function
 
Hello. I was trying to make a name generator for my game project, but to no success. I have defined a global char* names , as well as some other C-style strin...
[4 replies] Last: The second parameter is selecting a random index from the respective ... (by jlb)
need help
 
I am having problems with this code. I am hoping someone can help? I am tring to get my program to open and read and calculate the data from my text file so it...
[11 replies] Last: Perhaps: // As C++20 #include <iostream> #include <fstream> #includ... (by seeplus)
by Ch1156
Searching through stl containers
 
So I am going through my knowledge of stuff and trying to strengthen up areas that are the weakest. I noticed I do not know how to search through STL containers...
[12 replies] Last: #include <iostream> #include <string> #include <map> int main() { ... (by JLBorges)
Trouble with my if statement
 
My code is supposed to output "Excellent enjoy your stay" when true, and "lets try that again" if false. But I am getting the false statement no matter what. I'...
[4 replies] Last: Another version: #include <iostream> int main () { using namesp... (by againtry)
by SHGOVI
stack smashing detected error
 
Q.Basic structure program Unable to find an error. This error comes when running this program. *** stack smashing detected ***: terminated Can someone tell ...
[4 replies] Last: cin be C++, as is cout. ... c would use scanf or scan something and p... (by jonnin)
by kaffee
wxFormBuilder code does not compile undefined reference to `MyWindow::MyWindow(wxWindow*)'
 
Hello all, as the title suggests, I am unable to compile my wxFormBuilder project. I am new to c++ (last contact is about 10 years ago) and I am trying to ree...
[3 replies] Last: T H A N K Y O U ! you both. What a silly mistake! LANG="en_US.UTF... (by kaffee)
cin.get error - unable to enter input.
 
Hi, I'm writing a code where ten students input either true, false or blank in an array. Then the compiler will check if the answer is true or not. The actual p...
[1 reply] : As a first refactor consider. Note no error detection/handling for inv... (by seeplus)
Reading and writing different files
 
So the goal is to use ROT13 and read from a file with the words "JULIUS CAESAR" or "Now is the time for all good men and women to come to the aid of their party...
[13 replies] Last: @againtry well I'm not sure if you are saying I've waited till late be... (by jetm0t0)
Defining struct elements according to an enum value of that same struct.
 
Hello. I'm trying to code a card game of sorts, inspired in MTG and YGO. I've declared an enum of possible card types and a struct , which contains as an ele...
[9 replies] Last: What I am confused is with the terminology, "discriminated." What dis... (by mbozzi)
by bg333
Lowest Score Drop (Basic Homework)
 
Hey guys, I'm sure this exact programming challenge has been posted a multitude of times. I've checked older posts on this forum and although they have helped I...
[5 replies] Last: #include <iostream> bool isValid(double); int main() { constexpr... (by deleted account xyzzy)
Unable to load text file
 
Hi! I need some help with why my code is not working as it should be. I would like to read a text file, however when runnning the code I get the error message p...
[4 replies] Last: however the full path in a string variable usually needs \\ or / (wi... (by jonnin)
Code for sorting a char array?
 
Hi, so I was practicing the cin.get function and the question is that u input values in and the compiler will sort the letters out. However, when i run the code...
[5 replies] Last: Yeah, seeplus, I fooked up, not noticing* at the time I was doing the ... (by deleted account xyzzy)
Properly freeing dynamically allocated memory
 
I am having trouble freeing memory. There are many files so I have included only the main portions relevant to the issue. As far as I understand you free memory...
[13 replies] Last: > Did I miss something? You need to download the latest rar file from ... (by salem c)
by tacowo
Using ifstream& as a reference parameter to an ifstream within another function?
 
Hello, I've gotten the apparently classic programming student problem of "here's a text file with a bunch of roman numerals, do math with them." My professor re...
[3 replies] Last: [quote=tacowo]int romanToDecimal( char r ) // takes in a roman numeral... (by lastchance)
February 2022 Pages: 1234567
  Archived months: [jan2022] [mar2022]

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