Posts by Vinicius Castro • 430 points
21 posts
-
0
votes1
answer47
viewsA: Why is this algorithm in C returning wrong values?
Your entry is incorrect. In the first two loops of repetition, you’re reading vector A and B, respectively, something like this: for (i = 0; i < 10; i++) scanf("%d", &vetorA); Your scanf is…
canswered Vinicius Castro 430 -
0
votes1
answer49
viewsA: Error to delete the first binary code entry
Analyze the code where your program saves the data, ie at the end. Before saving, there is a condition if (n > 0). Imagine that you register 10 users, quit your program (such as n == 10, and n…
-
3
votes2
answers134
viewsA: Program completion condition in C!
You are reading incorrectly. Remove the ' n' character from your scanfs and the bug will come out.
-
0
votes1
answer1327
viewsA: Build error "Undefined Reference to `sqrt' " in Atom editor
The problem is that you are including the library but are not passing the flag in gcc. Try setting the flag -lm, sort of like this gcc main.c -o main -lm
-
1
votes1
answer180
viewsA: Rand() returning the same value even with the inclusion of srand((unsigned)time(NULL)
Your mistake is that you are casting a seed several times, put srand in the main and see the result. #include <time.h> #include <stdio.h> #include <stdlib.h> int rolaDados(){ int i…
-
1
votes1
answer108
viewsA: Convert structure to string
If you have an integer and want to turn it into a string, you can use the function sprintf which does the opposite of atoi. The function sprintf int sprintf(char *str, const char *format, ...);…
canswered Vinicius Castro 430 -
0
votes1
answer51
viewsA: Generate an error if the code entered by the user is not a valid value
To manipulate the input, it is recommended to read it as a string, so you will not lose any characters (because if you lose, how will you detect it?). Below is a code I made that reads an entry, and…
canswered Vinicius Castro 430 -
1
votes2
answers112
viewsA: want to read more than 1 file . txt in C
In C, the type used to communicate through files is FILE * as you may well know, FILE * is a pointer to a struct that contains data from a certain file, given these negotiated between your program…
-
1
votes1
answer321
viewsA: Struct vector: Passage by reference in C
The problem of your code is in the readings: in scanf you must pass the memory address of the variable that will receive the reading, and not the variable itself. Below is your code with correction.…
-
2
votes1
answer41
viewsA: Read a string from a File with space
You are using fscanf for reading and passing "%s" as parameter, what does that mean? You are reading a word from the file passed in fscanf. How to solve this? Using functions to read an entire line,…
-
1
votes1
answer43
viewsA: Use of library in different S.O
Yes Eric, there are similar libraries: You can choose to use GTK+ (https://www.gtk.org/), with it you can use the same code to develop graphical interfaces for Windows, Linux or macOS, here is a…
-
0
votes3
answers98
viewsA: Incorrect reading of floating point
Problem solved. The problem is not read, it is write. Reading a float to, when finding a '.', the correct character must be a ','.
-
1
votes3
answers98
viewsQ: Incorrect reading of floating point
I have a file that stores products, each product has three information: its name (char *), quantity in stock (int) and its price (float). The information generated in my program I am saving in a…
-
1
votes1
answer1082
viewsA: Compile C++ file in VS Code using external cmd
Press Control + ' to open the terminal, and enter g++ -the filename.cpp filename. Make sure you have g++ installed.
-
0
votes1
answer736
viewsA: Render and display the Matrix in C (dev c++)
I found several errors in your code, here they are: First, the variables where you are holding the amount collected each month need to be initialized, thus: int mat[12][4], l, c, totalsemana,…
-
0
votes1
answer31
viewsA: How to use struct member variable to preset matrix size
When working with vector, one has to bear in mind that there are two types: static vectors and dynamic vectors. The vector of your struct in this case is a static vector, you can even declare it and…
canswered Vinicius Castro 430 -
6
votes2
answers4454
viewsA: What is sscanf() and sprintf()?
SSCANF According to the book "The ANSI C Programming Language", by Brian W. Kernighan, the sscanf function, whose statement is int sscanf(char *s, const char *format, ...); is a function equivalent…
-
4
votes1
answer73
viewsQ: Why is it that when I include my . h header, the . c implementation is not included as well?
I have three files, produtos.h, produtos.c and main.c. produtos.h is located in the folder "headers", produtos.c is located in "sources" and main.c is in the same folder as "headers" and "sources",…
-
1
votes1
answer861
viewsQ: How to block downloads from my server
I have a server, and inside it I store videos that are displayed through. However, if people get the video link from Inspect Element they can download the video. Is there any way I block downloading…
phpasked Vinicius Castro 430 -
1
votes0
answers26
viewsQ: How does the automatic indexing of a blog work?
I’m creating a news site, and I see sites like G1 and Tecmundo using an automatic indexing for their news, how does it work? Well, I’ll explain it better: I have a file that reads the news through a…
-
0
votes1
answer873
viewsQ: How to organize data in 3 columns without breaking layout using CSS Flexbox?
I have a list of items (ul), and each item occupies 33% of the screen, thus forming a horizontal list of 3 columns. When there is no more space in the horizontal, it forms a new line, something very…