c++

Add one more space after each new line

How would you do this? User input a word, after pressing [ENTER] I want to make a new line before each letter and add one more “space” before each letter. It kinda looks like stairs. Pls help.jpg Source: c++

pipe in c++ not working

Here is my code for executing pipe. One end is supposed to take in a string and the other end is supposed to return string reverse. Where am I going wrong?The program executes successfully but doesn’t give the reversed string output. #include “iostream” #include “stdio.h” #include “unistd.h” #include “stdlib.h” #include “sys/types.h” #include “string.h” using namespace std; int main() { int…
Read more

Bullseye Code Coverage for Qt

Hey I am facing an issue regarding bullseye code coverage with Qt. In my .pro file I am adding the following: QMAKE_CC = “”C:/Program Files (x86)/BullseyeCoverage/bin/cl”” QMAKE_CXX = $$QMAKE_CC QMAKE_LINK = “”C:/Program Files (x86)/BullseyeCoverage/bin/link”” Then Performing below commands: Build Run Run qmake Rebuild It is not generating test.cov(coverage) file anywhere in the system.I have added Bullseye path in the system…
Read more

C++ Access derived class member variable in virtual function

class Car { class BaseState { explicit BaseState(Car* vehicle) : mVehicle(vehicle) {} virtual void run() = 0; Car* mVehicle; } class State1 : public BaseState { explicit State1(Car* vehicle) : BaseState(vehicle) {} virtual void run() { // use data of Car … doSomething(); } virtual void doSomething() { } } class State2 : public BaseState { } … } class…
Read more

How to link libssh library in Makefile

I get following error, when i tried to compile my test program g++ main.cpp -o main /tmp/ccICBwKO.o: In function `main’: main.cpp:(.text+0xa): undefined reference to `ssh_new’ main.cpp:(.text+0x2d): undefined reference to `ssh_free’ collect2: error: ld returned 1 exit status make: *** [main] Error 1 In my make file i have: all: main $main: main.cpp g++ main.cpp -o main -lssh Thanks for help….
Read more

Gurobi cannot solve LP after Update -> Status Code 1

After I updated my Gurobi, I cannot solve my LP anymore. I tried to debug, but come not further than GRBEnv env = GRBEnv(); Trying to continue, it fails with Signal= SIGABRT. I am not sure if this has anything to do with my update of gurobi, since the general gurobi example still works fine (http://www.gurobi.com/documentation/6.0/quickstart_mac/cpp_interface.html). Moreover, when I let…
Read more

Get System Date Format String Win32

I need to get the system current date format string like (“dd-mm-yyyy” , “mm/dd/yyyy” ect. GetDateFormat() API returns the formatted string like “12-09-2015” but need string like “dd-mm-yyyy” C# solution string sysFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; But I need in Win32. Source: c++

Can a template be instantiated if there is nested type (not accessed) with a method that cannot be compiled?

I accidentally found that g++ (5.2.0) compiles the following template<typename T> struct A { int x; struct B { void foo() { x = 1; } }; }; even istantiating A and A::B, provided the member B::foo is not used. You reasonably get instead a compile error for x being a non-static member of A even by just compiling the…
Read more

what’s the difference between following code, why one works and the other doesn’t?

i wanna define a function whose behavior depends on whether its parameter is pod type, i do this in two ways: first template <typename T, typename = typename std::enable_if<std::is_pod<T>::value>::type> void f(const T&) { //… } template <typename T, typename = typename std::enable_if<!std::is_pod<T>::value>::type>> void f(const T&) { //… } second template <typename T> typename std::enable_if<std::is_pod<T>::value>::type f(const T&) { //… } template…
Read more