Beginners - March 2019 (Page 14)

How do I clear the buffer?
Hello! This is some code designed to take the first character of a name inputted by the user and wipe the buffer clean to get ready for the next prompt. However...
Mar 13, 2019 at 6:16pm
[18 replies] Last: Probably the premiere woman in computer science, Rear Admiral (Lower ... (by closed account E0p9LyTq)
by vysero
Loop through vector
I want to loop through this vector: std::vector<DynamicSdmProtocol::DynamicSdm*> m_devices; I am getting an error when trying to loop through it ...
Mar 13, 2019 at 5:56pm
[3 replies] Last: Ah I see now, this was my fault, size() is correct. (by vysero)
by cash
vector insert function
My program should use the function find_if() to find the odd numbers in the vector and add a -1 in front of them, for some reason I'm getting an error? #...
Mar 13, 2019 at 5:44pm
[9 replies] Last: Iterator is more about making ++ polymorphic than about hiding the poi... (by keskiverto)
by Majeek
Improve Beginner Code
So I'm pretty new to C++ and after making this little game after I finished the 1st section of my lessons. (Section 2 is moving onto Unreal Engine) I wanted to ...
Mar 13, 2019 at 2:53pm
[5 replies] Last: Lets look at HiddenNumberGenerator. You want four unique digits, where... (by keskiverto)
Shallow/deep copy
Hello, I have a small code here which results in an error message. class Dummy { public: int *num; int test; Dummy() { num = new...
Mar 13, 2019 at 9:32am
[11 replies] Last: Constructor constructs a new object. Assignment modifies existing obje... (by keskiverto)
Please help
7. Consider the following declaration: class Strange { . . . }; (a). Write a statement that shows the declaration in the class Strange to overload th...
Mar 13, 2019 at 6:34am
[1 reply] : Read this -> https://www.learncpp.com/cpp-tutorial/93-overloading-the-... (by salem c)
What's wrong with my code?
I'm trying to code a program that asks a student for class , year, unit, grade and then displays those on a table then asks again for the next class unless they...
Mar 13, 2019 at 5:51am
[4 replies] Last: So I did that but now instead of asking for Course #1 it just duplicat... (by avaldivia)
grab first char of a string
Hi, I need help grabbing the very first character/letter of a string. As a beginner, I cannot use arrays or anything "Fancy" for this. I tried accepting the ...
Mar 13, 2019 at 1:48am
[12 replies] Last: '\n' is not the null terminator, it is the newline/carriage return. ... (by closed account E0p9LyTq)
by Vetzo
strerror_s: unique_ptr and char array+delete
Hello Forum, How do you use std::unique_ptr with strerror_s? std::unique_ptr<char > pcMessage; pcMessage = std::unique_ptr<char >(new char ); strerror_s(p...
Mar 12, 2019 at 8:54pm
[3 replies] Last: Ah, thank you both. (by Vetzo)
Beginner to class problem
Hi, I'm a student, and my c++ class has an online homework called zybooks and it's a mixture of participation and some challenges. We've begun classes, and it'...
Mar 12, 2019 at 8:32pm
[3 replies] Last: Is virtual something that should be used for classes in general? vi... (by AbstractionAnon)
by Majeek
"int" to "vector <char>"
I would normally just do "Vector.push_back(String )" in a for loop (for strings) but I cant do Int with integers, so how could I do this? void HiddenNumberG...
Mar 12, 2019 at 8:26pm
[4 replies] Last: Lines 2 and 3 are creating a duplicate variable name. Oh well how d... (by AbstractionAnon)
Trouble passing two digit hex values from .txt file into array
Hi, I am trying to use stream to open a .txt file and pass the data inside it into an array. However, I have the problem that when I pass the file (see below) ...
Mar 12, 2019 at 6:51pm
[9 replies] Last: I would do it as a vector and then extract the array from it if you NE... (by jonnin)
reversing struct array's rows
Would this take the struct array in temp and reverse it into temp2, then finally flipping the original image in im.pic? for (int i = 0; i < im.rows; i++) { ...
Mar 12, 2019 at 6:35pm
[8 replies] Last: That's some sick code. Thank you. (by jjordan33)
by AL88
Why is this segfaulting?
I'm trying to write my own address card database program and I am testing out different things like sorting alphabetically, writing a vector to a test file and ...
Mar 12, 2019 at 6:31pm
[1 reply] : Maybe give your vector a size? vector<addressCard> spareVector(numbe... (by salem c)
Integer cin
Hello, for example i have this code int a, b; cout << "enter a number " << endl; cin >> a; cout << "enter a number " << endl; cin >> b;...
Mar 12, 2019 at 6:28pm
[4 replies] Last: Oh, so 1 3 2 should result in a=1 and b=2. (by salem c)
Assigning value to constant integer in Class
Hello, I just started making the following program, Make a class Pointer Declare a 2D integer pointer as private data member in it. And a const int size. M...
Mar 12, 2019 at 6:19pm
[5 replies] Last: Also if you're using modern C++ you could assign the value in the defi... (by jlb)
by JayGln
pragma or ifndef?
I was finishing up an exam my professor gave me with only part of the .h file to answer some multiple choice questions. I wanted to try and figure out where he ...
Mar 12, 2019 at 5:54pm
[11 replies] Last: Funny how these topics reappear so regularly. #pragma once was once... (by Duthomhas)
Error binary operator << in creation of calendar
when I try to run the program, in lines 24 and 53 are giving me a binary error. If Anyone can help ASAP, greatly appreciated. #include<iostream> #include<i...
Mar 12, 2019 at 3:54pm
[1 reply] : Why don't you enclose your code with code-tags? Expect you that we cou... (by nuderobmonkey)
Help Required
Another zero-effort codechef problem poster. If your only skill is copy and paste, then just give up now. Otherwise, grab a pencil and paper and start sketchin...
Mar 12, 2019 at 3:33pm
[4 replies] Last: I will if you can point to it. If i see it I will, but if you already... (by jonnin)
by AL88
How can I replace the existing vector?
How can I replace the existing vector on line 170 with what is read from the file? What can I use instead of pushback(that doubles the vector size). I tried rep...
Mar 12, 2019 at 3:31pm
[1 reply] : Use std::vector 's erase() or clear() methods before you start pu... (by closed account E0p9LyTq)
March 2019 Pages: 1... 1213141516... 25
  Archived months: [feb2019] [apr2019]

This is an archived page. To post a new message, go to the current page.
Registered users can post in this forum.