Why is my HelloWorld function not declared in this scope?

You need to either declare or define the function before you can use it. Otherwise, it doesn’t know that HelloWorld() exists as a function. Add this before your main function: Alternatively, you can move the definition of HelloWorld() before your main():

Append an int to a std::string

The std::string::append() method expects its argument to be a NULL terminated string (char*). There are several approaches for producing a string containg an int: std::ostringstream#include <sstream> std::ostringstream s; s << “select logged from login where id = ” << ClientID; std::string query(s.str()); std::to_string (C++11)std::string query(“select logged from login where id = ” + std::to_string(ClientID)); boost::lexical_cast#include <boost/lexical_cast.hpp> std::string query(“select logged from login … Read more

Arduino sprintf float not formatting

Due to some performance reasons %f is not included in the Arduino’s implementation of sprintf(). A better option would be to use dtostrf() – you convert the floating point value to a C-style string, Method signature looks like: Use this method to convert it to a C-Style string and then use sprintf, eg: You can change the minimum width and … Read more

Program received signal SIGSEGV, Segmentation fault

If you are on Linux, try running valgrind. You just compile with -g (with gcc), and then run your program with valgrind in front: Unlike the GCC solutions, which tell you when the segfault occurs, valgrind usually tells you exactly when the first memory corruption occurs, so you can catch the problem much closer to its source. PS. It rhymes … Read more

How do I add the MinGW bin directory to my system path?

To change the path on Windows XP, follow these instructions, and then add the directory where you install MinGW plus bin. Example: if you install MinGW in C:\ then you have to add C:\mingw\bin to your path Just for completeness here are the steps shown on the link: From the desktop, right-click My Computer and click Properties. In the System Properties window, click on the Advanced tab. … Read more

How to find the size of an int[]?

Try this: Because this question is tagged C++, it is always recommended to use std::vector in C++ rather than using conventional C-style arrays. An array-type is implicitly converted into a pointer-type when you pass it to a function. Have a look at this. In order to correctly print the sizeof an array inside any function, pass the array by reference to that … Read more

libpng warning: iCCP: known incorrect sRGB profile

Libpng-1.6 is more stringent about checking ICC profiles than previous versions. You can ignore the warning. To get rid of it, remove the iCCP chunk from the PNG image. Some applications treat warnings as errors; if you are using such an application you do have to remove the chunk. You can do that with any … Read more

Returning an empty string : efficient way in c++

Gcc 7.1 -O3 these are all identical, godbolt.org/z/a-hc1d – jterm Apr 25 at 3:27 Original answer: Did some digging. Below is an example program and the relevant assembly: Code: Assembly: This was compiled with -std=c++11 -O2. You can see that there is quite a lot more work for the return “”; statement and comparably little for return std::string and return {}; (these … Read more

Socket API or library for C++?

Here I’m attempting to answer some of your specific, factual questions to which I have something to contribute. Yes, you can use any C socket library in C++. If it doesn’t work out-of-the-box because the linker reports an undefined reference for the library functions you want to use, then can fix it by editing the .h file(s) of the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)