Posts by Vinicius Fernandes • 1,727 points
61 posts
-
0
votes2
answers55
viewsA: Make an If in c++ by limiting the answers
To restrict an input to a specific value, you need to read the input within a loop. If the input matches the range you are waiting for, you break the loop, otherwise the loop continues. int dia = 0;…
-
0
votes3
answers67
viewsA: How to make the user choose the amount of elements in an ARRAY?
Ask the user the length of the matrix: int comprimento = 0; printf("Insira o comprimento da matriz: "); scanf("%d", &comprimento); Declare the matrix with the defined length: int…
canswered Vinicius Fernandes 1,727 -
1
votes1
answer32
viewsA: Problem with simple circular list in C
The first error is this malloc at the beginning that allocates the memory to the variable l and soon after you assign NULL for l with the function criarLista, leaking the memory. Directly assign the…
canswered Vinicius Fernandes 1,727 -
1
votes1
answer46
viewsA: How do I get only the units of that number
The year has 4 digits, so divide the year by 1000 and take the rest of the division: printf("%02d:%02d %02d/%02d/%02d",hora,minuto,dia,mes,(ano % 1000));
canswered Vinicius Fernandes 1,727 -
1
votes1
answer56
viewsA: Initial problem in C
The scanf is reading the enter you pressed while typing a number. To ignore whitespace, use a space before %c. scanf(" %c",&decisao);
canswered Vinicius Fernandes 1,727 -
0
votes1
answer54
viewsA: Pointer cast
The (unsigned char *) is a cast from any address to an unsigned char type address*. A unsigned char has a byte size. The first * is to de-reference the address of s. As the address of s is now…
-
1
votes1
answer48
viewsA: Improper storage in the vector
You have not declared the variable max used to initialize arrays pares and impares, so I replaced it with 10. I moved the variables i and num for the scope in which they are used. And for the…
-
1
votes2
answers33
viewsA: Array as a function parameter
The Zeranegatives function expects an int array and not an int. Just replace ZeraNegativos(numeros[9]); for ZeraNegativos(numeros);
-
0
votes3
answers109
viewsA: Calculator does not print the correct value
C does not initialize its variables, so a variable declared without an initial value will have a value that is already present in the memory, known as "garbage" value. Because of this your variables…
-
2
votes3
answers1489
viewsA: implementation of Split() in C++
The method find find the position of the character sep starting from the index start, if it finds it returns the position of the character to end, else it returns npos for end. That’s why the…
-
0
votes1
answer312
viewsA: Display imaginary vector values with pointer arithmetic
My doubt and the following: When I create a "FOR" or other whole variable to create another loop the variables and memory placement get all weird. What is happening is that you are reading the…
-
1
votes2
answers603
viewsA: While or Do While exercise using CHAR variable
The char type is an integral type as well as the int, it can contain a value between -127 to 128 if signed or 0 to 255 without sign. However, it is mostly used to store a character that ultimately…
canswered Vinicius Fernandes 1,727 -
0
votes2
answers59
viewsA: difficulty sqrt()
The area of a rectangular triangle can be calculated using the following formula: area = (base * height) / 2. To have a better precision recommend using the double type. #include <stdio.h> int…
canswered Vinicius Fernandes 1,727 -
1
votes2
answers225
viewsA: How to initialize a string vector within a struct?
When I tried to compile this code I received the following error: ISO C++11 does not allow Conversion from string literal to 'char *'. These values { "Abriel", "Valencian" } create a matrix matrix…
-
1
votes1
answer67
viewsA: What’s wrong with this array of pointers in C? (incompatibility?)
What is happening in your code is that you declare vector as an int array (int*) and its sum_all() function expects to receive an int array (int**), are different data types. Another point is that…
-
1
votes2
answers85
viewsA: Help me! C language
When you have an if/Else chaining inside another if/Else you need to use keys to avoid the ambiguous Else problem, where the compiler doesn’t know if Else belongs to the internal or external if, the…
canswered Vinicius Fernandes 1,727 -
10
votes2
answers158
viewsQ: What happens to memory when "realloc()" reallocates a memory block to a value less than the original?
Suppose I allot a dynamic matrix of 10 ints and assign some values values to it, then I use the function realloc() to reallocate the matrix to 3 ints, what happens to the other 7 ints, they will be…
-
0
votes1
answer45
viewsA: Why does pre-decrement generate a problem as an argument of a function? Why does Ex1 not work correctly?
I will try to explain in the way that I understand what is happening, if by chance I make a mistake in something correct me. In the Ex1 for the multiplication of in a factor * (-num) it is necessary…
c++answered Vinicius Fernandes 1,727 -
0
votes2
answers96
viewsA: Array with large numbers
You have marked this code with the C++ tag, but it is visible that it is in C. I was in doubt if this example of large numbers is an integer or double, but since the array is int I will assume that…
-
2
votes2
answers268
viewsA: Exercise: Pair or odd championship in c
I went to read the statement and started to do the implementation only I ended up traveling too much in the codes and I made an interactive game between the player and the computer kkkk, if anyone…
canswered Vinicius Fernandes 1,727 -
2
votes10
answers5627
viewsA: Function that returns if one can go to the database with true/false?
In javascript the string type can only store a value and not a "list" of values as you are doing. You said that your example worked by testing with the Friday parameter is because in the "list" you…
-
0
votes1
answer153
viewsA: I’m having trouble with my C algorithm
I don’t know why you limited operations between 0 and 9, so I limited my implementation as well. The checks must be done before performing the calculations and if an entry is found invalidates the…
canswered Vinicius Fernandes 1,727 -
3
votes1
answer2656
viewsA: Calculating Javascript false/rue relationship
In Javascript it is better to use operators === and !== when comparing. The function temAMesmame takes 2 strings and compares the received function values maedan returning a Boolean. function…
-
2
votes1
answer56
viewsA: Error in storing names in.txt file
Usually data structures are declared outside functions. I noticed some errors in your code: You only declared only one structure instead of an array to receive the names within a loop, in which case…
canswered Vinicius Fernandes 1,727 -
0
votes3
answers607
viewsA: Declaring a string in C
Once declared char nome[40] will be allocated 40 char in memory at the time of compilation, this value cannot be changed, but you can use a pointer to specify the size of the vector in the variable…
-
1
votes2
answers1761
viewsA: Relative path in Java
The paths in Java are relative to where your . jar is located, you who are passing an absolute path in your variable. Relative paths will also be different in Ides as you program. For example, using…
-
0
votes1
answer33
viewsA: I need to develop a program that given an input file, generates a java output file
I made an implementation here, the program will read the file, analyze and convert the data and write the file with the formatting indicated in your question. import java.io.BufferedReader; import…
javaanswered Vinicius Fernandes 1,727 -
0
votes2
answers528
viewsA: Writing in a C++ matrix
I was wondering if you are using C or C++, why the question speaks C++ and the code is in C. I did here an example of how to read a file using C++. Suppose your Emails.txt file is as follows: nome1…
-
1
votes1
answer450
viewsA: How to do a pointer struct for a function that prints the struct itself in C
The C language is not object oriented, so it does not have a pointer like the this for a method to be able to access members of a struct. The way I found to do this is this, you create a struct with…
-
0
votes3
answers732
viewsA: Write a function that returns the larger of two numbers passed as arguments
You are not passing the requested parameters in the function call, and even if you did that you would be comparing text because the input returns a string. What you should do is read the inputs in…
python-3.xanswered Vinicius Fernandes 1,727 -
1
votes1
answer167
viewsA: Variable and scope beyond file . cpp C++
Variables declared in global scope of the file can be accessed by other files using extern. foo.cpp int myVar = 10; main.cpp #include <iostream> extern int myVar; int main() { std::cout…
-
0
votes3
answers159
viewsA: Scanner gives error if inverting the order in which data is read
I listed here some changes I had to make to your code. Class name must start with uppercase letter. You can declare variables and start them on the same line. I added some logs to indicate what the…
-
0
votes2
answers3978
viewsA: I can’t change directories in Git Bash
git bash already starts by default in your user’s directory when it is in the default directory instead of showing all the way for example: /c/Users/Gustavo it shows only one: ~, when you are in…
-
0
votes1
answer132
viewsA: I am unable to publish my repository on github
For your computer to be able to access your repository and push using SSH for example, it needs to authenticate with github, to do this it needs to have an SSH key that is informed whenever you push…
githubanswered Vinicius Fernandes 1,727 -
0
votes1
answer3892
viewsA: My question is about the error: 'Function' "Was not declared in this Scope"
You’re implementing functions and variables in the header files and they’re not exactly made for this. The header files . h are like an interface that declares the functions, and the implementation…
-
2
votes2
answers3058
viewsA: How to use a Python Break?
You reversed the signals of the condition, you typed => when actually it is >=, also I think that the break would not be correct because it would stop the loop, but the continue that just…
pythonanswered Vinicius Fernandes 1,727 -
1
votes1
answer250
viewsA: Overflow error
The error is in the Location class in the getCategory function: public Carros getcategoria(){ return this.getcategoria(); } I think what you wanted to do is this: public String getcategoria(){…
-
1
votes3
answers579
viewsA: 3 java classes, one calling the other, how to call first-to-last methods? (bluej)
Classes can be used to declare variables within other classes. EX: public class A { private String nome; public A(String nome){ this.nome = nome; } public String getNome() { return this.nome; } } In…
-
4
votes3
answers991
viewsA: Showing only pairs in the list - Python
I did it that way: number = int(input('Digite um número: ')) if(number >= 2): # O range(0, numer + 1, 2) cria um objeto do tipo range. # Iniciando com 0 indo até o number + 1, pulando de 2 em 2.…
-
3
votes1
answer92
viewsA: Doubt about Python classes and attributes
So drivers is a static property, it does not belong to a specific instance, but the class itself. To declare a property that belongs to an instance you declare the property in the class constructor…
-
3
votes1
answer190
viewsA: Student of Kotlin
A class in Kotlin may have a primary constructor and one or more secondary constructors. In Kotlin it is possible to create classes with properties using only one line of code for this use the…
-
0
votes1
answer220
viewsA: Pass Array String by parameter
For the Matriz22 method to receive a String list is like this: public void Matriz22(List<String> lista){ } You have not shown the class to which the Matrix() method belongs, so improvisei, to…
javaanswered Vinicius Fernandes 1,727 -
0
votes1
answer67
viewsA: I want to call a public List<String> method in main
The main method is static it has no access to the non-static methods within the class, for this you need to instantiate first the class that contains the call method: public static void…
javaanswered Vinicius Fernandes 1,727 -
1
votes1
answer487
viewsA: How to create this class hierarchy?
This seems to be a POO exercise on inheritance, not to create one class within another, but to extend the child classes with the mother class. I implemented a version of my own here based on your…
-
-1
votes1
answer59
viewsQ: Difference between Staticresource and Themeresource UWP uses?
To declare a Textblock with Headertextblockstyle style you can use these two forms where the result is the same: <TextBlock Text="Olá, Mundo!" Style="{StaticResource HeaderTextBlockStyle}" />…
-
1
votes1
answer47
viewsQ: How does C# run in the universal app?
I started studying the universal Windows 10 app and saw that the execution mode is different from Win32 or . Net, since it uses Winrt that calls directly to the system kernel, leaving languages like…
-
15
votes2
answers5495
viewsQ: What are Async methods?
I noticed that most methods in C# have an equal method but with a name async. What are these methods and how they work?
-
4
votes1
answer1436
viewsQ: What is the formula used to calculate FPS in a game?
I’m creating a game in java using lwjgl3, I’ve seen many algorithms but all are different from each other. So simplifying my code would be like this: start(); while(running){ update(); render(); }…
-
-1
votes2
answers58
viewsQ: How do apps validate login on a remote server?
Let’s assume that I have a website with a Mysql database with log-in logs, so a desktop or mobile app would need information like host, root and password to remotely validate a form, but that…
-
3
votes1
answer60
viewsQ: Does Java’s Try-catch-Resources flush automatically?
When using an object of the type FileInputStream and FileOutputStream within a Try-catch-Resources java automatically uses the close-up() in the end, but, and the flush() is automatic or not? //…
javaasked Vinicius Fernandes 1,727