Quantcast
Browsing all 40 articles
Browse latest View live

Answer by Zan Lynx for Do all functions in a c++ program's main function get...

An uncaught C++ exception will terminate the program. Often with a stack trace but that is up to the implementation.So no, in your example bar() will never be called.Update: In some situations the...

View Article


Answer by Zan Lynx for C++: expected ';' at end of member declaration

Here is how your code should look. clang-format fixed it up.#include <iostream>#include <string>using namespace std;class employee {protected: string name; string surname; int tel; int...

View Article


Answer by Zan Lynx for Memory leak in golang slices of slices

Every slice points to a backing array. The Go garbage collector does not look at the active slices. It only looks at the pointers that exist in allocated memory, which would be the entire array even if...

View Article

Answer by Zan Lynx for getline(file, text) exhibits strange behavior : stuck...

Obviously, your program is not running from the directory you think it is.Visual Studio is particularly bad about this, I find. You'll need to go into the Properties for the project and see where the...

View Article

Answer by Zan Lynx for Is it a necessary trade-off that using smart pointers...

Your static member function, or friend function, which is the factory should have no problem with calling protected constructors and returning a smart pointer. Generally plan to return a...

View Article


Answer by Zan Lynx for Freeing heap on exit in C automatically

First I should point out that doing this is kind of useless because as others have said the operating system is going to clean all of your program out of memory on exit.But anyway.Have some fun with...

View Article

Answer by Zan Lynx for Using vector::data() chaining with member function...

You returned a temporary copy of your vector. After the statement it is part of it is destroyed. If you wanted to keep it around you need to assign it to another vector.So, you made a pointer to a...

View Article

Answer by Zan Lynx for Does C have an equivalent to var?

Scripting languages which are written in C manage to implement this for their variables. However, it is quite complicated.C needs to know the size of things, so that it can place them into memory...

View Article


Answer by Zan Lynx for LINUX BASH SET ECHO

In the bash shell, set is used to control the numbered variables like $0, $1, etc. and shell option settings.For other shell variables you just set them. Like this:character=(a b c d e f g)echo...

View Article


Answer by Zan Lynx for Why this code gives run time error on mid calculation?

Because any return from main that is not 0 indicates a runtime error.

View Article

Answer by Zan Lynx for What does "!$@" mean in Perl?

It sort of looks like a cartoon dialogue curse word doesn't it?Take it one symbol at a time. The ! is boolean NOT, so if the following value is True it will become False, and vice versa.The $ starts a...

View Article

Answer by Zan Lynx for Is it possible to use epoll to write fifo/pipe data to...

I believe that the only way to solve your problem is to include a timer based polling loop where you attempt to open each FIFO once a second or so. Make that part of your select/poll/epoll loop. You...

View Article

Answer by Zan Lynx for why, I'm getting some strange garbage values?

Files are in bytes. Integers are made of either 4 (32-bit) or 8 (64-bit) bytes. They can also be in little-endian (Intel) or big-endian (PowerPC) byte order.In memory and in the disk file you wrote,...

View Article


Answer by Zan Lynx for Thread local storage processes

If you intend to write C++ and you do not have a need to use Win32 functions specifically, then you should use the C++11 thread_local. See https://en.cppreference.com/w/cpp/keyword/thread_localThis is...

View Article

Answer by Zan Lynx for C using fread to read an unknown amount of data

Depending on how clever you need to be with the number conversion... If you do not need to be especially clever and fast, you can read it a character at a time with getc(). So,- start with a variable...

View Article


Answer by Zan Lynx for Implicit function declarations in C

Because of historical reasons going back to the very first version of C, it passes whatever type the argument is. So it could be an int or a double or a char*. Without a prototype, the compiler will...

View Article

Take the address of a one-past-the-end array element via subscript: legal by...

I have seen it asserted several times now that the following code is not allowed by the C++ Standard:int array[5];int *array_begin = &array[0];int *array_end = &array[5];Is &array[5] legal...

View Article


How to use Linux hugetlbfs for shared memory maps of files?

I have a program which uses mmap() and shared memory to efficiently access a large database file. I would like to experiment with huge pages to see if it speeds things up.I thought that a quick and...

View Article

Is the compiler able to optimize try/catch into a simple goto?

It seems to me that if you have some C++ code like this:int f(){ try { if( do_it() != success ) { throw do_it_failure(); } } catch( const std::exception &e ) { show_error( e.what() ); }}The C++...

View Article

How to locate a thread's stack base from a core file?

I have a core dump that shows a thread dying from a SIGBUS signal while executing mov %r15d,0xa0(%rsp). That seems to tell me that it died because it ran out of thread stack.But how can I prove it? I...

View Article
Browsing all 40 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>