Beginners - April 2021 (Page 11)

by PK Dey
inline function
 
The following code gives same result whether "inline" present Or not. Then what is the purpose of "inline" in the following purpose? #include<iostream> ...
[6 replies] Last: inline is just a suggestion to the compiler. [quote=cppreference]The... (by deleted account xyzzy)
by hbcpp
Prevent computer from sleeping in Linux
 
I need a way to prevent the computer from sleeping, turn it on/off at runtime. I believe SetThreadExecutionState https://docs.microsoft.com/en-us/windows/win...
[11 replies] Last: @jonnin You can read here https://docs.microsoft.com/en-us/windows/wi... (by hbcpp)
Provide a proper variable
 
how should I right a variable in int gindex (unsigned int PC, int bank, long long hist, folded_history * ch_i) for "folded_history" class folded_history...
[4 replies] Last: typically a pointer is initialized to one of 3 things: nullptr keyword... (by jonnin)
by akeilo
Needing help with my loop
 
I was wondering how I could fix this loop to keep asking the user to input a number after the wrong number. I also am trying to figure out what I broke. Thank ...
[3 replies] Last: Hello akeilo, Here is something to think about: #include <iostream>... (by Handy Andy)
by hbyte
My Easter Algo - Scrappy Genetic Algo
 
(S)crappy Genetic Algorithm! Visualise solving Styblinski–Tang function This is the Scrappy GA algo. A quick and dirty GA written to be used for Injecting ...
[no replies]
by ericM
pass template object to function
 
I am using several histogram objects (from boos::histogram). I would like to pass these histograms to a function, to handle my program output outside my main.cp...
[3 replies] Last: As a simple curiosity, how do I make sure that T implements the requ... (by mbozzi)
2d matrix problem
 
Array (a) consists of 5 rows and 5 columns. int a [ ][ ] ={{2,-5},{3,6,1,-4,2},{8},{9,2,1,2,9},{4,-6}}; a. Write a C++ code that stores the value 50 instead ...
[6 replies] Last: Hello samzavax, Like I said first show me how you would print the arr... (by Handy Andy)
Whats wrong with my code?
 
Whats wrong with my code? #include <iostream> using namespace std; int main() { int x,y; cin >> x, cin >> y; do { cout << "the smaller v...
[10 replies] Last: Hello Pepeforever, I think it is time to go back to the beginning and... (by Handy Andy)
by NiceS
File getting deleted instead of appending
 
Im trying to create a function that checkout a tool for a user when called, currently my entire checkout file is getting deleted and not getting appended. The ...
[7 replies] Last: outFile.open("tools.txt"); This will delete the tools.txt file da... (by seeplus)
Trying to assing a value of a static member of a struct
 
So i have a simple struct with only a single static varialbe as shown below: struct X{ static int k; }; int main(){ X::k =2; } This does not ...
[4 replies] Last: @seeplus thanks man you are a life saver (by Kallinteris Andreas)
Unable to print user input in quotes
 
Hello so I'm writing a program that converts decimal to binary format but can't seem to print the user input in quotes. For example I want to print; The numbe...
[1 reply] : cout << '\"'; before and after the for loop, not inside it.... (by Ganado)
loop problem
 
I have a project for programming course, I wanted to make a program where I use loop (while, do while, for loop) to book seats for movies in the cinema. the pro...
[2 replies] Last: thank you for your help! I put the code and run it but in the end of t... (by samzavax)
Address of function will always return true
 
Hello, I am new to this forum and C++. I am testing a function that will do something if another function is called or not. Here is what I have but it is givin...
[7 replies] Last: Thank you so much. Using the c was a better approach and it worked. Th... (by patCplusplus)
by PK Dey
t1, t2, t3 undefined
 
when i run the following code it is showing that t1, t2, t3 are undefined! But think they are object of class time. Then why is it showing that t1, t2, t3 are u...
[2 replies] Last: Because time is a standard c function. - which is probably being inclu... (by seeplus)
Unknow error
 
I have this code below implement a simple Virtual Machine to load instruction and do things to data. The problem is the exception I throw when meet a " " at the...
[9 replies] Last: There is a place in your code where you most likely are doing: throw ... (by Ganado)
I need to figure out how to declare variables but my professor is not explaining correctly and can barely understand her
 
#include <iostream> #include <ctime> #include <cstdlib> #include <algorithm> using namespace std; // Funtion prototypes: int getInput(); int findMin(...
[4 replies] Last: how to declare variables See tutorial: http://www.cplusplus.com/doc/... (by keskiverto)
Ternary Operator in this function
 
Hello, I was searching for a solution to a challenge and this was one of the answers, but I can't understand the for(int y:arr). What does it mean? Thank you fo...
[3 replies] Last: It's not good code though - as arr is passed by value not by const ref... (by seeplus)
How can I increment elements of a vector(or array)?
 
Adding to this 'example' would be appreciated : int x = 1; std::vector<int> children{}; int dog = 10, cat = 10 do { cat--; dog--; if (cat == dog)...
[12 replies] Last: @seeplus, yes that was the point, I really did not understand how I co... (by possum swallower)
Printing private class array data
 
I want to get data from an objects array and print it using "cout". Having trouble figuring out how to implement this. I have an array of pointers "classRosterA...
[3 replies] Last: > Why is your Student object called a 'classRosterArray'. That doesn't... (by ne555)
Unrecognized syntax in sample code
 
I did a bunch of C++ programming back in the 1980s and early 90s, but not much since. In trying to program a CoreAudio application, about 10 years ago I found t...
[2 replies] Last: Thanks! Yes, I'm old enough to have read "Goto considered harmful", so... (by Steve Frysinger)
April 2021 Pages: 1... 9101112
  Archived months: [mar2021] [may2021]

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