Posts by Ruan Montelo • 1,036 points
56 posts
-
1
votes1
answer40
viewsA: Question for in C (I’m still learning)
I made a small refactoring in your code. The biggest problem is the fact that it is dividing by zero at the end of the loop for: #include <stdio.h> int main() { int i = 0, n; printf("Digite um…
-
-1
votes1
answer85
viewsA: Function to check palindrome in C
First, the ideal is to understand the problem and then solve it with code. We know that a palindrome is a sequence of letters that, even reversed, continues with the same "meaning" (represents the…
canswered Ruan Montelo 1,036 -
2
votes1
answer42
viewsA: What kind of pointer is that?
The code: string &pn = animal; pn = "cabrito"; It’s not necessarily a pointer of the shape you normally know in C (I recommend you read on references in C++). That is a reference. Note that the…
-
-3
votes3
answers248
viewsA: Regex - take only the first occurrence of a word in Python?
The methods re.findall and re.search will return occurrences in a list and a Match Object, respectively: ['primeiro', 'primeiro'] <re.Match object; span=(3, 11), match='primeiro'> Match…
-
1
votes1
answer37
viewsA: Doubts in a C exercise
There are two problems: they are the access to the vector index vetorfat and the printf that will display more numbers than you want to be inside the second loop of repetition, responsible for only…
canswered Ruan Montelo 1,036 -
-1
votes1
answer37
viewsA: Number of elements in ndarray vector
I see the simplest way to filter a ndarray using the method where. From there, a tuple is returned containing an array of the items found in the first index, just check the property shape of the…
-
0
votes1
answer26
viewsA: What is the mainloop functionality in the Tkinter frame?
The method mainloop is used to "lock" running the current window using an Event loop of tkinter. This allows the tkinter can trigger responses to events in the current instance of the window that…
-
0
votes4
answers109
viewsA: Define the lowest and highest value among three numbers
If I understand correctly, your program needs to display the lowest and highest value entered by the user. I believe a simple approach would be to create a vector (double[]) with the three numbers…
-
2
votes3
answers70
viewsA: Because I would do Downcasting and Upcasting on C#
I will use the names of the classes you put in the question. We have the following classes: The base class Account: internal class Account { internal int AccountNumber { get; set; } } And two…
c#answered Ruan Montelo 1,036 -
1
votes1
answer30
viewsA: Could someone help me see where I’m wrong in my queue allocation
The problem occurs in two places, within its function criar_fila. The first is the fact that you are making the memory allocation sufficient for a certain amount of ints, but not for its structure…
canswered Ruan Montelo 1,036 -
3
votes2
answers192
viewsA: Sum of numbers in a range C++
To better understand how to solve the problem, I recommend reading more about recursiveness. The definition of recursion can be understood as a subroutine (method or function) that can call itself.…
-
1
votes1
answer42
viewsA: Destroy array in C++
Addressing the problem mentioned in the question: If I understand correctly, you need to delete the property rodas which is an array/pointer. The problem is that you are trying to remove the type…
-
0
votes1
answer28
viewsA: printf printing strange numbers
The problem is in the initial function call printf who does not own the \n at the end to skip the line before starting to display the values to the STDOUT: printf("\nSequência decrescente de %d até…
-
0
votes1
answer48
viewsA: error when registering a subject on a student’s list
Entering only on the merit of the problem you are facing to insert the values of disciplines for a student, you are trying to insert a value that depends on memory allocation without calling the…
-
1
votes1
answer29
viewsA: How to select all existing images and add an attribute to them
The code is apparently correct. You do not receive a return value in your browser console because of the behavior of the method setAttribute, that does not return any value. When no value is…
-
1
votes1
answer58
viewsA: Doubt if/Else (Javascript)
As mentioned by the @Yoyo user in the comment, its variable never changes value. So, it will never fall into a different condition. Since you need to redeem the value of the element input id pais,…
-
1
votes3
answers68
viewsA: Passage by reference in C
Entering only the merit of the error pointed out in the question, on the line where "flame" its function main: float CalculaHora(horas,minutos,segundos,&conversao); Note that you are not…
-
3
votes1
answer39
viewsA: Unknown terms pointer in C
For each case: p The format %p is used to make use of a formatting for displaying an address in memory. A pointer, being the variable p in this case, it already returns the memory address to which…
-
-1
votes1
answer42
viewsA: how to turn the list into a single string
You can use the method join, converting the items to string before and concatenating them from an empty string '': print(''.join(str(x) for x in previous)) With the input [1, 2, 3, 4, 5] the result…
pythonanswered Ruan Montelo 1,036 -
1
votes1
answer64
viewsA: How to invert a vector in C?
As mentioned by @Ricardopunctual in the comment, its function is void, then it really should not return any value. To return an array in C, it is necessary return a pointer to an allocated memory…
-
-1
votes2
answers42
viewsA: How to obtain the value of the variable outside the function?
whereas is just trying to access a variable outside the scope or is facing an asynchronous request problem: Access out of scope: If you are trying to access a variable that is outside the scope of…
-
0
votes1
answer39
viewsA: add to id +1 every time a new registration is made
I believe that only in order to read and increase the id, the problem lies in the fact that it is using the pointer to the file that was opened for bytes writing: Function cadastroCliente: FILE*…
canswered Ruan Montelo 1,036 -
0
votes1
answer54
viewsA: System.NullReferenceException. How to include fields from another table?
If I understand correctly, the problem is in the fact of having a Pessoa but not having a Aluno, since the key to Pedidos is connected to the Aluno. The only way I can see to make that call would be…
-
1
votes1
answer142
viewsA: Pycharm displays object class instead of the object itself
It is displayed directly on Google Colab because the expression is evaluated the way it was sent, the purpose is different for the environment. To make the Plots are displayed in your local code you…
-
0
votes2
answers38
viewsA: C# method with Procedure name and other parameters
If I understand the problem correctly, you need access to the name and parameters of a Stored Procedure in different places. I believe that the simplest solution would be to pass the variable…
c#answered Ruan Montelo 1,036 -
1
votes2
answers88
viewsA: How to print a decimal value with comma ex: 75.0 would be 7.5?
You can format the value of your variable MEDIA with string. Format: string med1 = string.Format("{0:0.0}", MEDIA); The result would be (based on the comment of the code that is in the question):…
-
0
votes2
answers88
viewsA: Arithmetic Burst C++
The warning C26451 is fired to indicate that the current operator is used in types that contain a greater amount of information, that is, there is a chance of data loss (accuracy of the numbers…
c++answered Ruan Montelo 1,036 -
0
votes2
answers106
viewsA: Hangman game in C
Entering only the merit of the program being aborting its execution, the problem is in the function printf, right after the "fill" of the variable letra: printf("\n\tLetra digitada: %s\n", erros);…
canswered Ruan Montelo 1,036 -
1
votes1
answer61
viewsA: Call function to allocate vector in C
You have correctly reserved the amount of memory you wanted, but are accessing the same memory region always in the functions cria_vetor and main: cria_vetor: (*conjunto)->x...…
-
0
votes1
answer22
viewsA: How do I print the line that is the smallest element of an array?
If I understand your question correctly, you want the row number of the entered value and not the matrix. For both forms, you can monitor the inserts (variable insercoes) and save the value of the…
c++answered Ruan Montelo 1,036 -
2
votes1
answer29
viewsA: jQuery - Trigger event only in the clicked element
The behavior that reports in the question is strange. Make sure you are looking for the right elements and if there is no other part of your code changing the desired behavior. That said, how do you…
jqueryanswered Ruan Montelo 1,036 -
1
votes1
answer29
viewsA: Take value that would go to the ID and put in another location and save in the database
If I understand correctly, you need to send the data that is in the fields mentioned in the request: data: { lat: POSICAO-LAT-AQUI, lng: POSICAO-LNG-AQUI } You can redeem the values you want after…
-
2
votes1
answer49
viewsA: Valgrind does not show which line the error occurred
To make the valgrind display the lines, you can first compile the program using the GCC with the flag -g which indicates for the compilation to be performed by providing debug information: gcc -g…
-
2
votes2
answers51
viewsA: "Argued tofrangeexception" error when performing database query to return quantity of records
As quoted by @Ricardopunctual in the question comment, the correct is check if there are items in your list before, to avoid exceptions of the type Argued tofrangeexception, when trying to access an…
-
0
votes3
answers50
viewsA: Does anyone have any idea why the if not be executed?
How does it mention that the variable letra4 is the first position of a string, I believe you want to compare chars. If this is the case, comparing the values directly should be sufficient (note…
-
0
votes1
answer27
viewsA: Problem with iteration in React
If I understand correctly, you need to filter the amount of elements to not render everything at once. The easiest way to do this would be to maintain the state of the indexes you want and use the…
-
1
votes2
answers133
viewsA: .Net Core 3.1 - How to use Enum to replace code string
If understood correctly, to compare the value of an Enum you can convert to int or string: (int)LANG.ENGLISH == 1 or LANG.ENGLISH.ToString() == "ENGLISH" If you want concatenate the values in the…
-
0
votes2
answers25
viewsA: How to hide something with jquery and css
Check if you are rescuing the correct element ID, if the element already exists on the page and put a . between element selection and method call hide. From this you can hide the element. The two…
-
0
votes1
answer50
viewsA: How to block a <a> tag with javascript
If I understand "disable" correctly, you can do the following: $("#proximonext").attr('href', 'javascript:void(0)'); And if the variable resposta has true as a value, replace the…
-
0
votes1
answer23
viewsA: Doubt beginner in javascript conditions
To find the input element with the desired value you should search for "input#country" and you’re looking for "input#pais". The "parents" ID element does not exist in the image code you put in the…
javascriptanswered Ruan Montelo 1,036 -
1
votes2
answers132
viewsA: Convert JSON to Array
If I understand correctly, you need to iterate through the keys and values of the original object by separating objects from each one: Object.keys(result).map((key) => { let objToReturn = {};…
-
1
votes1
answer49
viewsA: Math.Random is not random enough
As described: "...it is very possible that the result will be repeated or generate an approximate value of the previous one." There are explanations of why there is no way a computer can generate…
javascriptanswered Ruan Montelo 1,036 -
1
votes2
answers79
viewsA: Return JSON data in HTML
As mentioned by @Ricardopunctual in the comment, the problem most likely lies in the following code block: for (i = 0; i < data.length; i++) { htmlString += "<p>" + data.values[i].name +…
-
0
votes1
answer23
viewsA: Can using Try catch nested in php result in problems?
Error nesting structures "Try-catch", nay. The problem, as commented by @Ricardopunctual in the question is precisely needing more than a "Try-catch", not by syntax but by the structure of the code…
phpanswered Ruan Montelo 1,036 -
2
votes1
answer54
viewsA: How to compile C programs in Visual Studio 2019 without opening a project or solution?
Build Tools from Visual Studio 2019 You can use Visual Studio 2019 for editing only, if you prefer, and compile your codes using Build Tools from Visual Studio 2019. To learn how to install and use…
-
0
votes1
answer39
viewsA: Error converting an Enum
If I understand correctly, its enumerated value is receiving an implicit conversion to string, given that it is in a string interpolation and your column accepts only values int. That means at your…
-
0
votes2
answers38
viewsA: How and Where to Learn Sockets in C#
Microsoft’s documentation has greatly improved compared to how it was before and features extensive and very detailed content on C#, F# etc. including Sockets. The documentation provides several…
c#answered Ruan Montelo 1,036 -
2
votes1
answer38
viewsA: What is it for / Text / in Javascript
What you wrote was a regular expression, as exemplified by the @hkotsubo comment on the question. Anything between / / will be interpreted as a regular expression in Javascript, such as /[0-9]/g to…
javascriptanswered Ruan Montelo 1,036 -
0
votes2
answers123
viewsA: How to disable a branch on Github?
From experience (and as mentioned in the @hkotsubo comment), if you don’t want a local and/or remote branch, just delete the branch as there is no way disable, only prevent pushes are made for the…
-
1
votes1
answer66
viewsA: Discord bot python Choice color in embed
I have some experience building bots in Discord in other languages (C# and JS). For "Embed Messages," from my experience with the Discord platform, I believe that only one color can be passed: embed…
pythonanswered Ruan Montelo 1,036