Posts by Maniero • 444,682 points
6,921 posts
-
7
votes2
answers797
viewsA: Why can you pass a char vector to the scanf as the direct address or variable?
The answer is already in the question. If you’re using a vector you have an address, and that’s what the scanf() wait, an address where it should put the entered value. A string is a vector. If you…
-
1
votes1
answer113
views -
5
votes2
answers348
viewsA: Root with Bigdecimal
Unfortunately you don’t have a solution ready. If converting to another type is a valid option, then you have no reason to use BigDecimal. The conversion will cause loss of value, and worse, so that…
-
2
votes2
answers59
viewsA: What is the usage limit of . push_back()?
This is implementation dependent and can vary by architecture, compiler, version and even extra factors depending on usage, so you can’t work with a number. I believe that most implementations will…
-
1
votes1
answer737
views -
1
votes2
answers238
views -
4
votes2
answers441
viewsA: Should I cover private methods in unit testing?
Generally speaking, you shouldn’t. Private methods used properly are implementation details and the goal of unit testing is to test the public API rather than the detail. The private method is just…
-
4
votes2
answers772
viewsA: How to use a dynamically allocated vector returned from a function in C?
Probably the biggest problem is passing as pointer something that already a pointer. So it works: #include <stdio.h> #include <stdlib.h> int* uniao(int *v1, int n1, int *v2, int n2) {…
-
10
votes2
answers999
viewsA: Which is more efficient, perform multiple queries or use JOIN?
Depends on the database, depends on the data in the tables, depends on the table configuration, depends on other specific factors. It may be the same, it may be that the JOIN be faster because it is…
-
2
votes1
answer112
viewsA: Doubts regarding the PEP8
Not two spaces, two blank lines. PEP8 does not talk about the separation of imports, but I guess it only makes sense to separate all of them from the rest of the code, so it would look like this:…
-
2
votes1
answer157
viewsA: Comparison of elements of a vector with "strcmp()"
It makes no sense to compare two integers with strcmp() since this function compares strings. It would be something like that: void verifica_conta(int *ptr) { for (int i = 0; i < 1000; i++) if…
-
5
votes2
answers92
viewsA: How to make a function that takes two integer vectors and returns a boolean value?
Now understanding the question better, the code didn’t even compile and the variable has to initialize before using. But I have other observations. I think I wanted to use the && and used…
-
4
votes2
answers422
viewsA: What is the advantage of using one database for reading and another for writing?
Perks Higher scalability (non-performance) Greater reliability in infrastructure Detailing This is usually not quite how it is done. There is a server that receives the writings and eventually can…
-
5
votes2
answers138
viewsA: Tolist() returning read-only
In the first example you are using a anonymous type that has all its members immutable always, so you can not change the content, if you want to do this you have to create a class even, as you did…
-
2
votes2
answers371
viewsA: What’s the difference between initializing a variable in these constructs? And how do you set a constructor to default?
In this specific case nothing changes. I recommend the first only to leave uniform with the cases that need to do so. In cases of having members that need to be initialized and are classes there…
-
4
votes5
answers3132
viewsA: What is the difference between comparison operators on Oracle?
I only found information indicating that not all work on all platforms. There is no documentation of differences at all, so treat them as identical. Even if they may eventually perform differently,…
-
3
votes2
answers96
views -
5
votes2
answers554
viewsA: What are the applications of day-to-day arrays? (examples of their usability)
Well, actually there’s practically no application other than trivial demonstration that doesn’t use array extensively. Then all applications make use of array. Although in some cases the array not…
-
2
votes1
answer680
viewsA: Show specific error in ASP.NET MVC
Probably the mistake was that there was more than one <system.web>, can only have one, or the error setting was not within this section. It might be interesting to turn on debug mode as well.…
-
4
votes1
answer956
viewsA: Creating a conversion table from Fahrenheit to Celsius degrees
There are several errors, some perhaps because part of the code is missing. If you are going to calculate data with decimal part you need to use at least one float, cannot be a whole. If the…
-
4
votes3
answers951
viewsA: Table normalization for 2nd Normal Form
Normalization exists essentially to solve redundancies. See some redundancy there? Address None shown. Is it possible for the customer to have more than one address? Is it possible for more than one…
-
14
votes1
answer121
viewsA: Is it possible to change more than one record at a time?
Suffice it to say in the clause WHERE you wish to do in several, could use a OR to select several IDbut I think in this case it is more appropriate to use the IN(). UPDATE PESSOAS SET COR =…
-
3
votes1
answer73
views -
6
votes1
answer3377
viewsA: Why is the use of ';' mandatory in the WITH clause?
The problem is not with the WITH, is with the previous statement that needs to be closed. The compiler can’t always correctly identify the location and gives a misleading message, but doing so…
-
9
votes3
answers883
viewsA: How to create operators in Python?
Language does not provide this capability. It is possible to create a specific behavior for existing operators (see Math reply), but it would not allow creating the ++. The answer from jsbueno shows…
-
6
votes1
answer183
viewsA: Pass arguments to the property getter
Exists in C# yes. They are indexer properties. And so they serve precisely to have an indicator of what the content of a data collection is wanting to pick up. It is possible to have more than one…
-
5
votes2
answers122
viewsA: Is it correct in MVC to access data within the model?
In general everything that refers to the data should be done in the model, even if indirectly. Any data handling operations should be in the template. Then the method of entering that data should be…
-
10
votes3
answers3280
viewsA: How can I make an Rand() that always generates only 4 random numbers?
If you want 4 digits then you want 1000 to 9999, as it will generate 0, add 1000 to ensure the minimum 1000 and as it is already adding thousand establish the limit at 9000. $presenca = rand() %…
-
10
votes1
answer257
viewsA: What are extended functions?
I assume you’re talking about Extension Functions or extension functions. They are used to extend functionality in an existing type. You write them as normal functions and it works like a function…
-
6
votes1
answer102
viewsA: How does Visual Studio’s Edit and Continue work?
I don’t have information authoritative and I think it largely depends on the specific implementation that can change as needed. In C# and VB.NET it is more or less easy the real code that is…
-
2
votes3
answers40
viewsA: System.Nullreferenceexception in an attribute of type Stringbuilder
Property object needs to be initialized: public StringBuilder listNewsletter { get; set; } = new StringBuilder(); If you use an older version of C# you need to do this in a constructor, basic…
-
10
votes2
answers293
views -
6
votes1
answer1727
viewsA: What is the difference between Type-safe and Null-safe?
Type-safe is a feature that an object is always of the expected type and the compiler can determine whether an operation can be done on it. There will be no indefinite behavior if it fails, there…
-
22
votes2
answers539
viewsA: How does antivirus scan my program?
I decided to answer because it seems to still have doubts regarding Renan’s response. Make it clear that antivirus do not need and do not care about the source code of the application. There are…
-
2
votes1
answer103
viewsA: Method override of an interface
It cannot because they are completely different methods. It is only the same method if the signing is exactly the same and can only overwrite the same method.
-
7
votes1
answer362
viewsA: What is the best validation strategy before data persists?
That’s basically it. Of course it doesn’t necessarily have to be a method for each validation, it can be a method that does it all. This is a question of project organization. Each project may…
-
1
votes2
answers200
viewsA: How to convert text into file to number with decimals?
Assume that the format is always this and will always be correct can do: using static System.Console; using static System.Convert; public class Program { public static void Main() { var campo =…
-
4
votes3
answers540
viewsA: What kind of smart pointer to choose?
Complementing Anthony Accioly’s answer that already answers the question, note that the fact that the pointers are smart does not mean that it does not need to have some coordination of its use.…
-
4
votes1
answer277
viewsA: Knowing which class of daughter the parent class points to
The solution for this is equal to Java, if the function should add a Empregado then make the function receive this and not the general class. As for the other positions. addEmpregado(Empregado* p) {…
-
10
votes4
answers236
viewsA: Comparison syntax referring to the same variable
It is right in the challenge. It could exist, not with this syntax that is weird and maybe creates ambiguity, but another could. Math is like that In fact mathematics itself has a chain of…
-
9
votes4
answers229
viewsA: Is overloading methods less performatic?
The overload itself does not affect performance because they are methods like any other, they have nothing special but the fact that there is the same name, but all this is decided at compilation…
-
3
votes2
answers287
viewsA: Int, unsigned and Signed modifiers in C language
If you want to accept only positive have to filter properly (if (t1 >= 0)). The guy unsigned int indicates only that it will be a number without signal, does not prohibit entering a negative…
-
16
votes4
answers4874
viewsA: Is there a programming language in Portuguese? If so, what are they applied to?
No real use. There’s this Portugol who made some interpreters (Portugol IDE, Visualg, Portugol Studio), but it’s just for learning. It has a functional version called Potigol. Has a language Muti…
-
4
votes1
answer89
viewsA: Recover accents of a string with PHP
Essentially there is no way. I would, but the solution is so complex that it doesn’t pay. There would have to be other mechanisms to solve this, keep the accents, have a code, have a table with and…
-
9
votes5
answers1023
viewsA: What is the difference between starting an empty variable and starting directly with the value?
The question in the way it was presented does not make sense because in both is starting with value. The first example starts with a string whose value is no character and then changes to a string…
-
7
votes2
answers334
viewsA: Is "inheritance" table a bad practice in this case?
I can’t say you’re wrong, but I don’t like that kind of separation in most cases. I think it is valid if the register is too large and the parts are usually accessed independently most of the time.…
-
18
votes4
answers359
viewsA: Output a C code with pointers
The asterisk is the dereference operator, that is, it takes the value that is in that address. It can only be used on pointers to give correct results. *p is to get the value of the address of p,…
-
5
votes2
answers452
viewsA: String comparison in C
There are some errors in the code including syntax. Solving these problems and organizing a little the code what you need to know is the use of the function strcpy() to transfer the contents of…
-
4
votes1
answer161
viewsA: What are other pass applications?
It’s just that, of course you can use it in several places, not just one if. An interesting case is when you want to create an abstract method, ie without implementation in that type, probably to be…
-
3
votes1
answer132
viewsA: What is the difference between *variable and *variable-'0'?
This is the same thing as doing *ch - 48 I put in the Github for future reference. already '0' is a character displaying text of a zero and equivalent to code 48 in decimal of ascii table. He’s not…