Beginners - February 2019 (Page 2)

Logic time erros: Help fixing
 
Hello!! My code is to find the length, midpoint, and slope of a line segment using 2 points. It compiles and everything, but i just can't seem to find the logic...
[1 reply] : Edit your post and repaste your code between tags to preserve ... (by dutch)
by bzarr
error: ld returned 1 exit status
 
When ever I try to run my program I get an error saying ld returned 1 exit status and I can't figure out why. I have checked all spelling and type of variables ...
[1 reply] : Try checking the spelling of your function names! (by dutch)
by adabo
Conditionally erase object from a vector of objects.
 
Help. I get a runtime crash with this code. It compiles fine in Visual Studio Community. I want to conditionally erase an object from a vector of objects. When...
[1 reply] : Read up on the erase method. It returns a new iterator. #include <i... (by dutch)
by bzarr
expected primary-expression before ‘]’
 
I keep trying to run my code through g++ and for some reason I always get the expected primary-expression before']' and I'm not sure how to make it work. Also t...
[3 replies] Last: This part char o; ifstream inFile; inFile.open("data121.txt")... (by dutch)
Modifying this code to read 8 inputs onto one single line?
 
I am trying to modify this code to receive any amount of input, rather than just 10, but also giving the user a code word like "DONE" to end the program. Howeve...
[2 replies] Last: #include <iostream> #include <sstream> #include <string> #include <v... (by CodingIsHard17)
Why can't I use mid here?
 
Why do I get an error when computing the following line? vector<int>::iterator mid = (vi.begin() + vi.end()) / 2;
[2 replies] Last: You can't add the iterators. Try vector<int>::iterator mid = vi.... (by dutch)
Not getting right values with distance formula
 
I'm working on a problem for school to calculate the area of a triangle given a set of numbers from an input file. I've got everything working, but im not getti...
[13 replies] Last: yeah, that * 1.0 was me thinking the issue was in the distance calcula... (by MediumSizedFoot)
C Hangman Program
 
My assignment was to convert a C++ program into a C program. This program is like the game Hangman. My problem is the code compiles and runs in Unix VI editor, ...
[2 replies] Last: thank you so much! (by mysiarobin1987)
Can someone help me understand this program involving vectors?
 
So I am not sure what this code means so can someone break it down for me? #include <iostream> #include <sstream> #include <string> #include <vector> ...
[2 replies] Last: Okay I see. How can I make it read 8 inputs per line after converting ... (by CodingIsHard17)
Getting Polymorphism for friend functions
 
Hi guys, I learned that you can manage polymorphism with somthing like this for operator<<. class Base { public: friend ostream& operator<<(ostream & out...
[1 reply] : Your operator<< doesn't need to be a friend. #include <iostream> c... (by dutch)
for loop exponents
 
I can't figure out how to get the proper output. The code gives me an output like: Enter a positive integer: 5 5^5=25 • asks the user to a positive integer ...
[4 replies] Last: it probably does look weird because honestly I don't know what I'm do... (by dhayden)
Permutations and combinations
 
Hi I need help trying to figure out what I am doing wrong here. My assignment is to generate permutations and combinations of 4 people. However, when I run it a...
[2 replies] Last: C++ arrays are accessed starting at index 0, not 1. So if there are 4... (by dhayden)
Need help understanding program
 
So I understand how this program is suppose to work; however, the commented part of "Notes" isn't clear for me. Under "test if new entry is now the largest," ho...
[1 reply] : The variable largestSoFar is meant to contain the largest value you'... (by dhayden)
Help with linked list
 
Hello, So I'm working on an assignment and I'm stuck on a few things. I need to create a linked list to add employees and their data to. The first part is addi...
[2 replies] Last: Look at InsertBeginning(). This inserts after the node L. So that is... (by dhayden)
Calculator help
 
I'm getting this error when calculating the total bill. https://prnt.sc/mqf5n6 I kinda know what is the issue, it means if an user does not select one of the ...
[11 replies] Last: @Ganado yes it correctly added. thankyou! (by nickname687)
Having trouble with event-controlled loop
 
Write your question here. Demonstrate how to use an event-controlled loop to read input and find (remember) the largest value entered and number ...
[3 replies] Last: please remove your double post http://www.cplusplus.com/forum/beginner... (by ne555)
Need help with data processing
 
I have a text file with the content like this ABC 5 EDFS 6 WERT 4 TYHFS 7 What I have to do is read the text and the number then generate the kth...
[1 reply] : std::ifstream input("filename"); std::string word; int number; while(... (by ne555)
generate random numbers
 
Hi, this program should read an arbitrary number of integers, it should stop when "esc" is pressed, they should be stored in a vector and finally end by disp...
[1 reply] : You say you want the numbers to be stored in a vector, but you don't h... (by Cheddar99)
Reading csv file
 
I have a csv file like this No,Student ID,Last name,First name,Gender,DoB 1,18127221,Nguyen Van,Tuan,Male,4/11/2000 2,18127222,Tran Van,A,Female,9/6/2000 3,18...
[9 replies] Last: Hooray the result is great! Thanks all for your help! Good days! (by thinhphucvang)
by Majeek
Make a line of code that will execute std::cin
 
I'm trying to make a "Guess the Number" game where the user picks the HiddenNumber and the AI trys to guess the number. I relized that to do this like a normal ...
[2 replies] Last: Ty! (by Majeek)
February 2019 Pages: 1234... 23
  Archived months: [jan2019] [mar2019]

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