Posts by Rafael Bluhm • 1,736 points
29 posts
-
2
votes1
answer196
viewsA: Problem reading strings
The best solution is to always compile with Warnings, your code was full of useless variables. For best result in Sorting improve its function of comparing, this mine is also weak, will only compare…
-
4
votes3
answers173
viewsQ: Why is it not (easily) possible to hide private members?
Implementation concealment is one of the keys to good modern software engineering, and crucial in code reuse. Why then, in c++ is it not possible to hide the private data implementation? Since these…
-
5
votes3
answers18584
viewsA: How to use gets() in C++?
Avoid using gets. To store only one char in C++ use the standard input object (Cin). #include <iostream> int main() { char ch; std::cout << "Digite um caractere: "; std::cin >> ch;…
c++answered Rafael Bluhm 1,736 -
7
votes1
answer3306
viewsA: How to create a new library in C++
Two types of libraries will be explained: static and shared. Below is an example with the creation of both in the command line Linux. Static library: Used in the compilation main.cpp #include…
c++answered Rafael Bluhm 1,736 -
1
votes1
answer207
viewsQ: Is it correct to clean an internal malloc to a function with it?
Well given the following code is easy to do memory management: Code Example (in C): #include <stdio.h> #include <stdlib.h> int *criarValor(void){ int *valor = malloc(sizeof *valor);…
-
0
votes4
answers316
viewsA: "Pure" structs (no pointer) and C error handling
You must use pointers to return searches in the dynamic data structure. Even because it is made and assembled entirely with their help. Do void *busca(Arvore a, int valor); /* o poder do casting do…
-
1
votes2
answers3318
viewsA: C - How can I read data from a file (Considering that I use structures for it)
The easiest way is to create an array of structures, the hardest way would be to organize your own data structure. With array, simply to read and show I would: #include <stdio.h> typedef…
-
5
votes1
answer169
viewsQ: Special treatment for string, why?
I know arrays are static elements used when you have a predetermined size that you can use. But speaking of initialization, when the size is already set next to the array, I would like to know,…
-
3
votes2
answers1405
viewsA: Problem with Struct in C
Actually the biggest problem is - beyond gets - in want to "capture" the \n. With the example Yonathan is solved, but one cannot catch names with space. To capture names with spaces and not having…
-
3
votes3
answers252
viewsA: Arrays not started in C
No need to count the characters! Just know that the string ends in ' 0' and use such a condition in some loop. Maybe this is one of the reasons that the string in C ends in ' 0'. #include…
-
3
votes1
answer145
viewsQ: How can Qdialog lock a Qmainwindow?
I am implementing an experimental registration program, and I made a case where, if a person types nothing and tries to register this empty data, it opens a QDialog, receives the warning and does…
-
8
votes2
answers1558
viewsQ: Does the passage of objects in Java simulate passage by reference?
Everyone says that Java goes by value, including Objects. These are copied and cannot be reassigned to a new object within the method. The problem is that it is possible to change object values…
-
4
votes3
answers1952
viewsA: How to get a text from a Qlineedit in Qt?
With Qtcreator: Create a button and a lineEdit. Then I do an action for it: go to slot -> clicked. From there only create the command. Remembering that for those who use Qt Creator, you must use…
-
0
votes2
answers52
viewsA: Why is one of the cases incorrect?
In fact the limit really exceeds that of the usual integers. Just exchange them for longs #include <stdio.h> int main(void) { long a1, r, n, An, Sn; scanf("%ld %ld %ld",&a1, &r,…
canswered Rafael Bluhm 1,736 -
1
votes1
answer268
viewsQ: How to clear buffer in numeric menu when typing strings?
How to implement a menu that reads numeric values and indicates error (message on screen) when receiving characters and strings? The code below worked well for individual characters through the…
c++asked Rafael Bluhm 1,736 -
5
votes1
answer1575
viewsA: Recursive algorithm
Well, recursively the code is very small; remembering that the recursion must have a return value that stops it if that value is reached, otherwise the recursion will continue to do the substitution…
javaanswered Rafael Bluhm 1,736 -
1
votes1
answer84
viewsA: Error in a function check
I hope it’s what you’re looking for. The comments in the code try to explain what the program does. Any doubt post in the comments of the question and I will try to explain better. Exit: Matriz…
-
8
votes2
answers279
viewsA: Algorithm for (A+Bi) n
In fact its doubt becomes more a mathematical concept than a programming concept. To work with complex powers use the trigonometric form or the Euler form. There is no need to worry about the value…
-
5
votes2
answers912
viewsQ: How to free memory from an internal malloc to a function that returns a pointer?
How to release a malloc internal to a function that returns a pointer? In a simple way to try to exemplify my doubt, consider the following function f: int *f(int tam) { int *ptr = malloc(tam *…
-
16
votes2
answers17517
viewsQ: Real difference between point operator (.) and arrow operator (->) in C?
What is the real difference between the two operators. I know the operator (->) is used when the variable is a pointer, and that it is equivalent to (*ptr).membro. Well, if I declare a pointer of…
-
10
votes1
answer400
viewsQ: Is it good to use global variables for greater readability in the code?
I am implementing an exercise of the Deitel book, How to Program C, 6th edition, the Logo problem in chapter 6. It was an interesting question with legal logical problems etc. The only question of…
-
9
votes2
answers1393
viewsA: When should I choose whether or not to use a pointer when creating an object?
Using pointers, you create references, Example: #include <iostream> //Classe de exemplo class Objeto{ public: //Inicializa o valor como 0 por padrão na criação de objetos da classe Objeto(){…
-
8
votes1
answer2785
viewsQ: How to run Assembly inline in a code with variables in C?
From an example book, I was able to run the following Assembly (AT&T) code with gas, which returns a message with the processor name: .section .data output: .asciz "The processor Vendor ID is…
-
1
votes1
answer361
viewsQ: How to avoid buffer overflow in simple Assembly (nasm) application?
I’m trying to avoid writing off the application due to the excess buffer, but I don’t know how. The application is simple: it shows a message that asks the user to type something, then takes this…
-
0
votes4
answers2193
viewsA: How do I search a value within a String?
That’s what you want to do ? public class MinhaClasse { public static void main(String[] args){ String[][] table = {{"Cristiano","32","Italia"}, {"Marcos","45","Canada"}}; String minhaString =…
-
1
votes3
answers474
viewsA: Fscanf problem using code::Blocks and Opengl
You have to better explain what this point cloud (x, y, z) is and how you want to display such information. I’ll assume you intend to read 9 numbers in the file and show them. First option: Taking,…
-
1
votes1
answer216
viewsA: How to manipulate Widgets from the main window through a signal function ( C and GTK+)?
You can define your widgets in a structure and call them from within the function you created -- including organizing your application --, but calling by g_signal_connect(), and then connect a…
-
2
votes3
answers880
viewsA: Integer for String
Use the class function: QString::number();. Shown as follows: #include <QTextStream> #include <QString> QTextStream out(stdout); int main(){ int num = 10; QString s =…
-
34
votes2
answers1582
viewsA: How can -1 be greater than 4?
In fact sizeof returns a size_t type, which should be unsigned. The problem occurs in the unsigned binary Signed to binary conversion, if the programmer is not careful. The conversion of a binary…