Posts by Guilherme Bernal • 20,024 points
220 posts
-
6
votes2
answers790
viewsA: Linux-based c++ Qt program to run on Windows
There is an open source project called MXE, Minimalist/Mingw cross enviroment. It starts from the source code of several libraries and produces own versions for compilation for Windows, on Linux.…
-
6
votes1
answer401
viewsA: What does this Assembly code do?
This is Assembly x86 written in Intel syntax. There are many references on the internet to learn the basics, it won’t be hard to find. In a very practical way: mov X,[Y]: Write in X what is in the…
assemblyanswered Guilherme Bernal 20,024 -
1
votes1
answer73
viewsA: Makefile wxWidgets
Excerpt from your Makefile: Crypto: $(OBJ_FILES) # Faz a lincagem g++ -o $@ $^ $(LD_FLAGS) obj/%.o: src/%.cpp src/%.h # Compila arquivos individuais g++ $(CPP_FLAGS) $(WX_CXXFLAGS) $(WX_LIBS) -o $@…
-
1
votes1
answer492
viewsA: Undefined Reference error when trying to use a template class
Your code itself is correct, the problem lies in the organization of files and the way the compiler works, especially with functions and template classes. funcs.cpp: template <typename T> T…
-
2
votes2
answers847
viewsA: Nginx does not import phpmyadmin database: "413 Request Entity Too Large"
You must set the directive client_max_body_size for a higher value, different from the 1MB standard. The intention is to prevent customers from uploading too large since in most common cases it is…
-
0
votes1
answer45
viewsA: Possible to implement Keyevent in a class that inherits from Qwidget instead of Qframe
A QFrame is nothing more than a QWidget which is rendered with an extra edge. It does not add any other functionality that has anything to do with any event. That said, whatever you do and run in…
-
2
votes1
answer82
viewsA: Instead of maps, how to use a struct vector for the problem in C++?
What you can do to complete the reading is as follows: #include <string> #include <sstream> #include <ifstream> // ... ifstream file("Registro.txt"); float pontuacao; std::string…
c++answered Guilherme Bernal 20,024 -
1
votes1
answer522
viewsA: How can I generate a hexadecimal code from another sequence of numbers?
If you have a string with any number, for example: String str = "43956"; You must first convert this to an integer number, so: int num = Integer.valueOf(str).intValue(); Then you can convert that…
-
3
votes2
answers150
viewsA: Map method does not work as expected
As mentioned by @Roh Barboza, your #contatos is not returning a simple contact list. The real problem that needs to be fixed is not how you run the #map. The error is here: def add(*contato)…
rubyanswered Guilherme Bernal 20,024 -
2
votes1
answer361
viewsA: How to avoid buffer overflow in simple Assembly (nasm) application?
Your program is absolutely correct and the strange output you are seeing is in fact the expected output. Note: rafael@Gauss:~ $ ./entrada Digite um número: 12345ls O número digitado foi:…
-
10
votes2
answers517
viewsA: How does Std::move work?
C++ has two basic entities: values and types. It is not difficult to see that 3 is a value, which std::string is a guy, who decltype(itoa(sizeof(4))) is a guy and that double() is a value. The…
-
4
votes2
answers694
viewsA: How to round a float value in Firemonkey Mobile Delphi XE6?
Never never never never use a float to treat monetary values. They do not keep values accurately that one expects of money, it is well expected that after some calculations sum up a penny or two.…
-
6
votes2
answers2240
viewsA: How does C99 work in relation to C90 for declaring variables in the middle of the code?
Prior to C89 it was expected that the programmer would already define at the beginning of the function all the variables that he would use. In this case they were immediately allocated in the…
-
4
votes2
answers254
viewsA: Execution of Instructions
Usually processors do not execute an entire instruction in a single clock cycle. But at the same time they run one instruction per clock cycle. How is that possible? Pipeline! As you can see from…
-
1
votes2
answers80
viewsA: How to manually delegate an object to Ruby
The simplest way is to work with method_missing, thus: class SimpleDelegator < BasicObject def initialize(obj) @obj = obj end def method_missing(method, *args, &block)…
-
6
votes1
answer91
viewsQ: Code considered only at compile time can contain Undefined Behaviour?
When designing a function that adds up two values of any distinct classes, I can write the following in a generic way: template <typename T, typename U> decltype((*(T*)0) + (*(U*)0)) add(T t,…
c++asked Guilherme Bernal 20,024 -
3
votes1
answer103
viewsA: How to install Qt for MSVC without the Microsoft IDE?
Is not possible. Windows SDK used to come with the command-line compiler, separate from Visual Studio. But starting with version 8, it no longer comes with the compiler. The solution however is…
-
4
votes1
answer319
viewsA: How to make a simple Hello World using C conventions?
Every function must have its own stack frame, this is part of the function convention. So, how main is a function, you must start the stack frame with push ebp and mov ebp, esp and end with leave.…
-
9
votes2
answers125
viewsA: Give Alert after typing the word "pass"
Simply put, this is what you can do: var memoria = ""; window.onkeyup = function(e) { letra = String.fromCharCode(e.keyCode); // Capture a letra digitada memoria += letra; // Adicione no final da…
-
1
votes2
answers939
viewsA: Match jQuery function, how to get the cards
There is no function match jQuery library. You might want to use the function String.match javascript native. It works like this: "COMMANDO database -> run…
-
2
votes3
answers400
viewsA: Problems with regular expressions (friendly url)
^carrinho\/produto\/(.+)?$ Means capturing carrinho/produto/ optionally followed by anything to the end of the line. That’s the problem anything. By the rule, it may well be 9789/quantidade/5.…
-
1
votes2
answers120
viewsA: Reset variable
Variables serve to keep information. Maybe what you need is a function? int get_number() { return 5 + rand() % 5 + 1; } int main() { cout << get_number() << endl; cout <<…
-
3
votes1
answer560
viewsA: Conversion from Infix to Fixed Value
It’s a pretty simple mistake you missed. There’s nothing wrong with the code or the algorithm itself, it works. Error is in regular expressions. As well used in function operando, it is possible to…
javascriptanswered Guilherme Bernal 20,024 -
5
votes1
answer443
viewsA: How to plot graphs using Qcustomplot in the main thread?
Using Qcustomplot to plot: The class QCustomPlot inherits from QWidget and so always operates on the main thread. An example taken directly from documentation: // generate some data:…
qtanswered Guilherme Bernal 20,024 -
3
votes1
answer161
viewsA: Function that returns pointer gives crash when trying to return pointer to main program
There has been some confusion with the syntax, it does not do what it seems to do. Note: node* i; // Cria uma variável local do tipo node*. Esse ponteiro aponta para nada fread(&i, sizeof(node),…
-
4
votes2
answers194
viewsA: Segmentation fault: Linked lists in C
It may not be the cause of your problem, but it’s already a very serious problem: You have: char opt; scanf("%s", &opt); The scanf is reading a string of size boundless which will be put in the…
canswered Guilherme Bernal 20,024 -
30
votes3
answers1450
viewsQ: Remote control of an Android is technically possible?
Today I saw the following video: https://www.youtube.com/watch?v=9J7GpVQCfms Shows a bracelet that projects the screen of an Android phone paired on the user’s arm. This then can manipulate the cell…
-
3
votes2
answers3451
viewsA: Read a comma separated string
An error visible in the code is read from the description: fscanf(arquivo, "%s[^,]", eletro[i].descricao[50]); What you must pass to the fscanf is a pointer to store the read string to. But as an…
-
5
votes1
answer83
viewsA: Error copy file in C language
It is all a matter of correctly identar the code. Putting the spaces in the places due the error is immediately clear: #include <stdio.h> int main() { char str[100]; FILE *file =…
-
4
votes2
answers1488
viewsA: Difficulty with for loop in Ruby
If you really want to access multiple variables in a loop, the language allows it. You can use the dangerous function eval, which takes as argument a code in the format of a string and executes it.…
-
4
votes1
answer63
viewsA: Get an X-size from a Picturebox?
You can read the current width through the property Width, thus: pb->Size = System::Drawing::Size(pb->Size.Width, 110 + 9); But if you really want to just change the height value, I suggest…
-
2
votes2
answers4833
viewsA: How to receive a char pointer via keyboard in C/C++?
You can read a string directly from the standard console entry using the command scanf. Thus: #include <stdio.h> int main() { printf("Digite uma frase: "); char frase[300]; scanf("%s", frase);…
-
2
votes2
answers115
viewsA: Segmentation Fault in Structs C array
grafo = (Node*)malloc((numVertices) * sizeof(struct Node*)); Reading this code very carefully: Calculate the size of a pointer to struct and allocate a certain number of these pointers. I believe…
-
2
votes1
answer51
viewsA: Power ball in Ruby
You probably came from the javascript universe in which type loops for x in array iteram x varying between the indices of the array. Here in ruby the structure is: for <variável> in <algo…
rubyanswered Guilherme Bernal 20,024 -
1
votes1
answer64
viewsA: Specific element in an Assembly array in AVR
The goal is to calculate array+1. In the first moment the value 1 is born in the r30. I imagine some code before the register r31 because there is nothing there to do it. In sequence you must add…
assemblyanswered Guilherme Bernal 20,024 -
2
votes2
answers352
viewsA: Segmentation failure in malloc() function
I believe it to be merely an operator precedence error. You allocate memory for the variable *ptr. But when using inside the loop, you use *ptr[x]. This expression is interpreted as *(ptr[x]), which…
canswered Guilherme Bernal 20,024 -
16
votes3
answers651
viewsQ: Problem of stopping can be solved in practice?
The halting problem can be explained as: given a program and an input for it, it will complete its execution and return a response or will enter an infinite cycle? This has been proved undecidable…
computer-theoryasked Guilherme Bernal 20,024 -
3
votes2
answers2027
viewsA: Send a command to Terminal via C++
You can use the function system. However, I must warn you to be very careful with it. Firstly why this command will send the argument directly to the terminal, which will run according to the user’s…
-
7
votes3
answers1021
viewsA: Iterated inline functions
The specifier inline has two very different uses. The first is to tip the compiler that that function will probably perform better if it is replaced in the call. The second, and perhaps overlooked,…
c++answered Guilherme Bernal 20,024 -
3
votes1
answer368
viewsA: Save bi-dimensional array to EEPROM memory
The EEPROM has only two functions to read or write bytes. Then you must necessarily read/write your data byte by byte. You can wear something like that: void EEPROM_writeMany(unsigned addressOffset,…
-
2
votes2
answers723
viewsA: Xmlhttprequest Expect Response
In the MDN there are some examples of synchronous requests, the first of them: var request = new XMLHttpRequest(); request.open('GET', '/bar/foo.txt', false); // `false` makes the request…
-
5
votes1
answer1022
viewsA: How to use Github in Windows XP?
Instead of using the Github client, you can directly use git via the command line. Download and install from the site http://git-scm.com/. There even has a very complete manual in Portuguese on how…
-
4
votes1
answer131
viewsA: syntax error, Unexpected ',', expecting ')' - Rails 4
The problem: text_field_tag (:q, nil , { class: "form-control", height: "25", width: "25" } ) Simply put, you have the following: funcao (1, 2, 3) Notice the space before opening the parentheses.…
-
1
votes1
answer280
viewsA: C++ if select object
There’s no way you can do a single check of "Is there a button pressed?" and just based on that figure out which one it was. You inevitably need two checks, one for each button. You can do so: if…
-
10
votes4
answers793
viewsA: Simple Teaching of Pointers
The memory is like a large and spacious hotel. It has many fours, all numbered, and in each of these there may be someone. Having a room is like having a variable. It is yours and no one else can…
-
1
votes1
answer55
viewsA: Exporting currency formatting with Excelbuilderjs
Turn left to reach right. To obtain the format #.##0,00 should use the format #,##0.00 in the code. The reason? Hard to say. Maybe it is that all the file must be saved with American locale and…
-
2
votes1
answer55
viewsQ: Exporting currency formatting with Excelbuilderjs
I’m using the Excelbuilderjs to produce an Excel spreadsheet on demand and offer as a download to the customer. Ideally, this needs to be done on the client, not on the server, and the library works…
-
2
votes1
answer87
viewsA: Check if Sim Card is installed
A quick consultation in the documentation reveals the function TelephonyManager.getSimState(). Can be used like this: final TelephonyManager telephony =…
androidanswered Guilherme Bernal 20,024 -
4
votes1
answer77
viewsA: HTML5 2D game webgl?
The <canvas> define a sketch region of the screen. You can then get a context that will define how the drawing will be done. We currently have two contextual Apis, the "2d" and the "webgl".…
-
5
votes1
answer4123
viewsA: Width adjustment to take up space remaining to be occupied in a div
First, you must allow the two Divs to occupy the same line. To do so use the display: inline-block. Then you need to remove the space between the Divs. Note the following: <div…