Beginners - October 2018 (Page 27)

by k88
generating random numbers in an array without repetition
 
Hi,I was trying to generate random numbers to fill in an array but my code seems to not work. Here's my code: int n,m,num; cout<<"num"<<endl; ...
[1 reply] : #include <set> #include <cstdlib> #include <ctime> #include <iostre... (by Repeater)
Assignment Operator for class with struct pointer member variable
 
I am getting a bad access error when the code goes into the assignment operator. Not exactly sure how to write the struct pointer member variable in terms of sr...
[3 replies] Last: These are ok: CSNerd::CSNerd( string name ) // but I prefer initili... (by keskiverto)
having problem with the this problem
 
Using C++ to: Handling Priorities with Linked Lists: Design a class called supportTicket that handles information about reported IT support issues. A ti...
[1 reply] : std::list is a linked list. std::list has sort(): http://www.cplusplus... (by keskiverto)
by benjm
[C] Reusing pointer for new string
 
I was curious to know a good method to reuse a char pointer: char* strfunc (char *sp, int length) { if(!sp) free(sp); sp= (char *)calloc (length, s...
[2 replies] Last: just reuse it? You appear to be overthinking something. step 1) allo... (by jonnin)
Circular Buffer
 
Good day! I'm a beginner in C++, and I'm currently trying to implement a (boolean) circular buffer. I would like to ask about getting the iterator of the begi...
[6 replies] Last: Thank you for your detailed explanation. It's now clearer to me, and t... (by rookie000)
Search and display the comparison
 
I need help with the following question, I don't want the whole code but I really need help with this section. (DISPLAY THE NUMBER OF KEY COMPARISON FOR EACH SE...
[4 replies] Last: Do you mean the number of comparisons until a match was found? Like th... (by Manga)
copy elemnt in buffer
 
a program who copy just length of data which i need for example: data = b\nh\ne\nlength 45\n i need to copy only 45 in my buffer and then return the rest of my...
[1 reply] : I have no idea what you ask. Can you explain with more detail? (by keskiverto)
Can't modify array with pointer
 
Why line 8 (marked with comment) doesn't change array? #include <iostream> using namespace std; int main() { int tab = { 1, 2, 4, 8, 16 }; ...
[2 replies] Last: Holy cow, I'm sory, my mistake - don't catch this assignment. Thanks a... (by GoForBroke)
what(): std::bad_alloc error, what is that?
 
So, how can I fix this error? Here's my code: note that sizes =1239 and it's from a vector of objects. governador : cout << "Voto para governador (nu...
[1 reply] : Duplicate of http://www.cplusplus.com/forum/general/243443/ . DON'T c... (by MikeyBoy)
Nested Loops Help
 
My code is supposed to allow you to input all the inches of rain for the year, then adds them up at the end. when i run the code, i can only input januarys rain...
[3 replies] Last: holy crap i got it. i had the inputRainAmount as an int and was typing... (by LordOfPens)
by Tduck
Why am I getting a segfault?
 
My current assignment tasks me with using fstream, which I now finally understand to an extent, but now I have a problem which I haven't seen since I learned Py...
[3 replies] Last: Why is my code starting at line 10? ??? Please explain. Yes, your ... (by keskiverto)
by Verti
I need help with a project.
 
I'm currently taking an intro to computer science course in college and I'm having a lot of trouble thanks to having a horrendous teacher who teaches in the mos...
[2 replies] Last: You basically read from a (text)file like you read from std::cin using... (by Thomas1965)
calling function from class
 
Im trying to call a bool function called birth(int x, int d, int &v) in main. the function is in a class called GridWorld. Im havin trouble calling it. i...
[1 reply] : not much info is available from your code, what errors are you getting... (by closed account SECMoG1T)
char/string ambiguity causing crash?
 
I'm getting an odd crash whenever I close my program that seems to be caused by a string not de-allocating itself properly. A bit of research indicates it ma...
[6 replies] Last: You haven't actually checked if your input is correct. I tested it and... (by poteto)
My program give me errors What is w
 
int main() { int fahrenheit; celsius; cout << "Please enter a temperature in Fahrenheit: "; cin >> fahrenheit; cout << fixed; cout << setprecisio...
[1 reply] : #include <iostream> #include <iomanip> int main() { double fahre... (by JLBorges)
Need help with reading a text file and displaying it.
 
My objective is to read a text file that looks like this, 3450, Guido VanRossum, 10, 15, 14, 18, 20 6120, Yukihiro Matsumoto, 10, 9, 13, 12, 14 9230, James...
[3 replies] Last: I see, Thanks for the help! (by Awsom3Alan3)
Const
 
Hello. I am recently new to C++ and I was wondering what "const" does, and when I should use it. Thanks for answering!
[2 replies] Last: When you declare something const, the compiler will enforce that promi... (by keskiverto)
Best selling items program
 
Hi i am writing a program that will read a sales.txt file and output the top 2 items sold and their gross sales. unfortunately i can only get the program to out...
[3 replies] Last: Im also having trouble with getting the first and second products high... (by Usm6rn)
explain fragment of code
 
can someone explain how this code ends up with i = 5 i just dont see it. Ive tried messing around with it and noticed that when I change i to 4 the while stat...
[2 replies] Last: Hello COOGSHOUSE713, the expression i / 5 evaluate to an integer becau... (by mycuser)
by Kiryu
Why does my exception skip the catch block and just terminates the program?
 
Considering the following int main() { try{ GLShader shader(); }catch(...){ std::cout << "Hah! Catched!" << std::endl; } ...
[16 replies] Last: Taking a brief look at your code I noticed a memory leak, not gonna te... (by poteto)
October 2018 Pages: 1... 25262728
  Archived months: [sep2018] [nov2018]

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