Beginners - January 2021

c++ find duplicate strings in vector and print all occurrence of them
 
So i'm looking for a soultion to print duplicate strings in a vector. If the vector contains {a,b,c,a,d,a,a} i want to print each "a" out of the vector. For the...
[12 replies] Last: Based on this statement: Loop over the given array of strings to buil... (by lastchance)
Question regarding primes in array
 
Hello all, I am trying to spot all the prime numbers within an array however my code, apart from the prime numbers it gives me an some non-prime numbers as w...
[6 replies] Last: if you are checking for small values (I see a %10 in there!) you can g... (by jonnin)
about dynamic_cast
 
When I delete the body content of Class B, errors occur on compilation. I tried to replace "virtual void dummy() {}" with " int abc;" and the errors stills pop...
[5 replies] Last: > I see a pointer pointing to a base class can also be used to point t... (by ne555)
by telco
Writing a matrix in text file
 
I am trying to create a new text file and write a matrix value in it using fstream. But i am getting errors with this code. Would anyone please suggest me how ...
[11 replies] Last: We are (a library is) allowed to create proxy objects and use expressi... (by JLBorges)
Compiling and running your program
 
I have no idea what I’m doing honestly. Coming from Java, VS code 2019 is new to me. I’ve tried clicking the build button on the ide but when I want to run ...
[6 replies] Last: all IDE make a bunch of 'intermediate' files, not just an exe. All co... (by jonnin)
Copy pointer to pointer in function - C (1,2)
 
Hello, I'd like to copy pointer to pointer in function and I don't want to use the library. But in main I have the old string instead a new string. Thanks...
[22 replies] Last: > in that regard, > int insert(char*& str1, char* str2, size_t n) > ... (by JLBorges)
Only accepting 4 inputs from user
 
Hello guys. I am a beginner in c++. I am trying a coding where user can only enter 4 characters for time1, time2, time3 but its ending up in crash. I couldnt pa...
[3 replies] Last: Hello Mathavan, Consider this for you function: int add_movie() //... (by Handy Andy)
Trouble converting while loops to for and do loop
 
Hi 2 everyone, I have been working on this for some time now and have been stuck in the same spot. I have figured out how to get the answer I wanted with 2 whil...
[3 replies] Last: @cpluspython - please don't edit the original post so that future answ... (by seeplus)
by Feit
How to convert string to long int
 
Hi everyone, I need to declare a vector using string and then convert it to long int. I wrote the following code but it is showing error. string state ...
[6 replies] Last: @seeplus and @salem, many thanks. Very helpful answers (by Feit)
Read a whole sentence till i find a specific word
 
hi, i wanne read a sentence that is no more than 100 symbols and when it reads the word stop it ends reading the sentence. char*text; cin.getline(tex...
[4 replies] Last: Consider: #include <iostream> #include <iomanip> #include <cstring> ... (by seeplus)
Conditional wait and signal in multi-threading
 
Hye! I saw this code on geeks for geeks. But I am not able to fully get it. // C program to implement cond(), signal() // and wait() functions #inc...
[2 replies] Last: t1: created and starts running foo main: sleeps for 1 second to ensure... (by lost110)
by Ch1156
Correct use of this pointer (1,2)
 
I was following along with a youtube video on how to do some OOP stuff like inheritance and all that, and I was wondering if this is the correct use of the this...
[31 replies] Last: Excellent. Another aspect to throw into the melting pot is UML and cla... (by againtry)
Cicle Class Project
 
Hello, I am hoping someone can tell me why I am getting this error in my code. Code is for an assignment Instructions Below: "Construct a class named Circle ...
[3 replies] Last: Doing console input correctly when you want to flag non-numeric and ce... (by George P)
by kmce
Class inheritance problem
 
I am creating a small program to practice inheritance etc and I am having a issue that I can not figure out. I have an engine class which I can create with its ...
[2 replies] Last: Oh of course, that was stupid of me. thank you (by kmce)
Won't do the right thing.
 
Please look through my code. Its to long to post here: https://ashtonfroude.wixsite.com/mysite-3/post/help-needed Idk what can be the matter with it. Its not do...
[11 replies] Last: If you're going to link code externally, please just use something sim... (by Ganado)
Varied Amount of input data
 
Currently working on a lab that requires me to make a program that takes any number of non-negative integers as input, and outputs the maximum value and average...
[4 replies] Last: max = input worked, thank you! (by StaveDrider)
Confusing question regarding semaphores and threads
 
I am not able to understand this dependency diagram because there are no arrows in it! Whether thread A should execute first, release thread B and either B rele...
[1 reply] : I'd say the first place to start is here https://docs.microsoft.com/en... (by markyrocks)
There is a problem reading the file.
 
I completely enter the file address for the code test. But ''else'' is constantly executed. What could be the problem? The test file and the code itself with th...
[6 replies] Last: Oh right, cin >> char_array would add the null terminator already. Tha... (by Ganado)
by abrock
Documentation of std::nth_element
 
Hi, I'm using std::nth_element on vectors, some of them are pre-sorted and some are not. I found that my code implicitly assumes that vectors which are alrea...
[2 replies] Last: Which description from where? If for the cplusplus.com site, then pro... (by seeplus)
ofstream - unable to write onto next time line
 
Am i doing it right? I am still really noob at this. Everytime i run the code, only a line of text will be saved on the txt file. #include <iostream> #in...
[3 replies] Last: Open the file in append mode: ofstream projectFile("projectfile.txt... (by seeplus)
January 2021 Pages: 123... 11
  Archived months: [dec2020] [feb2021]

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