Skip to content
Advertisement

Tag: c++

What does “~[]” do?

I saw the following line of code here . I don’t understand, what does empty array script([]) do? Also, What is the purpose of ~[] in C? Answer The linked program seems to be logging its actions in some invented semi-formalized language. This logging “language” is not C. The string literal in your question is just a line in that

Error in malloc while trying to create a thread

Hi everyone i post only the core of the code which create probleam and which work with threads. As we can see foo function create new thread and reallocate memory to store the pthread_t. Then it try to create a new thread with pthread_create as NULL as attr and arg and as function pointer a pointer to foo2; Now the

What HW resource is mostly used when one does memcpy()?

This feels like a very newbie question, but I suddenly find myself clueless. I’m trying to profile a c application that does a lot of memory copies, and there is an option for me to reduce that number (requires some re-design). I’m trying to realize if it’s worth it, but I have no idea what resource it will affect, or

C Linux Pipe Reading Out-of-Order. Missing, and Duplicated Output

I am working on an application that needs to launch arbitrary child processes and read their output while they are running. It might be useful to think of it as a terminal emulator because it has to be able to run child processes many times throughout it’s lifetime and read back their output, and I want it to read back

c++ thread_local destructors with pthread destructors

I want to do some work after all C++ thread_local destructors called. This is platform specific – Android, so I have access to pthreads. The question is, when pthread_key_created destructors should be called, before or after C++ thread_local destructors? Or they can be interleaved? I tested On Linux Mint and pthread destructors called after C++ ‘s. Answer bionic/pthread_exit.cpp currently has

error while returning a char from a function in C [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 5 years ago. Improve this question hello, I am trying to pass and return a char in C but

Count maximum amout of parent processes in Linux

Here is my code. But teacher said it’s incorrect and something is wrong in if (pid == 0) condition body. Help me out please. Thank you! Answer fork() returns 0 for child process, >0 for parent process, and a negative value if there were errors. Your child process finishes immediately, so actually you never manage to spawn multiple processes at

RDMA – how does the ibv_post_send know the CQ?

I’m trying to learn RDMA. My question is, when doing ibv_post_send, I should get a completion event on a completion queue. But how does the ibv_post_send know to which completion queue? From what I see here, I could have created many. Answer Turns out when initiating a QP, it can be assigned to a send CQ and recv CQ in

Ending a Loop with EOF (without enter)

i am currently trying to end a while loop with something like this: } When i press CTRL+D on my Ubuntu, it ends the loop immediately. But on Windows i have to press CTRL+Z and then press ENTER to close the loop. Can i get rid of the ENTER on Windows? Answer The getchar behavior For linux the EOF char

Advertisement