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
-
1
votes1
answer341
viewsLanguage C switch command 2 instructions within the same case
I’m having trouble incrementing using the switch, for example, I want to use an accelerator and every time I call the case '+': it makes two example increments: potencia=potencia+10;…
casked 5 years, 6 months ago Diego otto 33 -
1
votes1
answer44
viewsError in data printing
input example: rmtpuzcafhnyxdesivlkbwgjqo 2 roahp uhchch exit : veras batata Code: #include <stdio.h> #include <ctype.h> #include <string.h> int main() { char palavra[ 1000 ]; char…
casked 5 years, 6 months ago Bruno Santos 21 -
1
votes3
answers98
viewsConditional structure and repetition For simple in C
This is a conditional structure code and repetition For simple in C. However, the output is being the sequence: 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20. The expected…
casked 5 years, 6 months ago Gustavo Medeiros 65 -
1
votes1
answer137
viewsIncrement pointer inside C-linked list
Good people, theoretically when we create a pointer and make it point to an array, int a[10] = {0,1,2,3,4,5,6,7,8,9}; int *p = a; then to increment the pointer to the next element we do something…
-
1
votes1
answer281
viewscounter how many times the program was executed in C
wanted a program that counts how many times it was executed through a txt file that quarda this value, but what happens is that it never leaves 1, someone has an idea of what I did wrong? #include…
casked 5 years, 6 months ago Christian Fleury 19 -
1
votes1
answer1406
viewsCompare two chained lists and return whether they are equal or different
I’ve been trying to compare two lists simply chained and return if they are equal or different but I’m not able to match the compare function, it only compares the last value inserted whether it is…
-
1
votes2
answers141
viewsPointer struct
With a view to the following structures: typedef struct celEstado *apontadorEstado; typedef struct{ char nome[30]; int populacao; int beneficiarios; int qtdCidades; float idh; apontadorEstado…
-
1
votes1
answer245
viewsProblem with fgets in C
This is the excerpt of my code with the problem: int main (void) { int n_sentencas, n_perguntas; scanf("%d %d", &n_sentencas, &n_perguntas); fflush(stdin); char** sentenca; // ponteiro para…
-
1
votes1
answer76
viewsHow to save samples before and after an event in a circular buffer?
Hello, I’m processing a 17-hour audio dataset. wav (16-bit PCM, 192khz), to simulate a "real-time" processing that will be embedded in an ESP32, Arduino DUE or a RASP, depends on the results. How…
-
1
votes1
answer67
viewsList of states where each node will be linked to a binary city search tree
Good afternoon, I wanted to know how to make a chained list of states where each state node is linked to a binary city search tree from information extracted from a file. My doubt arose after…
-
1
votes2
answers90
viewsExit error while trying to print contents of.txt file
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <getopt.h> typedef struct{ char **matriz; } Dado; void ler_agumento (Dado *dado, int argc, char **argv){…
-
1
votes1
answer24
viewsSubmit data p/ database via SOCK_STREAM
Hello, I need to create a function that should connect to port 80 of the server "servername" send a request in which the list of parameters/ values of the POST request is defined based on its…
-
1
votes1
answer81
viewsCan’t find one string inside the other
When executing this code, and perform a test with: Entrada: analise padrão Mensagem: ana The sentence is not found inside the other. #include <stdio.h> #include <string.h> int main (){…
-
1
votes4
answers2153
viewsFunction to invert a string
I tried to do a function in order to invert a string but the program always returns (null). #include<stdio.h> #include<stdlib.h> #include<string.h> char reverse(char string[]) {…
-
1
votes1
answer334
viewsPath in levels in the binary tree
I’m trying to create a function that traverses a binary tree in levels through a chained queue, but when I compile it shows the error message "Segmentation failure (recorded core image)".…
-
1
votes1
answer257
viewsVector and strcpy problems in C language
I’m trying to make a vector with 23 names, which should draw 11 salts, 6 sweets and 6 drinks without repetition, the draw should be done in numbers 1 to 3 and when it is drawn should be assigned a…
-
1
votes2
answers120
viewsBingo program does not identify who has won
Trying to make a bingo with matrix in C, however the verification of the drawn values does not identify correctly with the matrix. #include <stdlib.h> #include <stdio.h> #include…
-
1
votes0
answers90
viewsDoubts about how to pick up line values inside a C file randomly
Guys, I’m creating a game called "run the wheel",I have doubt on a part of the code, where I need to pick up words inside a file randomly. My file is this way that I will put down: vegetable 2…
casked 5 years, 5 months ago Leandro Sampaio 11 -
1
votes1
answer170
viewsC matrix showing large numbers and not typed
I’m having a problem in at least all my matrices made in class, I even caught a fixed problem of the internet and my matrix on PC is still showing random numbers. the code is as follows: : void main…
-
1
votes1
answer210
viewsfunction to insert a no in a linked list in C
How to complete the missing code in lines with 1. 2. 3. 4.? The goal is to add a new node with a given name and age at the end of the list. NOTE: I know there are less confusing and more practical…
-
1
votes2
answers77
viewsDoubt about switch
I would like the switch show me the sum if I choose case 1 as follows the code, but it does not perform the operations. #include<stdio.h> int main() { int a,b; int operacao; int soma = a + b;…
-
1
votes1
answer39
viewsMethod returns different data as the architecture of android
I created a library for Android and it has a method that returns the milliseconds of the epoch date. I tested on 2 different architectures to validate if the returns were correct. armeabi-v7a:…
-
1
votes1
answer71
viewsWhat is the most efficient way to kill an external process from a program written in C?
My version: //test.c (04/07/2019) #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #include <sys/types.h> void stop_attack(pid_t child){…
-
1
votes2
answers105
viewsMy while has no end
I am making a calculator. The program performs operations depending on the number the user chooses. The problem is that when you type 5 it is to end the loop and this is not happening. int…
-
1
votes1
answer48
viewsPointer from a function does not print
So guys, I got a homework assignment here, I started pointers now and I couldn’t quite understand it, I’ve tried in a lot of ways to pass the "i" value to the main function and print it out, but I…
casked 5 years, 3 months ago placementw 128 -
1
votes1
answer55
viewsCrash C program when running
Once I enter the variable data originalMoney the prompt crash. Follow the code (it’s incomplete, I only ran the test with the first case) #include <stdio.h> #include <stdlib.h> #include…
-
1
votes1
answer221
viewsChar array problem to find out if the input is vowel, consonant and uppercase or lowercase
I’m trying to get the user to type a symbol on input and the program recognizes whether the symbol typed was a vowel, an uppercase vowel, depending on the uppercase or other character. For this I am…
-
1
votes1
answer102
viewsHow does the return of functions in C work?
From what I’ve been seeing, every C function needs a comeback, whether I’m right or not? 1- What is the reason for this? It influences something? (I would like a logical explanation if possible). 2-…
-
1
votes0
answers129
viewsscanf and getchar()
why in the second printf I can use only op=getchar(); but in the end I need to use a scanf to realize the question? #include <stdio.h> #include <stdlib.h> #include <ctype.h> int…
-
1
votes1
answer75
viewsGetting Started in Programming
I worked out a very simple algorithm, but I’m not able to do the same. Follows: #include <stdio.h> int num1, num2, soma, multiplicacao; int main(){ printf("informe primeiro número: ");…
-
1
votes1
answer70
viewsObject orientation and meaningless values in c++
Hello, I’m starting programming in c++ and I decided to do a struct to learn and such... except that the compiler shows no error and at the end the program shows me a completely meaningless value,I…
-
1
votes1
answer528
viewsHow to show/display a list of strings in Chained List?
Guys, I just started to learn Chained List in C language. Why didn’t my code display full string on the screen? It is displaying only integers or 1 character. The problem is in the display part (the…
-
1
votes2
answers834
viewsFind the highest vector value
A program that asks to find the largest number of an array, typing the amount of elements and until which element it will verify. However, in this program that I did it is not considering the first…
-
1
votes1
answer251
viewsBucket Sort - C
I’m having problems implementing the Bucket Sort sorting method, I need to test it 30 times with different amounts of data, but when I try with 100000 it presents me this error: "Process returned…
-
1
votes1
answer1383
viewsRead only one line in the file
I want fgets,take only one line and not the entire file,how do I do it in C? If I print the word variable in the function it prints everything and also would like to return that line in main.…
-
1
votes0
answers47
viewsHow to store only characters from a text file in an array?
int main(){ char aux; int i=0,j=0,p=0; char vetor[26]; FILE *arq; My.txt file has any string, I just want to take the characters of this string and move to a 26 position vector, which is the amount…
casked 5 years, 1 month ago fabiovinicius 11 -
1
votes1
answer698
viewsHow to pass matrix as parameter in C?
Hello. In general, I know that to pass an array as a parameter of a function in C, we have to specify the size of its dimensions. But this makes the function less generic. I was thinking of using…
-
1
votes0
answers915
viewsCustomer registration in C saving data in a.txt file
Good morning guys, I’m trying to learn the C language, and I’m making a program to register customers without using a database, I need to save the data (such as name, address, phone, email and…
-
1
votes1
answer54
viewsAt the last run of the repeat loop the entered value is assigned to my counter
I put a printf() to track what happened and everything was normal, until I type my last value and it is assigned to the counter quantN. The conditional even works when it is a negative value, it…
-
1
votes1
answer78
viewsCalculator is not capturing the second number
I have a code that I wrote, it takes two numbers and sums, subtracts, multiplies and divides. However, when incrementing the questions in the code and then running it reads only the number of the…
-
1
votes1
answer848
viewsAdd an element that is not in the array
I’m new to C, I’ve been trying to find a way to do this program but always returns a result that I can’t understand when printing the array for visualization. Example of entered values:…
-
1
votes2
answers889
views -
1
votes0
answers20
viewsDoubt regarding C pointers
I am writing a program that has 3 files: algorithms. h, algorithms. c and main. c. This program has several integer vector ordering algorithms. With the intention of making the program more…
-
1
votes1
answer146
viewsProblems reading a C file
I am trying to open and read a C file and then print the result but when printing it does not come out complete in case it has a 32 x 32 text image. Besides I would also like to know how I will read…
-
1
votes2
answers102
viewsHow does the pthread_cond_timedwait() function work?
The purpose of this function is to show the hours, wait for 2 seconds, and show the hours again to make sure that 2 seconds have passed. I am not using sleeps as this function is to help me…
-
1
votes2
answers63
viewsAverage is not being stored-C
Good night! When running the program and reporting the data Name, Nota1 and Nota2, the program is expected to create a file called "class.txt" with the student’s name, grades and average. However my…
-
1
votes0
answers29
viewsGlobal variable in C
Good afternoon, I need to use a global variable that depends on a condition in a code. I have the following documents Code2.cpp and Code3.cpp, both contain the Code1.h. I declared an extern on…
-
1
votes1
answer63
viewsVariables bursting
The variables cont_setosa, cont_versicolor, cont_virginica are breaking at the end of the code, why?? How to fix this?? Before Ifs the variables are normal, but after them, there is this change...…
-
1
votes1
answer94
viewsHow to create a matrix with dynamic allocation and structs
I know how to create a matrix using dynamic allocation only. However, I’m not able to create using structures. I have the following struct: struct matriz{ int** elemento; int nlinhas; int ncolunas;…
-
1
votes1
answer48
viewsESP8266 Node MCU receiving commands in JSON
Well I am coding an ESP8266 in C in which ESP receives a command through JSON: I have to take the data from this JSON (a String) and convert them to char* then be able to send this data to perform…
casked 4 years, 10 months ago Alcindo Schleder 77