Quantcast
Browsing all 223 articles
Browse latest View live

Comment by Peter - Reinstate Monica on Outputting Date and Time in C++ using...

@BjörnSundin Ah, of course. Actually, c++20 does it.

View Article


Comment by Peter - Reinstate Monica on In C language, do multiple implicit...

Reading the standard may not be the best or at least not the easiest way to learn a language. It covers a lot of edge cases that make a very simple language look complicated. Part of the reason is that...

View Article


Comment by Peter - Reinstate Monica on How can i make a C program exit when...

Typical terminals send the input even in standard mode when enter is pressed; none of this should be necessary unless you are behind a pipe.

View Article

Comment by Peter - Reinstate Monica on How can i make a C program exit when...

I think this is not what the OP asked for. Their main issue is that the program simply does not see any input after a regular (i.e., non-enter, non-break etc.) key press since the terminal is in line...

View Article

Comment by Peter - Reinstate Monica on Why int **m its not equal to int m[][]?

It is probably confusing to the OP because it is the exception to the C rule that declaration mimics usage, caused by the (repeated!) type conversion from array to pointer.

View Article


Comment by Peter - Reinstate Monica on Why int **m its not equal to int m[][]?

@Chris The question is entirely clear and certainly does not need debugging details. It is also not exactly the question linked in your comment: Sure, the issue underlying the confusion is array...

View Article

Answer by Peter - Reinstate Monica for What can a JIT compiler do that an AOT...

A JIT compiler can optimize based on run-time information which result in stricter border conditions which were not provable at compile time. Examples:It can see that a memory location is not aliased...

View Article

Comment by Peter - Reinstate Monica on How to write multiple static libraries...

Are you using or creating those libraries? Also, if you are using automake you should say that clearly, also as a tag. I'd use cmake if I could.

View Article


Comment by Peter - Reinstate Monica on Memory leak after button execution...

@prapin I should write a post "why using namespace std is mandatory for short snippets on SO" ;-)

View Article


Comment by Peter - Reinstate Monica on Can I put arbitrary files (not...

Why so dismissive? Tired? Frustrating work day? ;-) The constraint is in the CMake logic as far as it is known to me (files can only be added to a target which is logically wrong). The various IDEs in...

View Article

Comment by Peter - Reinstate Monica on Can I put arbitrary files (not...

@nega No, I want CMake to play my IDE nicely.

View Article

Comment by Peter - Reinstate Monica on Comparing two files in C - I don't get...

@WeatherVane Re "check size first": Interesting idea; fseek() (the standard way) may be pretty fast and likely pays for large files. In principle though, proper byte-by-byte comparison takes care of...

View Article

Comment by Peter - Reinstate Monica on Kotlin suspendCoroutine

@Joffrey The documentation could explicitly state: "There are no restrictions on the context from which resume() can be called (e.g. synchronous or asynchronously, from the same or a different thread...

View Article


Comment by Peter - Reinstate Monica on C# Destructor not working as expected

Even GC.Collect(2, GCCollectionMode.Forced, true, true); GC.WaitForPendingFinalizers(); did not reclaim objects defined in Main whose references had been nulled. Surprising. (dotnetfiddle.net/5laO72)

View Article

Comment by Peter - Reinstate Monica on Dotnet garbage collector not...

I am not exactly sure why that is; I would have assumed that the gc collects the objects. A modified version of your test has the same results, see dotnetfiddle.net/5teY0S. People always point out how...

View Article


Comment by Peter - Reinstate Monica on Wrote a program to print prime...

@chux-ReinstateMonica The most efficient optimization would do away with the if altogether (because jumps can be terrible on modern CPUs) and replace it with bit arithmetic, taking advantage of C's...

View Article

Comment by Peter - Reinstate Monica on Wrote a program to print prime...

I accepted your invitation to edit. Feel free to roll back or modify if unhappy.

View Article


Answer by Peter - Reinstate Monica for Wrote a program to print prime...

I wanted to see whether it is possible to compute the primes at compile time with constexpr and give virtually instantaneous answers at run time.I found a solution for "compile time loops" with some...

View Article

Comment by Peter - Reinstate Monica on Use scanf() to read \n in a loop?

There is no guarantee that the input is line buffered. It may come from a file, or the terminal settings may have changed.

View Article

Comment by Peter - Reinstate Monica on Use scanf() to read \n in a loop?

If you need line-by-line processing, use fgets() and parse the read line with sscanf() (if that counts).

View Article
Browsing all 223 articles
Browse latest View live


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