Posts by Maniero • 444,682 points
6,921 posts
-
1
votes1
answer67
viewsA: Method with Generics in inherited type
This is not possible in Java. Quadrado and Retangulo inherit from Forma? Or does one inherit from the other? Well, if so, is a classic mistake. But let’s consider the first. public static <T…
-
2
votes3
answers2365
viewsA: How to receive C input data until no more input?
Without a context it is not possible to offer the best solution, considering that all items will be inserted and finalized with a ENTER and only when you have a ENTER without typing anything else is…
-
1
votes2
answers286
viewsA: Can you get the value of an autoincrement column before it is saved in the database?
Use something like this (depends on your code): INSERT INTO precoXestabelecimento (precoID, ...) VALUES ((SELECT last_insert_rowid()), ...); I put in the Github for future reference. The…
-
4
votes4
answers857
viewsA: Compare if variable is number within an if
First, a if that tests if something is the same and has a else if if it’s different, there’s no way there’s a third option, or it’s the same or it’s different, then the else would never be executed.…
-
17
votes1
answer1949
viewsQ: Whenever I am going to scan a string in C I must use "strlen()", right?
It is common to see in C execs that people need to analyze and/or manipulate the content of a string, then we need to make sure that it will not exceed its limit. It is very common to make a for…
-
20
votes1
answer1949
viewsA: Whenever I am going to scan a string in C I must use "strlen()", right?
The question linked has the definition of strlen(). This function counts how many characters a string has. If that’s all you want, then it can be used, it was made for it. But only use when that…
-
3
votes1
answer100
views -
4
votes2
answers238
viewsA: What happened to Unicode in Python 3?
According to the response in the OS of Martjin Pieters the guy Unicode was renamed to str, which is more intuitive, and the old str was renamed to bytes. It puts a code to handle when you don’t know…
-
10
votes4
answers3402
viewsA: How to detect the operating system with Python?
import os print(os.name) That’s usually what matters, indicating what you can and can’t use in your application. If you really want to show someone what the operating system is or if you want to do…
-
5
votes2
answers134
viewsA: When do I need to use a class that inherits from an Arraylist of a kind? I don’t understand what that’s for
Great, in general it does not have this benefit even. It may exist, but it is rare to find a case like this. Has a famous question in Eric Lippert’s OS that talks about it. It shows that the AP…
-
2
votes5
answers7439
viewsA: Exercise with odd pairs in C
Organizing the code helps to identify the problem. In the specific case it is having an integer pointer printed instead of an integer. If it were compiled as it should, it would not compile. and an…
-
13
votes4
answers8680
viewsA: What are the differences between HTTP 2 and HTTP 1.1?
While HTTP 1.x is considered a textual protocol, HTTP 2 is considered binary, difficult to read by a human, but making it easier for the computer. This is because now the packages are multiplexed in…
-
2
votes2
answers468
viewsA: What is the corresponding timestamp variable type (SQL Server) in C#?
The normal and seemingly most obvious would be to use the DateTime, After all, the goal of both, roughly speaking, is the same, is to point a point in time. Each with a different representation, but…
-
9
votes1
answer2240
viewsA: What is the purpose of the "assert()" function and when should we use it?
Definition It is a function of assertion. It exists in almost all languages. Some have more sophisticated and alternative mechanisms. Assertion - Proposition judged true Priberam Dictionary. So it’s…
-
1
votes1
answer3114
viewsA: How do one character variable receive another in a conditional structure in Visualg?
The assignment was reversed: algoritmo "melhor aluno" var Quantidade,cont,nota,maior : real nome,melhor_aluno : caractere inicio Escreval ("==============================") Escreval (" Escola Santa…
-
2
votes1
answer4995
viewsA: What is the difference of the structure "while" and repeat in Visualg?
The main thing is that the condition of enquanto is evaluated right on your entry, so can not even perform anything of the loop if the condition is already false, while (sorry the pun :) ), that the…
-
7
votes1
answer514
viewsA: Is there any project organization standard for C++?
The namespace of the C++ works the same way in C#. That is, they are only "surnames" for their members, nothing more than that. One of the advantages of this is that they can be composed. You can…
-
5
votes1
answer454
viewsA: Should I use abstract class or interface?
If you want to do it right, neither. At least with the names used. A class called Windows, which I already find strange, it doesn’t seem like I should inherit or implement a Conector. That seems…
-
4
votes2
answers80
viewsA: Parameters for external call
I consider it a scam. Not that it can’t be done, but prefer to do it in code. It has a question about it in the OS that can help. You have one more related there. If you insist: printf("system…
-
8
votes5
answers1574
viewsA: Why do "Alert", "confirm" and "prompt" lock the loading independent of the definition order?
I think the answers posted already respond well. Just to complement, as an alternative you can create a dialog that does not block. In general will use Webworkers or Promisses. What now has become…
-
4
votes1
answer236
viewsA: Is using the oid column in Postgresql as the primary key correct?
oid is a primary key. The question is whether to leave it as PK or use another one that stops it being used as PK. It’s not simple to nail this, but you can obviously do it. It has some conditions…
-
10
votes2
answers536
viewsA: External and internal memory sorting algorithms
In fact it can be said that they are the same for both external and internal use. It is likely that some algorithm is a little better in one case than other algorithms. I will not analyze one by one…
-
2
votes1
answer110
viewsA: Printing a vector... Differences between C++ and C... Where did I go wrong?
In the answer to your previous question I said it was not so simple to make this conversion. There will be a lot of different situation that will need proper treatment. The solution that seems…
-
2
votes2
answers163
views -
4
votes1
answer995
viewsA: Too Many Arguments to Function 'address* finds()'
Let’s take this function start: void apaga(struct endereco **primeiro, struct endereco **ultimo) { struct endereco *info; struct endereco *encontra(); // =============> declaração aqui char…
-
7
votes3
answers918
viewsA: Parallelism and Simultaneity
Parallelism and Simultaneity. Often simultaneity is called competition since the tasks compete with each other for an execution unit, each task can only perform for a handful of time. But some…
-
12
votes4
answers320
viewsA: What is .= in php?
It serves to concatenate strings. It adds new text to a text already exists in the variable. $texto .= "um texto aqui"; is the same as $texto = $texto . "um texto aqui". Another example: $texto =…
-
10
votes4
answers199
viewsA: Difference between syntax to declare a function
Javascript has some idiosyncrasies and I may have missed something, but under normal conditions there is no difference in use. Both will execute in the same way. One is anonymous and declared inline…
-
1
votes1
answer395
viewsA: Treat Inputmismatchexception calculator
Do you really need a calculator class? Okay. There are several ways to treat the exception, I will present one of them, where he understands that something typed wrong should disregard and enter…
-
11
votes2
answers7652
viewsA: What is User Agent Stylesheets?
This indicates that default style set in the browser has been used (or another form that is being used for render that element). It is only used if really no style has been used on it, even on other…
-
9
votes1
answer716
viewsA: In Ruby on Rails is the business rule on the model?
I decided to answer because there is no consensus on this. Which indicates that there are problems in the MVC standard. When something is really good, everyone agrees. Treating business rules on the…
-
2
votes2
answers1180
viewsA: Drawing of numbers with exception
You need to draw the number until you don’t get one that you don’t care about. There are other solutions, but for a simple cases so there is no need to complicate. Would that: #include…
-
6
votes2
answers339
viewsA: How to avoid very big win condition in old woman’s game?
If the problem is having a lot of if, can do with zero if: function chkVitoria() { return ((chkSrc('0') == chkSrc('1')) && (chkSrc('0') == chkSrc('2')) && chkSrc('0') !=…
-
4
votes2
answers223
viewsA: Is there a performance difference between Tuple and List?
Tuples are simpler because they are immutable and for other reasons. In the ONLY ONE ANSWER of Mark Harrison which already shows how the bytecode Python is mounted in each case and you can see that…
-
4
votes2
answers1007
viewsA: How do I display what’s on the list?
To me it’s an abuse to use the ToString() for this, this method was not created for this kind of thing. You should take the element and the class member, and you should do it by sweeping the list,…
-
3
votes1
answer664
viewsA: Access local variable outside an if
Declare it out of the if and attribute within: local variavelDoArquivo if true then variavelDoArquivo = 123 end print(variavelDoArquivo) I put in the Github for future reference. Read more about…
-
2
votes1
answer459
views -
1
votes1
answer82
views -
1
votes1
answer65
viewsA: Changing customer information via ID
The whole code seems strange to me and there seems to be problems of design in it. It may be a matter of style and taste, but I would do all the method SalvarDados() in just 2 lines. I won’t try to…
-
6
votes2
answers1472
viewsA: Database for mobile devices
Sqlite can take more than you think Your question is part of a false premise. First this is a value thought about 10, 15 years ago and was well, very conservative, and does not consider appropriate…
-
5
votes2
answers1182
viewsA: Using For in Python
Yes, using a data range is the idiomatic way of doing in Python and does not have the for you know in other languages. What you can do is use a while, is almost equal to for traditional. x = 0 while…
-
2
votes1
answer106
viewsA: Hide form by pressing key
You are creating a form name and hiding it, can not, have to hide the current: private void Form1_KeyDown(object sender, KeyEventArgs e) => if (e.KeyCode == Keys.F1) this.Hide(); I put in the…
-
2
votes2
answers9758
viewsA: Pass matrix as pointer
This whole code doesn’t make much sense and at various points it doesn’t do what you think it does. It can be simplified, organized and modernized like this, there it works: #include <stdio.h>…
-
3
votes1
answer512
viewsA: Program that read 3 numbers with repeating structure with scanner class!
There are several errors (which I fixed), but the biggest problem is that you are trying to calculate the average within the loop, you have to find the total and then calculate the average: import…
-
9
votes2
answers1732
viewsA: Why does if only work with the return of a method?
Look at this code: class Main { public static void main (String[] args) { int x = 10; boolean cond = x == 10; System.out.println(cond); if (cond) System.out.println("executou"); cond = metodo();…
-
7
votes1
answer289
views -
5
votes2
answers383
viewsA: About method chaining. Why are you giving nullPointerException?
This is because the variable cliente has not been initialized. The palliative solution must be something like this: Cliente cliente = new Cliente(); The ideal is that the class Cliente was done…
-
5
votes2
answers109
viewsA: Custom typing
PHP does not have cast for real. It has functions that convert values. Remember that PHP is dynamically typed, so the type of the variable does not matter and the cast serves to reconcile a value…
-
7
votes2
answers141
views -
6
votes2
answers661
viewsA: Execute code in Lua language
Can do: dofile("hello.lua") I put in the Github for future reference. Or you can exit the interpreter and run straight lua hello.lua…