Posts by Diego da Silva Pinheiro • 214 points
17 posts
-
1
votes2
answers942
viewsA: How to make my function Len() return the size of Std::string, vector and const char *?
In addition to Maniero’s response, you can also use Std::is_same together with constexpr to validate specific type operations (C++17). This can help prevent code duplication if you happen to have…
-
1
votes3
answers734
viewsA: How to compare Arrays?
If your intention is merely to make an atomic comparison, you can use the method allMatch with simple comparison predicate. Boolean equality = (IntStream.range(0,lista1.size()) .allMatch(i ->…
-
0
votes1
answer193
viewsA: C++ Compiling/Including all files . cpp from the subdirectories of the /src folder
You can use wildcards for this. It would look something like this (not tested): src = $(wildcard *.cpp) \ $(wildcard src/*.cpp) \ $(wildcard src/pecas/*.cpp) obj = $(src:.cpp=.o) CXXFLAGS= -O2…
-
2
votes2
answers115
viewsA: What is the performance gain when I log into my variable?
In more practical terms, consider the simple example below: #include <stdio.h> int testecomregister() { register int x = 5; x = x + 2; x = x - 1; return x; } int testesemregister() { int x =…
canswered Diego da Silva Pinheiro 214 -
0
votes3
answers111
viewsA: How to differentiate input types?
On the issues to) and c), to ISO/IEC 9899:1999 in the section §6.4.4.4.10 defines this behavior: An integer Character Constant has type int. The value of an integer Character Constant containing a…
-
1
votes1
answer98
viewsA: Error: Exception in thread "main" java.lang.Nullpointerexception
The third element of cVetor in main does not exist in your code. So you pass a null element to find Starburst, generating an NPE when you try to do the other operations: cVetor[0] = c1; cVetor[1] =…
javaanswered Diego da Silva Pinheiro 214 -
1
votes2
answers272
viewsA: What are the benefits of using struct?
Answering your question in a more empirical way, we can turn to the utility objdump. Using your struct as an example and compiling with the "-g" flag to provide debug information, we obtain:…
-
0
votes3
answers412
viewsA: Lack of Java memory even though the computer has available memories
The JVM works with a memory segmentation mentality, where there are very specific subdivisions each aimed at a certain purpose. Heap Memory: Used to store the objects you allocate. Here you can…
-
0
votes1
answer288
viewsA: Matrix Binaria in C
It is pertinent to avoid these transformations by making module/division and resorting to displacement operators. Easily, you can extract the bits to solve your problem. Considering an integer whose…
-
1
votes1
answer48
viewsA: How do I get each row of my matrix to store a substring?
1) Set the amount of words you want to read to the matrix. 2) Create a char** and use malloc by passing as the parameter the size of intptr_t * the number of words you want to read 3) Create a…
canswered Diego da Silva Pinheiro 214 -
1
votes2
answers811
viewsA: Oracle JDK 8 is NOT installed
The most uncomplicated way to get Java (and other things related to the JVM ecosystem like Maven, Gradle, Springboot, Kotlin, Scala and etc) into a Linux distribution is by using the sdkman To…
-
2
votes1
answer193
viewsA: System call in c/c++
You can list all processes using command ps -eo pid, com (Returns the PID and process name) and query the memory information of each of them using /proc/$PID/statm (Returns the total memory of the…
canswered Diego da Silva Pinheiro 214 -
1
votes2
answers53
viewsA: Doubts about an algorithm problem
The algorithm will essentially separate the digits from the number you entered and display on the screen. Since the type is integer, then it will truncate the value of the expressions. Example: x =…
algorithmanswered Diego da Silva Pinheiro 214 -
0
votes3
answers1158
viewsA: Even-odd vector fill C
You need to modularize your problem in different functions to not lose the thread of the skein. To initialize the vector, just use Designated Initializers from C99 to fill the vectors with starting…
-
0
votes2
answers60
viewsA: Simply Chained List in C - Do not compile correctly
In remove_start(), the code section below is giving rise to an eternal loop for the subsequent function you are using (start() there at the end of main) nodo_aux = *pp_ini; nodo_aux =…
-
2
votes3
answers170
viewsA: How do I break a string into several substrings so I can work with each of them separately using the C language?
André Lins' answer is the most pertinent in terms of portability, but it is good to know that the function Strtok() is a considered function destructive because it modifies the first parameter…
canswered Diego da Silva Pinheiro 214 -
0
votes2
answers86
viewsA: Code return problem (second-degree equation)
When working with floating point in C, one should check the exceptions of the floating point environment (Floating Point Environment) by enabling the #pragma FENV_ACCESS In terms of your problem,…
canswered Diego da Silva Pinheiro 214