General C++ Programming - August 2017 (Page 2)

Prima numbers
 
How can I write a c++ code based on this algorithm? **I'm new with C++. //Implements the sieve of Eratosthenes //Input: A positive integer n > 1 //Ou...
[1 reply] : The general policy here is that we aren't going to just do your homewo... (by Ganado)
My c++ program i a lot of slower than my java counterpart
 
Good day. I have written a program in java and c++ which takes an int list as an input and returns a list of all possible permutations. I used the exact same lo...
[7 replies] Last: you know how many you need, its a given computation... do a reserve on... (by jonnin)
by randym
How to get full path from relative path
 
Does anyone know any c++ function that I can use to retrieve a full file path from a relative file path.
[2 replies] Last: C++17 / Filesystem TS: std::filesystem::canonical() / std::experime... (by JLBorges)
by Li1
Overloaded oparators
 
Hi! I don't undstand overloaded operators...can you explane how it works...somebody.. Thanks
[3 replies] Last: In addition to max's excellent summary, the following lecture notes mi... (by gunnerfunner)
Why is SET slower than VECTOR in this case?
 
Hello. The code below runs faster with a Vector rather than with a Set vector<string>files{ "vocabolario1.txt", "vocabolario2.txt", "vocabolario3.txt" }; /...
[5 replies] Last: Thank you everyone. Line 27 looks through the set, one item at a tim... (by gedamial)
Set MSB 0
 
I need to set the MSB of a decimal number to 0 which am taking as input. So i don't know how many bits are there in the binary representation of the number. Ho...
[15 replies] Last: #include <type_traits> #include <limits> #include <bitset> namespace... (by JLBorges)
DLL to be called with Unicode strings instead of ASCII (1,2)
 
Hi. I am using the following DLL in a program that uses the ASCII format for strings : #include <windows.h> #include <string> using namespace std; ...
[28 replies] Last: Hi. Now the DLL works and provides the expected results. Thanks to a... (by richardv)
Program crashes at substr (positions are in range, using string)
 
Hi, could someone tell me why this program crashes every time when it goes to substr()? The crashing part is at line 70, it is really pissing me off. I've prin...
[5 replies] Last: A few problem areas. Mixing of formatted input cin >> with getline(... (by Chervil)
assignment of template descendant
 
hi everyone, i'd like to implement a "node tree": a node can have multiple children, but only 1 (or no) parent. besides the node hierarchy, each node has additi...
[6 replies] Last: i solved it, i just removed the template T as base class and added a p... (by John87Connor)
picking index of unspecified array size
 
Hi all, my question is how do I pick a specific number from an array which has an unspecified size efficiently? I'm sure I could traverse the array from the beg...
[4 replies] Last: std::cout << "input a number for array size:"; std::cin >> size; ar... (by keskiverto)
by pivot
Reading C++ Source
 
Recently, a cloned Unreal Engine repo locally to my PC. There are tons of file in the repo, and high quality codes. It's a great pleasure to read professionally...
[9 replies] Last: try https://scitools.com/trial-download-3/ I can't test this, can't i... (by jonnin)
regex to find each 5-letter word in a sentence
 
I am using the following data string and regexes to find each 5-letter word in a sentence, but I get incorrect results as indicated: string sentence =...
[4 replies] Last: gunner's solution works perfectly. \\b in a regex specifies a word bo... (by SSteven)
Finding 2 words in array
 
I have 1 dimensional two arrays each consisting of names of cities and number of items delivered to that particular city. Now I need to find a two letter word ...
[6 replies] Last: As already pointed out by Ganado if your strings have spaces you need ... (by jlb)
If else statement using single cout
 
Write a program to decide the class of family depending on its yearly income using if else with single cout The various classes are : < Rs 50000 very poor 50K...
[10 replies] Last: There are 10 sorts of people: those who like PODs and those who like s... (by Enoizat)
"Delete" statement not working?
 
Hi there, Im recently writing a new code where a function returns a pointer, say *myp. Thing is inside this function, the pointer myp points towards an array of...
[7 replies] Last: delete doesn't change the value of the pointer (which is an address)... (by zaratustra)
regex - Finding each vowel in a sentence
 
I am trying to write a program that uses the regex_search() function to find _each_ vowel in a sentence. The regex_search() function call is as follows: ...
[2 replies] Last: couple of additions that you may wish to consider: (a) std::regex_con... (by gunnerfunner)
regex_search() for digits not working
 
I have written a small program (based on an example in Josuttis' book) to search for an occurrence of digits in a string: /* The following code example is...
[2 replies] Last: Another option is: regex("(\\d+)") data: Hello this is... (by Thomas1965)
by bcass
GPA Struct
 
So I can't get my program to run correctly: #include<iostream> #include<string> using namespace std; struct student { int credit ; char grade ...
[4 replies] Last: OMG that worked thank you soo much !! (by bcass)
Function returning unexpected value
 
I have a function that should check at array of letters and return the number location of that letter in the array. char CHARSET = { 'A', 'B', 'C', 'D', 'E'...
[5 replies] Last: You could make your code work, but it’s prone to errors. For example... (by Enoizat)
by tario
error: invalid use of non-static member function
 
I keep getting the compile error: vclPCG.C: In member function ‘virtual Foam::solverPerformance Foam::vclPCG::solve(Foam::scalarField&, const scalarField&,...
[1 reply] : ¿is that openFoam? ¿what part is your code? I need to see more cont... (by ne555)
August 2017 Pages: 1234... 9
  Archived months: [jul2017] [sep2017]

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