Beginners - July 2020

Reading the first character of a line from a text file
I have a text file like this: 0 user1 1 user2 2 user3 3 user4 4 user5 If the first line of the string is equal to 0 or 1, etc. I want to do something with it....
Jul 31, 2020 at 8:55pm
[2 replies] Last: Yes that works, thank you. (by CodePanther)
Curious?
I set up a variable such that... float P; Then I assigned a value to it... P = 2 / 7; When I output the resultant value I am told P = 0? All ot...
Jul 31, 2020 at 8:03pm
[3 replies] Last: Thank you; hadn't realised the integer division thing (lovely how all ... (by Gazzieh)
Working with vectors
I am new to C++ but not programming. I am currently working from an old FORTRAN piece of code, which handled vectors in a slightly different manner to C++ (a...
Jul 31, 2020 at 12:22pm
[5 replies] Last: Thank you lastchance; I will do so immediately. That will make my code... (by Gazzieh)
Point.h
Good Evening, I created a Point class defined within two files, Point.h and Point.cpp.(following studies instructions) Then wrote a PointTest.cpp file that will...
Jul 31, 2020 at 2:11am
[14 replies] Last: g++ -Wall PointTest.cpp Point.cpp -o program Assuming PointTest.cpp ... (by Ganado)
no matching function for call to "" (1,2)
This is my specification file, and my implementation file isnt working. #ifndef DATE_H #define DATE_H #include <string> class Date { private: int m...
Jul 30, 2020 at 10:57pm
[25 replies] Last: Something to think about in relation to the use of arrays I mentioned ... (by againtry)
dereferencing pointer
Hey y'all, hope I write this question correctly. My question is directed at the line quiz ->display(); From what I understand, the -> operator de references t...
Jul 30, 2020 at 10:33pm
[2 replies] Last: Ah that actually makes perfect sense, thanks for the input. (by noblemin)
Arrays from text file?
Here is example input.txt: 100 100 100 100 90 100 100 100 80 100 100 100 100 100 I would like to find the sum of the first column and...
Jul 30, 2020 at 1:59pm
[5 replies] Last: First column is score and second column is total possible per assignm... (by dhayden)
by AL88
Why is this infinite while loop with the printf not looping for ever?
Why is this ifinite while loop not repeating the printf statement? It only runs it once! please help me fix #include <ctime> #include <iostream> #incl...
Jul 30, 2020 at 1:48pm
[3 replies] Last: Great minds think alike. (by againtry)
Getting input from a string?
Hello, I am working on a problem where I need to get user input for a string. I have below posted an example as to understand why I keep getting an error that s...
Jul 30, 2020 at 1:25pm
[5 replies] Last: https://docs.microsoft.com/en-us/cpp/cpp/fundamental-types-cpp?view=vs... (by againtry)
Another array question
Could I have some help with an array. I believe that I need a two-dimensional array. Here is exactly the assignment "The program should begin by reading the we...
Jul 30, 2020 at 2:03am
[5 replies] Last: Thank you for your help, it worked out. (by Fayezilla)
help with istream and get()
Hello, i am using the get() function to extract data from a single line of text into multiple fields, split with a comma as a delimiter (,) . ...
Jul 30, 2020 at 1:48am
[1 reply] : Is there a particular reason that you're using C-strings instead of C+... (by jlb)
Why am I receiving these errors about multiple definitions?
Hi, I am receiving the following errors regarding a virtual class with derived classes from it regarding multiple definitions. Errors LNK1169 one or m...
Jul 29, 2020 at 10:32pm
[12 replies] Last: Hi MikeyBoy Some time ago I had coded a program to calculate the expo... (by Shishykish)
Roll dice function rand() always gives same result
Real noob here. Started learning C++ as of this week. Trying to create a dice rolling program where player rolls 3 dice and so does the computer. The one who ha...
Jul 29, 2020 at 9:27pm
[1 reply] : Your rollDice function seeds the random number generator with the curr... (by Repeater)
Passing array to function
Say there's an array: int arr What data types are passed to a function f by f(arr, &arr)? Please help me understand that. Thank you.
Jul 29, 2020 at 7:48pm
[7 replies] Last: Thanks all for your explanations. (by Simon90)
Vectors
Hey pals, i've finished learning the loops( for, while, do while), switch, if, if-else-if , &&, || , increment and decrement operators and some other the very b...
Jul 29, 2020 at 1:37pm
[10 replies] Last: I used to merge againtry's and ne555's code and it seems legit. So muc... (by MaxGreen)
Can someone help me with this assignment please, I cant figure out why my loop is exiting early (1,2)
This is only my second quarter doing C++. The assignment is to steer the rat into one of three holes. The user has to enter their starting bank. So lets say the...
Jul 29, 2020 at 1:11pm
[20 replies] Last: This is actually easy code. If you are up for the challenge and you ke... (by johnglen244)
Infinite loop when validating input
In my program, I am trying to validate the users input an make sure that the only thing they can put in is a number between 1998-2019. The problem is, whenever ...
Jul 29, 2020 at 1:11pm
[2 replies] Last: I use it for when cin fails due to somebody inputting characters or if... (by greenway)
by F95
Incorrect count output / Having difficulty trying to create a HashTable/Set using open addressing
I'm trying to create a program that opens a .txt file containing a speech and assigns each word to a space in the array/set based on the hash value. Collisions ...
Jul 29, 2020 at 12:57pm
[11 replies] Last: also you are missing mTable .state = Entry::FULL; in your add() func... (by ne555)
Sqrt root
Write a program to calculate the following equation for any value of x (user input value): sqrt (pow(x,3)+pow(x,2)-12*x-12)
Jul 29, 2020 at 11:40am
[8 replies] Last: #include <iostream> #include <cmath> using namespace std; int main(... (by againtry)
Writing to the Console Buffer
Hi, My C++ skills are improving but I want to write a fair bit of general code before branching into GUI. Unfortunately, there is only so much you can do by wr...
Jul 29, 2020 at 11:29am
[9 replies] Last: Many thanks. I'll give this a run and go through it. Why don't you... (by Thunderchook)
July 2020 Pages: 123... 12
  Archived months: [jun2020] [aug2020]

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