Posts by Fernando Silveira • 1,149 points
40 posts
-
0
votes1
answer90
viewsA: Operator overload = in c++
The code presented has some problems. Are they: The return of the allocation operator (operator=) should be, most of the time overwhelming, *this. I won’t go into the details of when this might be…
-
0
votes1
answer45
viewsA: How to insert data into a member vector of a struct?
What you are trying to do is initialize your structure with startup lists (initialization lists) but what you’re really doing is violating language rules. To initialize a structure that contains…
-
0
votes1
answer46
viewsA: Function parameter eeprom_write_block
The function eeprom_write_block() receives three parameters: the memory address from which the data will be copied, the memory address to which the data will be copied and the size of the data to be…
-
5
votes2
answers245
viewsA: I can’t push in GIT repose
At the time of initializing your repository you should instruct the git to create in shared mode and how it should be done. There are some sharing modes and I suspect that the standard (group) is…
-
1
votes1
answer58
viewsA: How to sort an array using three attributes?
Since you already asked how to add the second field previously in this question, I believe it is best to explain how the comparison of two fields or more works. This way you can include as many as…
-
0
votes1
answer51
viewsA: How to sort an array using two attributes?
To sort by two fields you must compare in this order: if the first field of an element is greater that of the other element; if the first field of an element is equal to that of the other element…
-
0
votes1
answer37
viewsA: Problems with arithmetic operators in C++
Respondent based on user comment user140828. The problem is that in the division of 30 by 100 you are using integers and the value ends up being truncated to zero. This is because integer type…
c++answered Fernando Silveira 1,149 -
1
votes1
answer146
viewsA: Reference not defined in compiling an executable for windows x86
For some reason Clang is not finding the symbols used to unwind the stack (unwinding stack), which is probably in a specific library. Because of this, if you add the flag -fno-exceptions the error…
-
1
votes1
answer1303
viewsA: Colors in cmd using Python?
I recommend using the module Colorama. Code example for Python 3: from colorama import Fore, Style print(f'{Fore.YELLOW}Entrando na configuracao{Style.RESET_ALL}') Code example for Python 2: from…
-
0
votes1
answer81
viewsA: use Fork on linux
After a fork() child and parent processes virtually no longer share the same memory area. To do this you must use some type of IPC communication. If all you want is to transfer two int son to father…
canswered Fernando Silveira 1,149 -
2
votes3
answers548
viewsA: Error using scanf("%[ n]") in sequence
This is because in the first two calls from scanf() you ask to read exclusively characters that are not line breaks. This implies the scanf() leave the line break character in the buffer of stdin…
-
1
votes1
answer176
viewsA: Traverse a vector by dividing the search into threads
The problem is not race condition but algorithm itself. You call the function contar() twice: once in the thread main and other in the first thread. Behold: contar((void *)chave); int rc; rc =…
-
1
votes1
answer356
viewsA: Shell script take out extension and search only by name
To remove the suffix .* of a variable just refer to it as ${variavel%%.*}. So you could fix your script and solve the problem: #ciclo for para aceitar multiplas entradas de ficheiros## for file in…
-
0
votes1
answer443
viewsA: Shell Script for copying renamed file structure to target
After the execution of rsync you could rotate the find to list all copied files and rename each file individually thus: # lista todos os arquivos copiados para $FULLPATHDST find "$FULLPATHDST" -type…
-
1
votes4
answers47253
viewsA: How to insert a line break inside the echo shell script?
You can do it that way too: echo $'Bom dia\nfulano' How this expansion is done by bash and not by command echo, the argument $'Bom dia\nfulano' works with any command, and not only with the echo or…
-
1
votes1
answer50
viewsA: Enter sudo password after running Spawn command
The sudo directly access the tty to which you are connected to receive the password, and so it is no use to write it in stdin. To work around this you can add a permission to the file sudoers to…
node.jsanswered Fernando Silveira 1,149 -
1
votes2
answers115
viewsA: Remove only strings from a list
To check if a variable is of type string you must use the function isinstance() and compare it with basestring in the case of Python 2.x and str for Python 3. Python example 2.7: >>>…
-
1
votes1
answer54
viewsA: getNextDataRange() from google Spreadsheatapp bug?
The problem is that Direction is not global and is within the object SpreadsheetApp. Follow the corrected line: var s5 =…
-
0
votes2
answers47
viewsA: Members of a structure as pointers
Your program must be failing because you are running a series of indefinite instructions. He is allocating memory in a few moments but is not treating it correctly. His code is with several errors.…
-
0
votes1
answer70
viewsA: Implicit recursion when assigning the return of a function to a variable?
The problem is that you are instantiating a list in function call Unirandi() (the list [-0.05338583452963963, 4.311503781033389]) and always passing the same instance to the function trial_search().…
-
0
votes1
answer44
viewsA: Problem with socket - recv - python
The problem is that its function realizando_conexao() returns the module socket instead of socket previously created: the variable s. Just change the return socket for return s.…
-
7
votes1
answer1150
viewsA: What is the difference between findByIdAndRemove and findByIdAndDelete in Mongoose?
TL;DR - The two do the same thing in different ways, but it is recommended to use the findByIdAndDelete(). The small difference is that the findByIdAndDelete() uses Mongodb’s native function…
-
0
votes1
answer105
viewsA: Joining of vectors in C
The problem is that the vector C is not being initialized. This means that the way it is implemented it is getting "random" values from memory and to solve this you need to first boot it. There are…
-
1
votes1
answer325
viewsA: How to merge the two applications that are in a separate Gitlab?
If I understand correctly, all you want to do is merge between two different branches of two different repositories. For this case we will call the branches "branch-a" and "branch-b", and the…
-
1
votes1
answer129
viewsA: Help to get struct values(Arduino,C++)
To access members of a struct just use the syntax variavel.membro. In the case of struct tm, the members are: tm_sec int seconds after the minute 0-61* tm_min int minutes after the hour 0-59 tm_hour…
-
0
votes1
answer8960
viewsA: GIT PUSH --SET-UPSTREAM ORIGIN MASTER ERROR
The warning that the command git push is sending signals that your tree is out of sync with the master branch Github. In this case you have two options: ignore the differences and overwrite the…
-
2
votes1
answer1360
viewsA: Call any function of another class of the same type
The problem is that every instance method requires an object. If it were specified as static function. Example: class MyPrint { public: static void StaticMyP(int a) { cout << a << endl;…
-
2
votes1
answer252
viewsA: Doubt about Python classes and methods
It seems very simple, you are almost there. Just fix an error in the method setarData(), as noted by Anderson... def setarData(self, d = 3, m = 8, a = 2017): self.dia = d self.mes = m self.ano = a…
-
2
votes2
answers152
viewsA: How to cut a suffix from an expression in bash (egrep/sed/etc)
Do not need to use any extra tool for this, because the bash is able to separate these words. Assign the filename to a variable and use the modifier %: nome_de_arquivo_completo="pasta.teste.git"…
-
2
votes1
answer1178
viewsA: Reading an XML file and printing specific fields using the Python language
First you need to set the date thresholds that your script has to work on. For this you should use the library datetime: from datetime import datetime begin = datetime(2017, 4, 10, 7, 50, 12) end =…
-
3
votes1
answer92
viewsA: Function with variable number of parameters via template
Yes, it is possible, with variadic template: template <typename T, typename... Args> T min_vt(T x) { return x; } template <typename T, typename... Args> T min_vt(T x, T y, Args... args)…
-
1
votes1
answer347
viewsA: How to save records of a mysql query in C++
First you need to check the return values properly, starting with mysql_init() and mysql_real_connect(), and abort the program if necessary. If this does not happen the result may be unexpected and…
-
0
votes1
answer47
viewsA: pstree in c++ program
What happens is that you are literally running the command pstree -s pidPai whereas the right one would be to replace the word "pidPai" by the number PID of the current process. Follows the…
-
1
votes1
answer188
viewsA: Validating extensions of regex files in c++
The problem is in Pattern chosen. If you want to filter only file extensions that end with h, hpp, hxx, H, HPP, HXX, c, cpp, cxx, C, CPP, CXX, aspx, php, py, java, rb, d, htm, html, HTM, HTML, mp3,…
-
1
votes1
answer55
viewsA: Function per parameter does not modify variables
The function p is rather modifying the received values. The problem in the presented case is that the values passed to the function are not being used and the pointer to this data is being lost,…
-
2
votes1
answer42
viewsA: Is it possible to include dynamic libraries in a static?
A static library is simply a collection of object files (.o) and is not connected (link). To check this you can run the command ar t <nome-da-biblioteca>.a, that will show you which files .o…
-
1
votes1
answer58
viewsA: C++: Instances of the same class
Not to be without record of reply, I answer here what has already been answered in the comments and made by the OP: create a container with pointer for all created objects, inserted at the time of…
-
2
votes1
answer873
viewsA: C++: what SIGSEGV means
You get a SIGSEGV, which is the sign 11, when your program references an invalid memory area. This implies unexpected interruption of your application, as noted above. If you pass a vector with only…
c++answered Fernando Silveira 1,149 -
1
votes1
answer278
viewsA: C++ Heterogeneous list
In that case you could eliminate the method get() and implement the operator<< in class any to play the content of val in the std::ostream. This way you don’t have to worry about templatized…
-
4
votes2
answers589
viewsA: Branch x Checkout x Merging automatico for master
This is normal and automatic. To avoid this kind of problem you should discard the changes made using the command: $ git reset --hard HEAD Run this command very carefully as it will discard all…