Skip to content
Advertisement

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 categories at once. Every C program starts

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 undefined behavior, so an answer could stop right here. But there’s at

In the kernel space, how does one get the physical addresses corresponding to a file on ext4-formatted disk

If you’re here: https://github.com/torvalds/linux/blob/master/fs/ext4/file.c#L360 You have access to these two structs inside the ext4_file_mmap function: I am changing the implementation of this function for dax mode so that the page tables get entirely filled out for the file the moment you call mmap (to see how much better performance not taking any pagefaults gives us). I have managed to get

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 epoll queue. I can connect and perform the

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 > Additional options. I also added the –cflags output to

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 stdint.h. For instance,

Advertisement