Beginners - March 2022

Questions about C++ strings...
Hey, thanks for coming here. Currently I'm learning C++ and beyond. While I'm using C++ strings and come up with some inconsistencies. Do we really need incl...
[6 replies] Last: Really thank you, guys. I learned that c++ header files are not having... (by bydrachen)
Matching one part of a struct with another
follow-up to Thanks for your help on my last post, but I've already gotten stuck again, I need to know if its ...
[3 replies] Last: that aside, this is a major POINT of structs/objects, is the ability t... (by jonnin)
Is it better to declare global variable or declare variable multiple times?
So I got some code, it looks a little like this... void Func(int i) { //calculations with i. } int main() { int i; Func(i); //more calculation...
[4 replies] Last: Objects offer a way to control globals and limit access if you must us... (by jonnin)
by Paul5
C++ program to sort even nums in descending order then odd nums in same order using one array and without built in functions
#include<iostream> using namepsace std; int main() { int a ,i,n,j,k,temp,c=0; cout<<"Enter size of the array :"; cin>>n; cout<<"Enter el...
[19 replies] Last: [quote=Paul5]So the time complexity of the program you mentioned above... (by lastchance)
String Manipulation
hello I have been trying to get parts of this code to work. I had it compling before but not anymore(i think bracket problem). Mainly Ive been trying to get ...
[6 replies] Last: im using dev c++ version 5.11 update: i think i got it figured out no... (by HellocMonkey)
using cin with structs
I'm trying to create a digital vending machine using structs for all of the Items in the vending machine, but I just tried using cin and im getting an error tha...
[3 replies] Last: you can overload the << and >> operators for cin and cout making them ... (by jonnin)
by Squabs
Writing Functions for Number guessing game
Trying to finish an assignment and need some assistance. Trying to write functions for a number generator 100-1000. I need to Generate a random number between 1...
[8 replies] Last: Using C++ random - rather than C rand()/srand(), then: #include <ra... (by seeplus)
Min and Max Value in Array
I am trying to find the minimum and maximum value from my text file array but the output is always 0 for both the max and min. #include <iostream> #include ...
[3 replies] Last: This program can be simplified. #include <iostream> #include <fst... (by seeplus)
by Pen72
No output
The way to swing the list follows the algorithm below : 1Pick the smallest integer from s and append it to the result. 2Pick the smallest integer from which...
[4 replies] Last: Using the iterator on line 45 is illegal due to the erase on line 44. ... (by coder777)
Why is system() hated so much?
Why do people say using system() is bad coding? I like using it to create "breaks" in my programs so you can press enter to continue and stuff that makes the pr...
[5 replies] Last: To help explain @kigar64451's comment, the black terminal screen you s... (by mbozzi)
by Pen72
Using Multiset
The way to swing the list follows the algorithm below : 1Pick the smallest integer from s and append it to the result. 2Pick the smallest integer from which...
[3 replies] Last: [new thread at ] (by seeplus)
Nesting Loops Explaination?
I finally understand the basics of the for loop but I am really having a hard time grasping the concept of how and when to use a nested loop. Is there anyway so...
[1 reply] : Nested loops are often used with 2 dimension arrays such as your theat... (by AbstractionAnon)
by worldd
Dominos problem
An integer N is given, followed by N number of pairs of integers - the pairs represent domino tiles. Each tile can rotate (ie the first number becomes the secon...
[6 replies] Last: heh.. adding tiles to the start is changing the starting point, though... (by jonnin)
by Pen72
Sum of numbers
Any idea to solve this problem in a more efficient way other than comparing it one after another? -------------------------------------------------------------...
[2 replies] Last: #include <iostream> #include <vector> #include <set> #include <algori... (by lastchance)
Reading numbers from a file into an Array/Vector
Hi had a question about reading a file with a int and a string and putting it into a vector/array The file is called options.txt and contains: 5000 Leather S...
[4 replies] Last: #include <iostream> #include <fstream> #include <string> #include <v... (by seeplus)
by Pen72
Improve time efficiency
Given a sequence of distinct integers A . An inversion pair is defined as a pair(Ai,Aj) , such that i<j and Ai>Aj . Please count number of inversion pairs i...
[5 replies] Last: Adding a condition is tiny, agreed. I would think that skipping the l... (by jonnin)
Solving data alignment issue
I have function A that only spits out arbitrary amount of byte (on range of 0x10 to 0x80), and function B that allows me to pass data only in 0x100 byte. Th...
[4 replies] Last: You are right jonnin. I used memmove at the end and it works well for ... (by Happilicious)
by Pen72
Coach problem (1,2)
A train moves from A through a station to B. Initially, the coaches of the train is numbered by 1,2,...n. You want to know whether you can rearrange the c...
[20 replies] Last: oh yes, there's no warning message, I'll try using the debugger, thank... (by Pen72)
Help with password requirements code.
I have been doing wicked good lately thanks to all the help I've been getting here but I am having some issues with this code. I am trying to write a code that ...
[3 replies] Last: Valid - if input < 6 digits and inputLength <= 8 ?? Seems a queer vali... (by seeplus)
Do .tcc/.tpp files need headerguards?
If I understood correctly .tcc/.tpp files should have their includes in the correspnding .h file and aren't included more than once. So I am guessing that they ...
[1 reply] : That's right. You only need to use header guards for the header files. (by Peter87)
March 2022 Pages: 123... 7
  Archived months: [feb2022] [apr2022]

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