Posts by zentrunix • 5,511 points
272 posts
- 
		0 votes2 answers38 viewsA: How to make a concatenation between a string and another primitive type in a function return?If you are using a compiler that supports C++14 you use the suffix "s" to indicate a string. Complementing: for numeric types, use to_string to convert to string. Assuming getDono, getStatus, return… 
- 
		0 votes2 answers58 viewsA: How to return different structures in a function with a value defined in Runtime?I think it’s too complicated... Unless there is some reason to use templates (at least I don’t see any) I would do something like this: if (get_os_arch() == 32) { s_arch_x86* x86 = (s_arch_x86*)ptr;… 
- 
		3 votes2 answers709 viewsA: How to get the connection id of a socket on a js Node server?In general there is no concept of "connection id" in the TCP protocol. It is possible to know the IP address and port of the person who connected remotely, in his example the Ria through the… 
- 
		3 votes3 answers548 views
- 
		0 votes3 answers2036 viewsA: Error of Segmentation fault (dumped core)Most likely the problem was caused by "stack burst". Local variables (i.e., declared within a function) typically use a memory space called a "stack" (commonly also called a "stack" even in… 
- 
		3 votes2 answers458 views
- 
		1 votes1 answer84 viewsA: Doubt about processes in language cDirectories /proc/n (where n is a number) contain information about the running processes. Assuming a process with pid 1234, the file /proc/1234/cmdline is a text file that contains the command line… 
- 
		1 votes2 answers241 viewsA: Can anyone assist in a resolution of a C code?Simple task. #include <stdio.h> #include <stdlib.h> int main() { int numero; char nome[100]; printf("*\n"); printf("* digite nome: "); scanf("%99[^\n]", nome); printf("* digite numero:… 
- 
		0 votes1 answer129 viewsA: Python UDP BroadcastRegardless of whether it is Python or another language, when broadcasting, you need to specify a port. Actually the question does not even make sense, when using UDP (or TCP) to exchange messages it… 
- 
		0 votes3 answers246 viewsA: Read and print struct valuesIn the "insert" function declaration the "employee" parameter needs to be declared "by reference" with a "&" next to the employee type: void inserir(funcionario& func) // <---------… 
- 
		2 votes2 answers302 viewsA: Error trying to access an array elementYou need to use an array of structures. Obs. not tested. #include <stdio.h> #include <stdlib.h> #include <string.h> /*Definindo tamanho*/ #define TAM 5 int main(void) { /*--Criando… 
- 
		0 votes1 answer149 viewsA: Visual Studio Transfer Control bypasses the startup of:Put keys in each "case": switch (option) { case 1: { int var; std::vector<int>v(size); std::list<int>l; //... //... break; } case 2: { double var; std::vector<double>v(size);… 
- 
		0 votes2 answers528 viewsA: Writing in a C++ matrixThere is no need to use a bi-dimensional matrix for this case. It is much easier to understand (and more natural) using a vector of structures. Much less necessary is the use of a two-dimensional… 
- 
		0 votes2 answers138 viewsA: Problem in realizing the sum of the lines of a two-dimensional matrix C++Though you say so The code works until the part of creating a one-dimensional matrix for actually your code nay worked, since compilation errors occurred. I copied the code you posted and opened it… 
- 
		0 votes2 answers34 viewsA: Program not to loop, even by typing the interrupt key!Put a space before %c printf("Deseja sair (s/S):"); scanf(" %c", &sair); 
- 
		0 votes1 answer70 viewsA: Serialize/Deserializar struct for sending via socketsFirst of all, whenever you travel through the network structures like the one you show you need to worry about the alignment of the fields of the structure. In this specific case nothing needs to be… 
- 
		0 votes1 answer146 viewsA: Dynamic stack in C does not compile because of incompatible char typesThere are several errors in the program, and the choice of names is very bad (Stack, Stack, STACK ???) Here is a version with some fixes. #include <stdio.h> #include <stdlib.h> #include… 
- 
		0 votes1 answer43 viewsA: How to dynamically allocate memory to a 2D array that stores the pixels of a bmp file in C?I did not touch the program, although it can be improved to be less confused, but here "on my machine" is not giving mistakes. [~/Projects/testes/so] $./390391 390391.dat 10 13 18 12 11 11 10 17 10… 
- 
		0 votes3 answers167 viewsA: What’s wrong with the Bubble Sort algorithm?It is not worth detailing everything that is wrong, corrected program. #include <stdio.h> #include <stdlib.h> void troca(int *a, int *b); int bubbleSort(int *vec); int main(void) { int… 
- 
		0 votes1 answer41 viewsA: Vector in struct does not workYou will use the variable "game" (array of game structures) to work, and no longer the individual variables "track" and "vetpalavras". Obs.: not tested. #include <stdio.h> #include… 
- 
		0 votes1 answer118 viewsA: Read each row of a file with different types in c using vectorFirst you read the name of the "clue", and the amount of words. Then you read the words, one at a time. #include <stdio.h> // exit #include <stdlib.h> // exit int main(void) { int qtd,… 
- 
		0 votes3 answers108 viewsA: Problems with a C programImplementation without many strings, but with some comments and explanatory messages. Also with names of significant variables, instead of x, y, m, n, k, etc, and with comfortable eye spacing.… 
- 
		1 votes3 answers170 viewsA: How do I break a string into several substrings so I can work with each of them separately using the C language?A solution using the strpbrk function, which is standard C, and is non-destructive. #include <stdio.h> #include <string.h> int main(void) { char teste[] = "aaa1bbb2ccc3ddd"; char* ptr1 =… 
- 
		0 votes1 answer56 viewsA: How do you reverse the digits of a vector and print them separately ? And can you differentiate 000 from 0 in C?The logic of the program that is in the question is very confusing, nor have I tried to understand. Below is a program with a logic that I believe is much simpler. P.S. Teachers never talk about… 
- 
		0 votes2 answers222 viewsA: problem comparing strings in c languageCorrected program. #include <stdio.h> int main(void) { char comida[20]; char bebida[20]; float total_a_pagar; // entrada de dados separada para comida e bebida...fica mais facil de //… 
- 
		1 votes2 answers55 viewsA: Exercise to sequence numbers with StructThe way it’s set I don’t think you can do it. Following the "anonymous" tip, what you can do is put a maximum size default in the floats array. #include <stdio.h> #include <stdlib.h>… 
- 
		1 votes2 answers72 viewsA: C program does not read values in txt fileAs the program posted is confused, it is easier to rewrite than point out the errors. #include <stdio.h> #include <stdlib.h> static void CPU(void) { int m, n, nLido; char matriz_A[5][5];… 
- 
		1 votes1 answer108 viewsA: How to check if client disconnected abruptlyOne way to do this control is for the client to keep sending messages to the server for a predetermined time. For example, even if the client has no message to send to the server, every 5 seconds it… 
- 
		0 votes2 answers199 viewsA: How to remove white space on a vector pointer?I can’t control data entry so the user won’t enter characters in white, for example: If it enters A B C D, the whitespace will be stored in each index of the vector. If that’s just the problem,… 
- 
		0 votes1 answer32 views
- 
		3 votes2 answers141 viewsA: Pointer structUPDATING The error is on this line: typedef struct celEstado *apontadorEstado; and the cause of the error is the fact that "celEstado" in your program is not a struct, but rather a typedef for an… 
- 
		0 votes1 answer111 viewsA: Chained list - Multiple error defenition of mainYou are SETTING the main variable in more than one place (when you include the list header file. h). You should not SET variables in . h files, otherwise you will probably get this type of error.… 
- 
		0 votes1 answer61 viewsA: Problem with reading file C languageThe end of file test is in wrong place... You have to test right after doing a reading operation: // while(!feof(pFile)) // <--------------- ERRADO while (1) { // char bufferAux = fgetc(pFile);… 
- 
		0 votes4 answers428 viewsA: Receive various values and print only the 3 largest ones in cImplementation with scanf testing. #include <stdio.h> int main(void) { int n, pon, plu = -1, slu = -1, tlu = -1; do { printf("*\n"); printf("* pontos (-1 para fim): "); n = scanf("%d",… 
- 
		0 votes1 answer152 viewsA: Helps in C dynamic allocation exerciseYou had problems with scanf. Below goes the corrected font. I also put some printf to debug (oddly it seems that teachers do not teach this). PS. Whenever the scanf function is used it is advisable… 
- 
		1 votes2 answers518 viewsA: Chained list - [Error] Storage size of 'mylist' isn’t knownYou need to declare the structures in . h and not us . c. Example: List file. c #include <stdio.h> #include <stdlib.h> #include "lista.h" // struct Nodo // { // int info; // struct Nodo… 
- 
		0 votes2 answers1281 viewsA: How to pass a vector class vector as a function parameter?It’s an old question and the answer seems pretty simple, unless I’m missing something... // void Matrix::IniMatrix(int *vetor) void Matrix::IniMatrix(vector<int>& vetor) { for (int i = 0;… 
- 
		1 votes1 answer108 viewsA: how to pass char from the main int to a class c++?You are passing the "name" parameter in the wrong way. Also, although it is not a mistake, your program is not "idiomatic" C++ that is, it is not "pure" C++ it is a mixture of C++ and C. #include… 
- 
		0 votes1 answer127 viewsA: Error Read access violation in visual studio functionStart here: you have allocated memory for the "im" pointer in (1), used the "im" pointer in (2), but you have not initialized the memory allocated in (1). Great chances of "strcpy" in (2) exiting… 
- 
		2 votes2 answers249 views
- 
		0 votes2 answers697 viewsA: Error lvalue required as left operand of assignmentThere are several errors in the program, noted below #include <stdio.h> // <============== FALTANDo #include <locale.h> // main () // <======== ERRO int main(void) {… 
- 
		0 votes1 answer26 viewsA: Getopt getting other options as argumentAccording to the documentation here you need to put "::" after specifying the argument to make it optional. #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int… 
- 
		0 votes3 answers573 viewsA: incompatible types when assigning to type ‘tipoNo’ {aka ‘struct tipoNo’} from type ‘tipoNo *’ {aka ‘struct tipoNo *’} arv = inserir(&arv, 5);You are assigning a pointer (return of the "insert" function) to the "Arv" variable, which is not a pointer. Correction: // tipoNo arv; // <------------- ERRO tipoNo* arv = NULL; //… 
- 
		2 votes1 answer185 viewsA: Difference between MOV and MOV ptrIt seems you’ve seen this here. The explanation is what is there on the link. In an instruction of the kind mov [ESI], al ; Store a byte-size value the Assembler (masm, tasm, etc.) knows which… 
- 
		0 votes1 answer36 viewsA: How to get the data output in a fileI think the problem statement is confused, I put an initial solution anyway . #include <stdio.h> // para scanf, printf, etc #include <stdlib.h> // para exit #include <string.h> //… 
- 
		1 votes1 answer230 viewsA: Conversion of C-pointers to AssemblyAssuming "real mode" programming for 8086, then we will use the general-purpose register AX (16-bit), the general-purpose register and index register BX (16-bit), and the segment register ES… 
- 
		7 votes4 answers3721 viewsA: List files by name (containing date), but filter the 5 days prior to the current date with . bat?This question is interesting as challenge, in practice it is totally unfeasible, the script is complicated and very easy to break. Update: missing consistency of file names, whether year, month and… 
- 
		0 votes1 answer28 viewsA: How to make the correct Ipaddress.Parse conversionA number with zeros on the left is an octal number, that is, a number written on base 8. Thus, (octal) 077 = (decimal) (0 x 64) + (7 x 8) + (7 x 1) = 63 In other words, generally avoid writing… 
- 
		3 votes3 answers444 viewsA: Factorial from 0 to 20 using For(1) You are adding "int" to "double": acc = acc + fat; The problem is that high factorial values fit in double, but do not fit in int. By the way, you’re not even using the variable "acc" for… 
- 
		0 votes1 answer127 viewsA: Problem C++ LNK2019 errorButtonscroll method definition of Shop class is missing.