Beginners - February 2020 (Page 8)

Sum of n Even numbers
 
Just trying to write a basic function that calculates the sum of n even numbers. Ex: n = 3 (2 + 4 + 6 = 12) -> Sum = 12. n = 4 (2 + 4 + 6 + 8 = 20) -> Sum = 20,...
[2 replies] Last: @Ganado, yes I was trying to multiply that was my mistake and didn't n... (by bobcat854)
Why can't I use list insted of array?
 
I'm a beginner in C++ and I have a question in array. We can initialize an array like this: int arr = {0, 0, 4, -3, 7, 8, 2}; and use array for a p...
[14 replies] Last: It's clear now. Thanks to you all! (by MILLER XYL)
Valid Palindrome Error
 
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1: Input: "aba" Output: True Example...
[2 replies] Last: This seems to be equivalent to what you wrote, and I don't get any err... (by dutch)
When designing an interface, should typedef be avoided?
 
Hi I'm designing a library at the moment and have some complex types which I'm renaming with typedef. E.g.: <code> class Newthing {}; typedef vector<New...
[4 replies] Last: Isn't using the new typedef? Yes - it's better than typedef beca... (by mbozzi)
Calendar program with array help C++
 
I need help trying to display a 5 x 7 calendar for each month and detecting if its a leap year. I cannot seem to figure out how to make my array work to display...
[11 replies] Last: const string day_name { "Monday", "Tuesday", "Wednesday", "Thur... (by againtry)
How to go about finding user input (integers) within a text file?
 
To my understanding, you use the getline function in order to find a string of letters from a file, but what if you're wanting to find a certain number in a tex...
[1 reply] : There are a lot of ways, but life can be made easier if you have a par... (by Duthomhas)
****Extract Word Starting With Vowels From A String****
 
So I Need To Extract All The Words That Starts With A Vowel From A User Given Sentence And Print Them.... I can't build a code...(can't Think Anything about th...
[3 replies] Last: #include <iostream> #include <sstream> #include <string> #include <al... (by lastchance)
Problems to change macro through compiler (solved) and segmentation fault (solved)
 
Hi, i'm a new user and i need some help to understand how to put a macro in my code that can be changed from compiler before compilation. My aim is changing...
[9 replies] Last: @Darius00, There is a huge amount to "fix" in your code. First of al... (by lastchance)
by brim4
How to put information from file into an arraya and compare two arrays?
 
I'm new to c++ and have two files "line.txt" which contains : abcfurfghthehgiowl "searchwords.txt" : (6 words in total) As you can see not all the wor...
[2 replies] Last: an array of strings: string sarr ; int i = 0; while (infile >> sarr[... (by jonnin)
by Bopaki
Why am I getting error:Undefined reference to operator<<
 
That operator<< is declared and defined in the program. #include<iostream> #include<cassert> using namespace std; template<class Type> struct nodeTy...
[4 replies] Last: Line 14: Your output operator is private. Line 332,334,339: You're ... (by AbstractionAnon)
Moving array of characters
 
khn
[13 replies] Last: Yes (by zapshe)
Add Two Numbers
 
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single...
[1 reply] : How else do i create a new linked list? Use a constructor that exist... (by dutch)
Valgrind- memory errors and default destructors (1,2)
 
Apologies in advance for the long post! My question is a little involved, and i tried to limit the code blocks as much as possible! Background: A reply to ...
[20 replies] Last: Hmm. I have no idea if you had a reason to avoid updates. I routinel... (by jrbobdobbs83)
by Bopaki
I didn't know what this error means
 
The error is : New types may not be defined in #include<iostream> using namespace std; class opOverClass { friend ostream& operator<<(ostream&,...
[4 replies] Last: Lines 6-7: Your operators are private. That's going to make them imp... (by AbstractionAnon)
understanding class pointers
 
Hello all I am trying to understand class pointer. I have a seen a lot of people use it on the forum. Hence, my questions are as follows below 1. What is ...
[2 replies] Last: Pointers are used primarily in two situations: 1) When you want to ... (by AbstractionAnon)
Alternative to auto
 
I have a sample code that uses auto. The thing is I don't know what auto does, even after looking at online resources. Can anyone give me an alternative to ...
[8 replies] Last: I can definitely agree that this sort of thing is a travesty: auto x... (by Repeater)
Declaring a 2D array constant
 
How do you declare a 2D array constant? FOr example, if we know "that no map will be larger than 500 by 500". Thank you.
[1 reply] : const and constexpr mean the data will not change. eg const int x ... (by jonnin)
by darego
Binary search tree print() only printing out first 2 nodes
 
I have a simple Binary Search Tree which contains various chars. I need a function which prints out all of the node char values in ascending order. Although my ...
[9 replies] Last: Thanks a lot dutch. Works perfect now (by darego)
arguments that are pair<int, int>
 
Hi, I am trying to create a function that has a parameter that is a pair<int,int> but i cant figure out how to pass the values to it, i seem to be getting error...
[4 replies] Last: Still not entirely sure what you're up to, so I can't say that this is... (by dutch)
Sorting Letters and Words
 
Hello, I'm new to C++ and am having a problem with this code. can anyone please help or give me a tip? This is a Letter and Word sorting program Enter two ...
[6 replies] Last: Thank you so much, this will teach me how to work with future projects... (by Frank5093)
February 2020 Pages: 1... 678910... 13
  Archived months: [jan2020] [mar2020]

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