Posts by sbrubes • 958 points
38 posts
-
0
votes1
answer38
viewsA: Function returning Nan
Two errors: ḍ length' is spelled incorrectly (attributed to the ḍtam'), and a non-numerical value in the vector ¡numeros' (where it contains two commas). Should stay: var numeros =…
-
1
votes1
answer52
viewsA: List does not print in C
I won’t comment on the other errors in your code (if any) as I haven’t tested it. So I focus here specifically on the problem reported: my list doesn’t want to print First you are recreating the…
-
2
votes2
answers37
viewsA: Redefining how a function operates? C
TPonteiroFuncao is a typedef, ie, sets a name/nickname for a type, in your case a function/pointer type for function. A type definition for function is marked by its signature, which is composed of…
-
2
votes2
answers105
viewsA: Trying to understand c/c++ pointers
Because when you does not pass by a pointer or reference, passes as a copy. That is, changes a new object created in a new address. With this example, it is easier to illustrate: #include…
-
0
votes1
answer139
viewsA: How to read all keys from a section of a . ini file? C++
The same thing from previous answer but playing in a Std::vector: std::vector<std::string> chaves; for(const char *resultado = lista; strlen(resultado); resultado += strlen(resultado) + 1)…
-
0
votes1
answer38
viewsA: C code does not show full list
C iterations start at 0, so the for stays: for(numero = 0; numero < 5; numero++) In: printf("%s",alunos[numero].n_matricula); is printf("%d",alunos[numero].n_matricula); To mix scanf and gets you…
-
0
votes1
answer64
viewsA: Arq.readlines python / Tkinter loop
With Ast.literal_eval: from ast import literal_eval with open("relatorio.txt") as arquivo: relattxt = [literal_eval(linha) for linha in arquivo]…
-
1
votes1
answer116
viewsA: How do you make an array of Labels in C/C++?
My previous answer was wrong, and so I eliminated it, even though other responses supported it. 1 2 3 Like you said, is to say what you don’t know, but as you said there was support for such,…
-
0
votes2
answers162
viewsA: Limit time to Cin input
In short, you would need an asynchronous reading of the input with std::cin, what is not possible. What I believe is the best way is for you to lean on library C conium. h, specific for MS-DOS…
-
1
votes1
answer118
viewsA: compare Array with another Array com for in Java
To iterate all, you must remove the internal loop (j), and thus, make your "comparison in arrays", as you ask: for(int i = 0;i < perguntas.length; i++) { if…
-
0
votes3
answers2356
viewsA: Access data from a JSON structure
Thus: import json json_str = """[ { "teste":[ { "dados":"teste", "uno":[ { "um":"Teste", "cores":[ { "preto":"Preto", "branco":"Branco" } ] } ] } ] } ]""" json_list = json.loads(json_str)…
-
2
votes1
answer35
viewsA: goto unsafe variable value
The scope in which you are declaring int numero;(comeco), is different from the scope in which it uses numero (fim). So you will need to declare it in a scope above: #include <iostream> using…
-
2
votes1
answer421
viewsA: Python - How to get the output of running a . py file to a . txt
First, self.proc.stdout.read(), will block your call until the program closes, and so you get nothing. To do what you want, you need two threads, as follows: def print_lines(inp): line =…
-
1
votes1
answer47
viewsA: How to use RAII, Constructors and Exceptions
The most RAII for your second case, possibly is the use of smart pointers3, as std::unique_ptr and std::share_ptr, but it seems to me that you’re afraid to use Try’s body. How should you avoid heap…
-
1
votes1
answer55
viewsA: Loop a list of Getprivateprofilesection C++
You should receive in list, something like: "pedido1 = 3552\0pedido2 = 2208\0pedido3 = 2066\0\0" 1 2 for(const char *resultado=lista; strlen(resultado); resultado+=strlen(resultado)+1) os <<…
-
0
votes1
answer44
viewsA: What’s wrong with the code? He was supposed to check while, but when I type continue or cancel he keeps repeating!
The condition is wrong, must be: while (!produto.equalsIgnoreCase("Cancelar") && !produto.equalsIgnoreCase("Continuar"))
-
1
votes1
answer63
viewsA: Number of attributes in a Python class
The rule is common sense, and mainly, the good programming practices. To object orientation is a form of programming that enables developers to think about things like work in real life: objects. 2…
-
2
votes2
answers782
viewsA: How to delete git branches that don’t exist on the remote
In Windows Power Shell, in response: git checkout master; git remote update origin --prune; git branch -vv | Select-String -Pattern ": gone]" | % { $_.toString().Trim().Split(" ")[0]} | % {git…
-
3
votes2
answers84
viewsA: Error of memory allocation
First it must be understood what is the stack or stack: The stack is a contiguous portion of memory reserved to stack the necessary data while executing code blocks. Each need for allocation is a…
-
0
votes1
answer223
viewsA: The Object 'XXXX' is dependent on column 'XXXX'
The answer as follows is wrong: -- Desabilita constraints de todas as tabelas EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all' -- Reabilita constraints de todas as tabelas EXEC…
-
5
votes3
answers949
viewsA: Why does the User-Agent header always return "Mozilla /5.0" independent of the browser?
First you must understand the meaning user-agent, or the user’s agent, or whatever acts/interacts. In general, it is necessary to know what kind of functionality is compatible with that agent, to…
-
2
votes1
answer72
viewsA: How to use Pyopengl in pycharm
Check your Run and debug settings: run/debug Configurations (in English) See if the path to the interpreter (Python interpreter), is the same where you installed the packages or use in another tool.…
-
0
votes1
answer2576
viewsA: How to subtract hours from a date sequentially in SQL?
That depends on your SGBD, or commonly called, database. Considering a table as: CREATE TABLE TABELA ( SECTOR VARCHAR(15) NOT NULL, HORAS TIME NOT NULL, DATA TIMESTAMP NOT NULL ); Mysql SELECT *,…
-
0
votes4
answers4137
viewsA: Is there a "main()" function in Python?
Speaking of application entry point, Python does not define a function for this. The programs are interpreted from top to bottom, as is common in scripting languages. 3 Behold:…
-
4
votes2
answers2017
viewsA: Python - How to build a good function to check for internet?
There is not only one correct answer First you must understand what it means internet, in the concept of its application/program. Hence, implement applications to verify by the services (quality and…
python-3.xanswered sbrubes 958 -
6
votes1
answer1315
viewsA: How to delete all files from a directory
In accordance with reply in English: System.IO.DirectoryInfo di = new DirectoryInfo("YourPath"); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } foreach (DirectoryInfo dir in…
-
1
votes2
answers47
viewsA: Matrix as parameter passage in C
Arrays are indexed in 0, so the interactions stay: for(i=0; i<tam; i++) The index for the evidence (j), to iterate on them, always make comparison with the total evidence, no i: for(j=0; j<3;…
-
1
votes2
answers520
viewsA: What are gch files and how do they work?
File with extension.gchrefers to the precompiled header of GCC, and one way to generate them is by passing a header file, .h, as a source to the compiler. 3 Using it is transparent to the developer,…
-
0
votes1
answer521
viewsA: How to use the strcountc function in C
#include <stddef.h> size_t strcountc(const char * const str, char ch){ size_t count = 0; for(const char *cur_index = str; *cur_index; ++cur_index){ if (*cur_index == ch) ++count; } return…
-
3
votes2
answers258
viewsA: if statement - use of parentheses
The use of parentheses, in particular for ifandwhile, in Python, it is more a decision of software engineering and maintainability, this having no relation to the performance of execution. 3 Clean,…
-
3
votes1
answer58
viewsA: Build error
lista1.java:4: error: class Stack is public, should be declared in a file named Stack.java The Stack class is public, and must be declared in a file called Stack.java. 1 lista1.java:54: error:…
-
1
votes3
answers1053
viewsA: Problems in Try (Python)
I believe the structure you’re quoting might be something like: def acao(n): if n == 2: raise ValueError('n == 2') try: acao(1) acao(2) acao(3) except ValueError: pass Where the function acao…
-
2
votes2
answers848
viewsA: Problem with balance of parentheses, in Python
It is a problem known as parenthesis, and the most common solutions suggest stack, queue and disposal. 1 2 3 First let’s get to the problem in your code: elif simb == ')': if len(pilha) > 0:…
-
1
votes1
answer42
viewsA: Email and Password continue to appear even after creating an SSH key
Apparently you are not using SSH, but HTTPS for repository access. 1 To check your repository, run in the repository folder: $ git remote -v If the source URL (origin) begins in https://github.com/,…
-
1
votes2
answers945
viewsA: Remember Git user and password when commiting
As described in the session 7.4 Git Tools - Credential Storage of Git Book: If you use transportation SSH to connect to Git remote, is possible to have a key without a passphrase, which allows to…
-
0
votes2
answers4651
viewsA: From a list, return even numbers in python
for the return in a Lista2=[2,4,6] That is, in a list of ordered pairs, utilize filter for filter the pairs, and Sorted for order her. lista1 = [4, 3, 2, 5, 7, 6] lista2 = sorted(filter(lambda x: x…
-
0
votes2
answers56
viewsA: Collect name of file used
Interpreting your question as "Discovering the name of the current Python script". Thus, some solutions follow according to issue in English: The attribute __file__ in any file will give you the way…
python-3.xanswered sbrubes 958 -
1
votes1
answer152
viewsA: How to program C# on Linux using Glade?
First of all, two concepts must be clear: Glade is a GUI builder for GTK+. 1 GTK+ is a multiplatform Toolkit for creating graphical interfaces. 2 Basically Glade creates an XML file, which should be…