Skip to content

Tag: c++

How to get local codepage in linux?

In Windows, I can use GetAPC function to get the local codepage. But how should I do to get local codepage in Linux? Thanks. Answer Linux does not use code page identifiers. It has locale identifiers, but different processes can have different locales and a process may be using different locales in different …

Adding newline character to printf() changes code behaviour

For some reason, adding n to printf() changes the behaviour of below code. The code without n prints (null) whereas the code with n leads to Segmentation fault. Printf.c Printf.c – Output Printf_Newline.c Printf_Newline.c – Output I am curious to understand the reason behind this. Answer Both are …

OpenSSL will not release file handles

I am writing a service (in C for CentOS) that must make lots of outbound SSL connections to a third party REST API via SSL. OpenSSL is used to create establishment of the secure connections with the remote server. After initialization of the ssl_connection I register the returned file descriptor with our epol…

g++ can’t link curl lib files

I’m having some issues with getting g++ to link the curl lib files. I’m using Visual Studio 2017 with the linux dev plugin and Ubuntu Server 17.04. curl-config –libs gave an output of -Lcurl which I tried adding to the linker options in Project settings > Linker > Command Line > Add…

string to long, not giving me the correct answer

I am trying to convert number stored in the c string to long int. But I am not getting the expected output: Output : 821493369 gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) Can you please advise what am I doing wrong here? Thanks. Answer In addition to using long long, you can use exact width types from stdin…