Posts by Isac • 24,736 points
820 posts
-
3
votes1
answer15
viewsA: Problem compiling Math. h
If you get this error it is because the implementation of the Math library is not being linked in the process. To resolve add the -lm in the compilation instruction: gcc teste.c -o teste -lm When it…
-
1
votes3
answers40
viewsA: How to turn a 2D Array into 2D Pointer in C
The key detail is that double A[3][3] is not an array of arrays internally, but a continuous zone of memory accessed in a special way. For this reason when you will try to access within the function…
-
5
votes5
answers96
viewsA: Matrix with out-of-range index returning correct values
In C and C++ native two-dimensional arrays are stored as continuous zones of memory, as if a normal array were. In this sense, the following figure illustrates this: Above the array I placed the…
-
1
votes2
answers64
viewsA: bishop’s move on chess
Another Member has already answered the question when he was already here. Anyway I answer in the same that gets two ways to apply the same logic I mentioned. My example: #include <stdio.h>…
-
1
votes2
answers68
viewsA: How to hide class when clicking outside an input
You can also make this show or hide from the class resultado on the basis of <input> with pure Javascript only. For this you need to use events focusout, focusin and manipulate property…
-
4
votes1
answer56
viewsA: How to declare that a camp has the same kind of class?
Solution Change: next: Optional[Node[T]] To: next: Optional['Node[T]'] # agora como string Problem and motivation The problem is that at the point where the next the class is being built Node does…
-
1
votes1
answer53
viewsA: Read txt file names in C
The problem lies in your interpretation of strtok. What the function does is to navigate token to token ("word" to "word") over what has been passed. Each navigation is done to each call from…
-
1
votes1
answer49
viewsA: Trying to turn canvas code into pure Javascript for React
I’ll start by saying you have a lot of misconceptions, but let’s start at the very least so you can get the code running: this.interval = setInterval(this.updateGameArea, 20); That one this of…
-
3
votes2
answers76
viewsA: Problem in the scanf, infinite loop
The problem is that when you read an integer through the entry with scanf and could not read the whole, the characters you typed are in the input, ie in the stdin. This will cause the next reading…
-
5
votes5
answers145
viewsA: Check if a string is composed only of '0' and '1'
Just to add another alternative, it can also do with pure JS functions in a minimally direct way. You can transform into array with split, filter through 0’s and 1’s with filter and check if the…
-
0
votes1
answer45
viewsA: Perform music in the program in C 2
By the linked question and answer I see that you are using the mpg123, in the form of: mpg123 <arquivo_de_som> If you notice the help of this utility you will see that it has an option to run…
-
3
votes1
answer41
viewsA: Loop in a file being read in C
The problem is that you are doing several readings and in only one of them, in the while, is that it checks if it has reached the end of the file. It can solve the problem by swapping the various…
-
0
votes1
answer46
viewsA: How do you put a Tkinter Text into a variable like str?
It lacks parameters for the get who’s calling. If you look at the tutorials of the documentation itself notice the following: Retrieving the Text After users have made any changes and submitted the…
-
1
votes1
answer35
viewsA: Randomly generate values from a repeatless vector in C
There are several situations that are not right in this code: Every time you do perguntas[rand()%4] generates a random number and therefore the number that generates and shows to the person is not…
-
5
votes2
answers108
viewsA: Given an X number, check if there are 2 elements in a list that together result in X
Colleague @hkotsubo already explained the problem and showed solutions, and I take this opportunity to show another way to solve the problem that is also very efficient, since it only goes through…
-
3
votes2
answers107
viewsA: How to decrease the tab opened in Visual Code and show navigation arrow between tabs?
It is possible to set the size of tabs to one of two options: fit - Separator occupies the size needed for the name to be visible shrink - Separators are adjusted in size so that all are visible…
visual-studio-codeanswered Isac 24,736 -
0
votes2
answers69
viewsA: How to see if a string has integer numbers
To have a super robust solution will need complex logic, but to solve the cases indicated in the question does not need much. With 2 more variables and changing only in main can do: int main () {…
-
1
votes2
answers53
viewsA: PHP because $_SESSION[name] - without quotation marks - is accepted and does not give error in INSERT and when destroying Sessions gives error in unset($_SESSION[name]
I will be as direct as possible to the problem. If you have: $x = "nome"; And makes: $_SESSION[$x] = "Rui"; So it corresponds to do : $_SESSION["nome"] = "Rui"; Note that here the name came out with…
-
1
votes1
answer1308
viewsA: Intersection of vectors in C
The problem in the solution you have refers to logic and the "null" value. There is no null value for integer, and \0 is incorrect also because it is a char and only has application in strings. It…
-
2
votes1
answer36
viewsA: Remove DOM elements with javascript
The classic way to remove an element is by using the removeChild from the parent element, which applying in its code results in: imagem.parentNode.removeChild(imagem); Note that access to the parent…
-
3
votes1
answer311
viewsA: double free or corruption (out) - Using C++ matrices
As I indicated in comment the problem indicated: double free or corruption (Oct) It means you either made one free in duplicate, which is wrong, or there was corruption in the heap. In both cases…
-
1
votes2
answers102
viewsA: Uncaught Typeerror: Cannot read Property 'split' of Undefined - Javascript
There are several variants of this error spread over the internet, and always refer to the method executed, which in your case is the split. The message says: Cannot read Property 'split' of…
javascriptanswered Isac 24,736 -
2
votes2
answers355
viewsA: Would using underline in C# be good practice?
What I recommend to you is to use the name convention of the team or project in which you are inserted. This is more important than "debating which naming convention is best used". By doing this you…
-
0
votes1
answer485
viewsA: Registration using struct
Deletion is done by decreasing the size you are currently considering, in your case given by the variable cont, and pulling all elements from the removed one home back, thus leaving the last house…
-
0
votes1
answer41
viewsA: How do I write this formula in . formula?
The use of that formula in .formula implies adjusting the style to English, which means: Barter ; for , Change function names to English. Ex: SE passes to IF Escape all double quotes inside the…
-
2
votes1
answer1445
viewsA: Compile project with multiple files . c in Vscode - C language
The "C/C++ Compile Run" extension you are using only allows you to compile and run one file only, as indicated in own repository: Compile & Run single c/c++ files easly on vscode And so with…
-
3
votes2
answers118
viewsA: How do you make this code more readable for someone who doesn’t know anything about programming?
What you should do is: Make variable names clear and readable, in your case in Portuguese so that your code resembles pseudocode as closely as possible. Use functions on every bit of logic that…
-
1
votes2
answers88
viewsA: Delete dynamic input
You actually have several problems with your code, the first being the creation of repeated id’s. Note that you assign a id same as each button: btn_delete.id = "btn-delete"; That will make you have…
-
2
votes1
answer61
viewsA: Scan string in multiple of 3
There are several things that are not right and need to review and correct. C strings are delimited with double quotes and not single quotes. Single quotes are reserved for characters only. Example:…
-
2
votes1
answer94
viewsA: How to create a matrix with dynamic allocation and structs
Its allocation is not correct in several parts, and this refers specifically to the function inicializaMatriz. This one should look like this: Matriz* inicializaMatriz(int nlinhas, int ncolunas){…
-
6
votes4
answers985
viewsA: Compare string with array to return the most compatible item
I choose here to show another approach to the same problem, and taking advantage of almost all the code you already had. The difference is that it uses an auxiliary counting vector for each…
-
2
votes2
answers66
viewsA: How to count elements on the screen and when reaching a certain amount change position?
For what explained your goal is better to do by css as the other answer already showed. But for learning purposes, I show you how to do what you want with Javascript. The logic is to make a for on…
-
2
votes1
answer256
viewsA: Limit the number of columns in an HTML table by PHP
Getting columns by position If the order is the same coming from the database query just need to make a for specific within the reading of each table row. Adjusting to your code is something like:…
-
3
votes1
answer79
viewsA: Change another selection option when a selection is triggered, using jquery-Chosen
What you want to do only with pure JS and HTML is quite simple, but using the Chosen library complicates things a bit. To make the selection of an element in a <select> manifest on the page…
-
3
votes1
answer848
viewsA: Add an element that is not in the array
Let’s start with what’s not right. Here you got it wrong and used 1 instead of i: if(vet[1]==valor) { c++; } Further down did a for that is not useful: int cc=0; if(c==0) { for(i=0;i<10;i++) {…
-
1
votes1
answer75
viewsA: Char matrix reference error
The types you used in the function parameters are not right, and there are more things in that function that are also not right. At the end I think you need to review the pointer part in some…
-
3
votes3
answers993
viewsA: Remove "disabled" with Javascript
To remove the attribute disabled just use the method removeAttribute of Element. This one gets a string indicating the name of the attribute to be removed, and does not generate an error even if the…
-
4
votes3
answers92
viewsA: Counting letters in a string
Although not responding directly to your question I find interesting to mention that you can reach your goal in a very direct way using functions and structures already existing in python. All you…
python-3.xanswered Isac 24,736 -
3
votes1
answer48
viewsA: Concatenate strings in the parameters of a function?
Why not use literals template ? This simplifies it a lot, because not only is it multiline, but it doesn’t have to escape " or '. In addition you use interpolation with ${} rather than concatenate…
javascriptanswered Isac 24,736 -
1
votes1
answer50
viewsA: Valgrind problem and dynamic allocation in C++
Let me start by saying that you’ve made a lot of trouble using char * everywhere when std::string was much simpler, avoiding having to manage the memory of each string individually, as well as its…
-
5
votes2
answers107
viewsA: How does a function know how to take the elements of an array if they are not being passed to the function?
Whenever in doubt, see documentation, typically the MDN. The documentation specifies the method forEach as follows: Syntax: arr.forEach(callback(currentValue [, index [, array]])[, thisArg]); Note…
-
0
votes1
answer30
viewsA: Revert a standard input line in C
What prevents you from reading the two words that are written is the scanf that’s done as: %s[^\n] When it should be: %[^\n]s But there are several other details that are not right: You have to read…
-
5
votes2
answers99
viewsA: Require function with another associated function?
These parentheses mean what? These are call parentheses of a function: function func1(x){ //codigo } func1(val); //chamar a função func1 // ^---^---> parenteses de chamada de função Meaning when…
-
1
votes2
answers78
viewsA: Why does the program work despite the invasion of memory in the vector?
@Maniero has already explained the problem itself, but I want in my response to focus on its code and conclusion. You start by saying: Why the program works despite the invasion of memory in the…
-
1
votes2
answers42
viewsA: Stop counting for Jquery
Another way to do what you want is to count the amount of elements you have already written on the screen. Although being a little more extensive is more generic and will work even if you want to…
-
0
votes1
answer80
viewsA: Insertion at the end of the list resulting in 'Segmentation fault'
Let us begin precisely by if who mentioned: if(ref == nullptr) ref->prox = novoNo; If we imagine that the list is empty, and so ref has the value nullptr then ref->prox represents undefined…
-
1
votes1
answer182
viewsA: Insert an item in the chained list
The point here is that you have a pointer on main that passes to the function in the hope that the function changes that pointer, with a simple assignment but that does not work as you imagine. The…
-
2
votes2
answers79
viewsA: Read file without displaying space
You can also do what you want with a regular expression. It may be a little exaggerated for the example you have, but it’s always good to know more ways to get to the end result. All you need to do…
-
0
votes2
answers538
viewsA: Codeblocks compiles (linux operating system Mint) but does not show on screen
The interactive screen you speak of is the terminal, and you indicate that it should not be configured in your Codeblocks. To define which terminal to launch in Codeblocks you must go to the menu:…
-
2
votes1
answer109
viewsA: Operation Logica in C
Turns out when you do a reading with fgets for stdin, the enter you press is also stored as a \n inside the string. See how it appears running in debug and inserting the word aça: That is, in the…