Most voted "c" questions
C is a general-purpose computer programming language used for operating systems, games, and other high-performance jobs and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the UNIX operating system.
Learn more…4,811 questions
Sort by count of
-
0
votes2
answers47
viewsVector inside the matrix?
My function needs to find the line where the first occurrence of a vector occurs within a matrix and return its line. But it is always returning the wrong line, my logic is wrong? My job: int busca(…
-
0
votes1
answer1349
viewsDoubt in reading Matrix per file in C
I have to read an array 48X2 by a file .txt, the file has this structure: nome_da_pessoa 1 2 3 4 ... N N Where N is the 47 position elements, I need to save the person’s name in a variable, and save…
casked 6 years, 10 months ago user117001 -
0
votes0
answers49
viewsRand generating equal numbers
I have to do a program that generates random numbers for X1 and x2 and perform the operation F = X1*X1 + x2*x2; but I will repeat this 10 times and I will keep the lower value of F; then I will…
-
0
votes1
answer1893
viewsCryptography in C
I am developing a program in C, which will be able to encrypt and decrypt texts and save them to disk separately. I want to use the ASCII table for the implementation of Cryptography, I am able to…
-
0
votes0
answers38
viewsHow to implement OPEN SSL MDC-2 Hash using byte Array in data entry
Hello, I am trying to do/learn how to use openssl MDC-2. I found an example (https://linux.die.net/man/3/evp_digestinit) and I adapted to try to understand. This functional to input data via string…
casked 6 years, 9 months ago Dognaldo Jesus 1 -
0
votes1
answer645
viewsStone-paper-scissor-lizard-Spock in Uri Online Judge ex. 1873, but he does not accept
My attempt: #include <stdio.h> #include <string.h> int main() { char rajesh[15], sheldon[15]; char pedra[] = "pedra", papel[] = "papel", tesoura[] = "tesoura", lagarto[] = "lagarto",…
casked 6 years, 9 months ago André Moreira 3 -
0
votes2
answers1303
viewsHow to validate an email in c
Eai guys. I need to do an e-mail check with these features. Email must have: 3 more characters; an arroba sign (@); another 3 characters or more; followed by a endpoint sign (.); and a set of at…
casked 6 years, 9 months ago Igor Vargas 274 -
0
votes0
answers114
viewsProcesses in linux(Fork())
I am creating a client/server type server using sockets tcp, a client connects to the server, when it closes the client application, the server closes the connection command close (related), but the…
casked 6 years, 9 months ago Aislan Silva Costa 83 -
0
votes1
answer109
viewsGood practice in C on the "main()" call?
I’m developing a simple app for college work, and I have doubts about using the function main() in the code for instead of going out back to the beginning of the program, this would be good practice…
-
0
votes0
answers91
viewsProblem with the if-lse
I’m having a problem at the time of a comparison with the if-lse! I have a function that reads one file and writes to another only what is approved by if-Else, then deletes the first file and…
-
0
votes1
answer186
viewsProblem splitting a String array into C
I’m making a program that needs you to find half a string vector, but that half cannot cut any word, so that half would necessarily have to be the next space found after half. Soon after finding…
-
0
votes2
answers69
viewsError when user provides file name
#include <stdio.h> int main(void) { char ch; int caracteres = 0; int linhas = 0; int imprimiveis = 0; FILE *arquivo; char nome[50]; printf("Escreva o nome do arquivo: "); fgets(nome, 50,…
casked 6 years, 9 months ago Dennis Paiva 43 -
0
votes1
answer793
viewsHow to check whether the list is empty or with an element in C
typedef struct { int tamanho; nodo *inicio; } lista; typedef struct { lista **vet; int tamTabHash; int colisoes; } tabHash; tabHash…
-
0
votes1
answer26
viewsWhere is the macro LITTLE_ENDIAN_HOST and how does it behave?
After finally understanding how the decoding of opcodes works with a project of a CHIP-8 emulator I decided to return to an old project of mine, an emulator of Gameboy, so I started to implement the…
-
0
votes2
answers32
viewsCopy a square matrix of tam n into another complemetar n-1, omitted row 0 and column 0 of matrix n
#include<stdio.h> #include<stdlib.h> #include<limits.h> #include<locale.h> int main(){ int i,j; int mat[3][3]; int comp[2][2]; …
-
0
votes1
answer373
viewsHow to calculate the difference between dates using the time. h library
I saw that has a function in the team. h calculating difference between date I went on the site Documentation link time. h, did not quite understand how to perform this calculation, for example…
casked 6 years, 9 months ago rafael marques 939 -
0
votes1
answer1497
viewsHow to edit data from a Struct using a function
I want to create an edit function that takes as a parameter the music array by reference. (using pointers) The user must choose the song number and type back the data from that vector position. I…
-
0
votes0
answers45
viewsHow to extract a word between , and =?
Supposing I had a word: char[1000]={"ALGUMA COISA,ALGO=TESTE,FIM"}; The word before = and = itself are optional in the sentence; How do I store the SOMETHING word of the phrase in a variable? The…
-
0
votes1
answer83
viewsProgramming Problem C - Vectors
The problem is: Write an algorithm that reads 3 vectors A[1..10], B[1.10] e C[1..10] and write the elements that are in A and B (intersection) but are not in C. Write the values in the order they…
-
0
votes1
answer1979
viewsI cannot identify the error - |35|error: ’d' undeclared (first use in this Function)|
I am programming in C/C++ and gave an error that I cannot identify it. #include <stdio.h> #include <stdlib.h> #include <stdbool.h> //Função Principal do Programa int main() {…
-
0
votes0
answers39
viewsHow can I make one switch run in parallel with another?
I made this code for moving a character to a college assignment, but I wish that when I pressed the 'a', I could still walk and the ship wasn’t erased, just as I could press the 'a' several times…
-
0
votes0
answers36
viewsFunction that returns multiple elements
I have a doubt in the following exercise: Make a subroutine that takes a single value representing seconds. This subroutine should convert it to hours, minutes and seconds. All variables should be…
-
0
votes1
answer2428
viewsCalculate execution time of a sort algorithm in C
I have a question about how to get the run time only in the sort algorithm. I searched a lot on the Internet and found a lot of superficial stuff, nothing that would help me in what I need. I have a…
-
0
votes1
answer81
viewsProblems with C socket
I have 3 functions responsible for creating a socket, sending data and receiving data. Function sock_create creates a new socket by returning an int of that socket, Function sock_send sends a header…
-
0
votes1
answer48
viewsCode in C simply closes
#include <stdio.h> #include <stdlib.h> void recebeNumCartas(int *nAlice, int *nBeatriz){ scanf("%d %d", nAlice, nBeatriz); } int achaMenor(int nAlice, int nBeatriz, int menor){ menor =…
casked 6 years, 9 months ago Guilherme Bartasson 21 -
0
votes1
answer1505
viewsVector union, no repetitions in C
Follows the statement: Read two integer vectors X and Y, cadao one with 5 elements (assume the user does not report repeated elements). Calculate and show the resulting vectors in each case below:…
-
0
votes1
answer44
viewsHow to store a word within a vector larger than the word
I declared a variable char SendDataCmd[256] which will store the commands sent from the computer to the microcontroller via UART. Commands have different sizes as for example RST, ADV ON e SET…
-
0
votes1
answer55
viewsHow to delete a file (not txt) in C?
I’m creating a program that puts each student’s grades in a different file. The user places the student’s code and this code becomes the name of a file that is not txt (I don’t know how to make it…
-
0
votes0
answers63
viewsGenerate a matrix without repetitions
I need to make a code that takes an array and puts random numbers on it, no repetitions. I am able to generate the matrix, however, it still has some repeated numbers ;-; #include <stdio.h>…
-
0
votes0
answers489
viewsFunction to multiply each row of a matrix by the value of its corresponding secondary diagonal
I’m not getting the values of the secondary diagonal of a matrix by a function. /* 19) Elabore uma sub-rotina que receba como parâmetro uma matriz A(6,6) e multiplique cada linha pelo elemento da…
-
0
votes1
answer56
viewsSegmentation fault while reading file
I have an inputstream header. h that defines a struct having a string, an int and a readc Function. In this header I define the Function init receiving as parameter a string having the absolute…
casked 6 years, 8 months ago Carlos Henrique 77 -
0
votes3
answers176
viewsDynamic allocation with a void function
I made a simple code using dynamic allocation. Just ask for the vector size, to insert data and print them at the end I can make dynamic allocation with int, returning the vet, but as I’m learning,…
-
0
votes1
answer952
viewsWindows and Avast are blocking the compilation of C programs
Whenever I worked with C language, I used the college computers, so I never had trouble compiling and running them in the Dev-C++ IDE. Currently, I installed version 5.11 on my machine, but I only…
-
0
votes3
answers117
viewsText looks full of junk after typed
I started creating a data collection and usage application with the following code: #include <stdio.h> #include <string.h> int main() { int idade = 0; char nome[20]; printf("Hello! How…
-
0
votes1
answer549
views -
0
votes0
answers21
viewsProblems with setuid
I am developing a program that changes my process uid to 0 allowing me to start other root programs. mysu.c #include <stdio.h> #include <unistd.h> int main(int argc, char **args) { int…
-
0
votes1
answer114
viewsIs that piece of code redundant?
I recently did a C proof in which I had to complete a code to remove items from a queue, follow the code with the answer considered correct highlighted: typedef struct No { int dado; struct No…
-
0
votes0
answers96
viewsIncrease Module Speed bluetooth HC-05
Hello, I have a project with Arduino and the Bluetooth module HC-05 that gets the MACS of Bluetooth devices around (not connect, just search). It works, but I would like it to perform better by…
-
0
votes1
answer452
viewsCells with vectors in C, is showing the elements that have already been removed
How do I show my vector without the numbers that have been removed? 'Cause when I show him, even if I take a number off the function, he still shows up inside. #include <stdio.h> #include…
-
0
votes1
answer208
viewsPointers and data type hidden in C
EDIT: I’ll leave the codes right below in text same. Good evening. Please see attached image. It is the implementation of a function whose prototype is defined in another file named "stack. h". As…
casked 6 years, 8 months ago Lucas Lopes 89 -
0
votes1
answer38
viewsError to replace characters
I have to create a function to make the exchange of some character. This is the exercise: 1. Build a function that receives a message, its size and a character and remove all occurrences of that…
casked 6 years, 8 months ago Victor Eyer 1,508 -
0
votes1
answer78
viewsDisplay the value of vectors in C
Good afternoon, I am a beginner and I am creating a program with 3 vectors and I would like the entered value to demonstrate me on screen, but when running it shows some values that I did not type.…
-
0
votes1
answer54
viewsQuicksort C - Contest. c:16:50: error: request for Member' name in Something not a Structure or Union
I’m trying to make this URI thing: Tetris His high school class decided to organize a tetris championship. After discussion about the rules, it was defined that each student would play a total of 12…
-
0
votes1
answer106
viewsCorrection of the Code in C
I did the code below which is basically read two vectors A and B, and accumulate the values in vector C. At the end of the code, I need to show if there are repeated values and print a message to…
-
0
votes2
answers128
viewsIf Else Statement problems chained in C language
I’m starting in programming and had enough difficulty to understand If Else in a chained way. I came across the following situation, when running the code only the first or second condition…
-
0
votes0
answers85
viewsMemory junk when pointing a pointer
In an attempt to implement an adjacent matrix graph, I created the function to create a new "matrix" in which the contents of the graph would be copied to it by adding the new positions. However,…
-
0
votes1
answer57
viewsHow to improve performance in this code
I made the point The Legend of Flavious Josephus, but the time limit has expired, which I can change to decrease the time My code #include <stdio.h> void carregaVetor(int *vetor, int numero);…
casked 6 years, 7 months ago rafael marques 939 -
0
votes1
answer2163
viewsAscending Order in a chained list in c
#include <stdio.h> #include <stdlib.h> typedef struct LISTA{ int dado; struct LISTA *prox; }lista; lista *insere(lista *p,…
casked 6 years, 7 months ago Igor Vargas 274 -
0
votes1
answer1875
viewsHow to use abs() in an if function, Else if (c)
Edit 2: What I was asked to do: Your program must read the coordinates of a football over the field, and tell if it is inside the field, if it has gone out the side, if it has gone out the back or…
-
0
votes0
answers47
viewsDecimal to C binary conversion program
The exercise I’m solving asks to write a program in C(pointer, dynamic and recursive allocation) that prints a given integer on a binary basis. My result is generating a very large number, now I…