Posts by Maniero • 444,682 points
6,921 posts
-
4
votes2
answers4833
viewsA: How to receive a char pointer via keyboard in C/C++?
Basically the same way as other types of data. I know you’ve learned in another question how to use the scanf(). There are two differences to read a whole you already know. scanf("%s", texto); The…
-
7
votes2
answers1419
views -
4
votes1
answer487
viewsA: How to use escape characters in a string in C#?
There is a problem there. You are trying to read a file that is essentially a binary as if it were text. This is not going to work. You need to use the class BinaryReader. Alternatively you can use…
-
2
votes1
answer1040
viewsA: Take array values returned from another class
It seems to me what you need to do is just sweep the array returned by the method that provides the list of states: try { ctx.get(FilialComplementoTO.FILIAL_COMPLEMENTO_KEY); //FilialComplementoTO…
-
2
votes3
answers906
viewsA: Can a primary key be used on a foreign key?
The Id, which is primary key, not only can it but is often used in Fks. If you want to know if the key can be composed, ie use more than one column as FK? Yes, can and is also common happen. qnt…
-
3
votes1
answer1393
views -
10
votes4
answers9003
viewsA: Invert a 3-digit number in C
If you want to understand how the algorithm of a function that does the reversal works: #include <stdio.h> #include <string.h> void reverse(char str[]) { int len = strlen(str) ; char…
-
5
votes1
answer3965
viewsA: Print vector disregarding repeated values
I will consider that the statement is exactly this. You are not doing what the statement asks. Note that it has two parts: "read a 50-element vector" (you’re doing much more than that on loop that…
-
6
votes2
answers83
views -
1
votes1
answer110
viewsA: And I have a question regarding select in sqlite bank in WP
AP solved it like this: var returnedCollection = App.db.Query(“select Email from Usuario”); for (int i = 0; i < returnedCollection.Count(); i++) {…
-
1
votes1
answer157
viewsA: Sax parser xml string Java Android
The AP was able to resolve according to response obtained in the OS. According to the definition SAX characters() can be called several times per element. Therefore, you must accumulate the text; If…
-
23
votes2
answers9074
viewsA: What is the difference between mock & stub?
I think the canonical reference on the subject is article by Martin Fowler. It shows the difference between 4 types of substitutes: Dummy These are objects used to fill a list of parameters when…
-
12
votes2
answers6315
viewsA: Heap of Java memory
First understand that we are talking about an abstract concept. It is a name only to facilitate our understanding. There is no component of hardware called heap located in memory. Not even a…
-
8
votes1
answer130
viewsA: Time is early in program . C
According to the documentation of this function return is made on time UTC (that in the background is the GMT time) and your computer is probably on Brasilia time which is three hours late. So…
-
12
votes1
answer5739
viewsA: Is it possible to generate a table script from an SQL command?
There are numerous ways to do it, some more up to standard, some less so, some simpler, some more specific but I think this is what you’re looking for: CREATE TABLE tabela_nova AS (SELECT * FROM…
-
4
votes2
answers768
viewsA: String of characters inside the scanf. Why and how does it work scanf("Day %d",&dia);?
There’s a lot of mistakes there. You’ve never seen it in books because of this. I think you miss at least two concepts in C. I won’t go into too many details. Pointers When you write &dia is the…
-
19
votes1
answer5221
viewsA: How does Design Pattern Observer work and how does it implement it?
Introducing When you like a magazine a lot you can go on the stand every day to see if the new issue has arrived or can make a subscription and receive at home. The observer pattern is exactly the…
-
141
votes4
answers35777
viewsA: Is HTML a programming language?
Not. This is a common doubt and error. HTML is a markup language as its name says. Hyper Text Markup Language. More broadly can be considered a data language. HTML only encapsulates data and…
-
5
votes1
answer3148
viewsA: Palindrome in C++
All that was left was the presentation of the result, I only added a line at the end of the character check. I commented on some improvements you can make to your code and made them in example shown…
-
35
votes2
answers33649
viewsA: What are SQL views? What are the advantages and disadvantages of using?
View is a result originated from a predefined query. Essentially it is a metadata that maps a query to another, so it can be considered as a virtual table. As its name says, it represents a vision…
-
15
votes2
answers19497
viewsA: How to get a snippet of a string?
You need to find where the first bar is and have the search done by the second starting from where the first one is. The . NET has the method Indexof() to locate a specific text in another. It would…
-
6
votes1
answer736
viewsA: What are the practical differences in C and C++ code portability?
Preprocessor This is how you solve the different parts for each platform. I don’t know how well you know the languages, but this is part of the preprocessor. These preprocessor directives help…
-
8
votes3
answers2035
viewsA: Interface or Abstract?
At first there was not much change. Interfaces are usually preferred when there are no status or implementations, which is your case. And this is the most important thing to note. That case does not…
-
5
votes3
answers88
viewsA: Problem receiving random integer values in array
I found the code very confusing and rewrote it to try to understand and it worked this way: package gerarOrganizar; import java.util.Random; public class GerarOrganizar { public static void…
-
8
votes1
answer206
viewsA: Sort table by contained value
You came close. But there are three mistakes. You are receiving the parameters improperly. This lambda that the table.sort wait receives only two parameters representing the two items to be…
-
9
votes2
answers295
viewsA: Why did a dynamic array work without the use of malloc()?
Your code does not allocate as you imagine, you are making a serious mistake. This code is far from doing what you think it is. You’re reserving memory for vet with an undetermined amount of…
-
47
votes2
answers25876
viewsA: What are the advantages and disadvantages of using indexes in databases?
Perks Improves performance consultation in many cases Data access is greatly reduced. The way the index is mounted allows searching a part of the data. The most common is the use of binary tree…
-
3
votes10
answers360
viewsA: Organization of CSS
There is no pattern. The two forms are a matter of taste. According to my perception the second is preferred by most because it looks cleaner, more readable. Some think the first one makes the code…
-
3
votes2
answers353
viewsA: How to increment variables
Basically what you need to do is use a array (java tutorial and class documentation). It is a variable that stores several values (a collection of values). Hence you access each individual value…
-
4
votes1
answer1494
viewsA: Pass variable value between Classes
This code is very confusing and larger than it should be. There seems to be also inconsistent use of static, in your case probably everything should be static in "part 2" and then you wouldn’t even…
-
3
votes1
answer196
viewsA: How do you get time for a millisecond?
As far as I know is not possible directly on Lua. The closest you could get is to use the os.clock() but the accuracy is less. However I can suggest some options: create a C function and use the…
-
18
votes2
answers3112
viewsA: What would Win32 be?
It can have several meanings. One of the most common, probably the most correct and which is very related to programming is that Win32 is a name API. Obviously is the Windows API (in English is much…
-
29
votes2
answers2228
viewsA: What is the difference between a lambda expression, a closure and a delegate?
I will not go into detail about the functioning since the doubt is more related to terminology. Introducing Each language can have its own definition. In general terms there is a more accepted…
-
10
votes1
answer3553
viewsA: How to use a Try catch inside another?
Each case is a case, but in general nesting of try is not the most appropriate. This probably indicates that you are capturing more exceptions than you should. Anyway, usually you just want to give…
-
10
votes1
answer1127
viewsA: How does the default Java constructor work?
The standard builder (default constructor) is the one the compiler creates for you. If you create it, it’s not the default. You can even simulate one equal to default: public Pessoa() { super(); }…
-
8
votes4
answers930
viewsA: Behavior of different ways of comparison in Java
As for the first question, you are correct. Second: Not necessarily. In Java the method Equals() always looking for (or at least should, depends on the actual implementation) find the most…
-
4
votes1
answer130
viewsA: Converting split expression to C++ to C#
From what I understand you want to do a split and take only the quotient. If this is it I see no reason to use the function div not even on C++. The same goes for C#. Actually C# doesn’t even have a…
-
8
votes3
answers152
viewsA: Viewdata error in controller
You can use a object initializer: var pessoa = new Pessoa { PessoaId = 1, Nome = "teste teste", twitter = "@teste" }; Or create a builder for your class: public class Pessoa { public Pessoa(int…
-
14
votes1
answer269
views -
22
votes1
answer2737
viewsA: What’s the difference between "throw" and "throw ex"?
The first and last examples in practice are identical if you are using only C# as a language in your application. Not specifying what to capture indicates you are capturing Exception. That is, any…
-
8
votes3
answers1909
viewsA: Error creating a Mysqli database via PHP on Wampserver
I created this and it worked. If you do the same and it doesn’t work, you have some problem with your installation or Mysql configuration. Just viewing the error provided by Mysql to be sure. But…
-
9
votes1
answer216
viewsA: Pointer variable is declared null, but member function performs normally
Why do you think you should make an exception? The pointer is needed to refer to a data structure, i.e., to a state, to data in memory. To access class behavior, that is, its methods. the pointer…
-
12
votes2
answers882
viewsA: Standard for typifying errors/exceptions?
There are the conditional exceptions (similar to the one you will get in C# 6) which is even more flexible than that, you can filter anything: try { myroutine(); // pode lançar umas das três…
-
21
votes3
answers17170
viewsQ: How to generate numerical sequences in SQL without creating tables?
Reading the question How to set to zero or null in an SQL query of a date range, for those whose value does not exist? I remembered a similar problem I have. Usually when I need those sequences that…
-
22
votes2
answers1168
viewsA: What defines a clean code?
There is no formal definition and I doubt that one day it will exist (it is symptomatic that there is no entry in Wikipedia). It is subjective. Whenever someone says what it is, be suspicious. But…
-
38
votes2
answers35446
viewsA: What is the complexity of an algorithm?
If you want more theoretical, more accurate information on how this works, the hugomg response is more appropriate. Have this answer as an alternative for those who have difficulty or lack patience…
-
6
votes1
answer946
viewsA: Array size
Lua has tables and no arrays. Lua tables have semantics of array and semantics of hash depending on how you place your elements, and this can be a little confusing. A array must have a sequential…
-
24
votes3
answers1011
viewsA: @Override is required in Java?
Yes, you should do this for the compiler to check and avoid overwriting the wrong method (maybe with the wrong signature), "hiding" the correct method and possibly calling the method in the wrong…
-
7
votes2
answers1879
viewsA: What are the differences between background and foreground threads?
The only difference is that the background threads do not determine the life of the execution environment, they do not hold an application running and depend on the foreground threads to continue…
-
31
votes3
answers2698
viewsA: What are covariance and countervariance?
Variance refers to how a type relates to its subtypes. I’ll use examples in C# which is what I know. First let’s go to an example of invariance: <!lang: IList<Animal> lista = new…