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
votes1
answer51
viewsHow to check if a code contains 3 letters and 4 numbers in this order?
I am assigning the return of the function checks code to a flag. The idea is to make the flag trigger the loop if the code is incorrect char *leValidaCodigoAviao(char *msg, char *msgErro){ char…
-
0
votes1
answer36
viewsI cannot return the message saying if the values form a rectangle triangle
#include<stdio.h> #include<stdlib.h> #include<locale.h> #include<conio.h> #include<math.h> int retangulo(int a, int b, int c){ …
casked 6 years, 5 months ago Eliandro_05 1 -
0
votes1
answer1662
viewsVector union in the language C
Question: Make a program that reads two vectors of 10 elements. Create a vector that is the union between the two previous vectors, i.e., that contains the numbers of the two vectors. It should not…
casked 6 years, 5 months ago Antonio Lopes 59 -
0
votes0
answers382
viewsrandom primes in C
I have to make a program capable of generating automatically and randomly 100 positive integers between 0 and 1000 and that presents in the console the sum and average of the primes existing in the…
casked 6 years, 5 months ago Fabio Gonçalves 11 -
0
votes1
answer42
viewsCalculating Date and Time
I’m using the tm header time. h structure as follows: #include <stdio.h> #include <time.h> int main() { struct tm dt_current, dt_begin; dt_current.tm_year = 2018; dt_current.tm_mon = 11;…
-
0
votes1
answer581
viewsSegmentation failure in C language
Hi, I have a problem... The code only runs until a part after this appears: Falha de segmentação (imagem do núcleo gravada) Follow my program below: #include<stdio.h> #include<stdlib.h>…
-
0
votes0
answers50
viewsSort strings on a struct array in C
I’m trying to sort alphabetically strings in a string array in a struct, but for some reason the names get bugged #define TV 10 #define TC 100 typedef struct ficha { char nome[TC]; int dependentes;…
-
0
votes1
answer346
viewsError: expected Expression before 'dadosaluno'
I’m doing a student registration program: #include <stdio.h> #include <stdlib.h> #include<string.h> /*Elabore um programa em linguagem C, que seja capaz registrar um conjunto de…
casked 6 years, 5 months ago Gustavo Mariano 1 -
0
votes1
answer63
viewsHow to play letter by letter of a sentence in an array?
Example: in the sentence naruto, the letter n vector frase is in position frase[0]. I want to put it on mat_cript position [0][0]. Not only her, the rest of the sentence too. #include…
-
0
votes1
answer104
viewsUse of the getline() function in C with Mingw
I created code for a library collection using Linux/GNU, and it’s working perfectly. However, I need to Compile code on Windows using GCC, and wanted to know if there is a method to use this…
-
0
votes0
answers72
viewsHow to read data from a.txt file
Hello, I am developing a database queue in C. How can I read entries in a file and thus assign values to some specific variable of my program? Example: I have a variable int qtd_boxes in main. I…
casked 6 years, 5 months ago Pedro Felippe 9 -
0
votes0
answers166
viewsHow does a Merge Sort work exactly?
I already know that it uses recursion and that it orders the vectors until they are ordered, but it is exactly in this part that it generates my doubts. How do I know when he will call the Merge…
-
0
votes1
answer101
viewsDynamic Chained List Creation
I am studying data structure by site: Uncomplicated C Language - Data Structure and in class 12 (3:52 min) the teacher develops the function that creates the list: // Implementação das funções…
-
0
votes2
answers359
viewsInitialize a function that has a string pointer as argument
I wrote a function that changes the letter of a string by its successor using a pointer of string. #include <stdio.h> #include <stdlib.h> /* 14) Implemente um algoritmo que receba uma…
-
0
votes0
answers324
viewsUnique random function without repetition - C language
Guys, I’m doing a program in C language, and I need him to do some sweepstakes, but they can’t be repeated, the program controls the input of a lecture, and there will be a draw, in this draw the…
-
0
votes2
answers981
viewsChange a text value using a C pointer
I need to change the values of the variables through their pointers but I’m not getting. #include <stdio.h> #include <stdlib.h> //Programa principal int main() {//Declaração de variáveis…
-
0
votes1
answer83
views"strcpy" behaving strangely depending on how you put it in "if"
What’s going on here? #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> void escolha_simb(char *jog1, char *jog2) //** escolhe quem vai ser x ou o…
-
0
votes1
answer156
viewsRead char matrix from a binary file
Function that writes and reads binary file: int FUNCAO_QUE_GRAVA_BIN (char filename[],int partida1,char resultado1) { typedef struct { int partida; char jogvelha[3][3]; char resultado; } velha;…
-
0
votes0
answers82
viewsSave variable to struct by pointer
I have a problem with my code that I can’t solve, I think it’s a simple detail, but so far I haven’t discovered. I need to reference a vector, which has a struct, but it is not allocating the data…
-
0
votes1
answer43
viewsHow to check if the seat is free and if you are not asking the user to type again by inserting an 'X' in the occupied space?
I need the user to enter where he wants to sit by informing the row and column he wants, if the user chooses the position 0-1 the program will register and write to a txt file later mind that…
casked 6 years, 4 months ago Paulo Henrique 13 -
0
votes1
answer149
viewsHow to insert elements into a Binary Search Tree?
How can I make this function work? I am looking for an answer here on the site and still can’t void log_registrar(Log **l, int conta, int classe, int timer, int caixa){ Log *novo =…
casked 6 years, 4 months ago Pedro Felippe 9 -
0
votes1
answer108
viewsChange of binary basis to decimal basis
I’ve been trying to program a code to solve an exercise. Here’s the question: Write a program in C language that reads a string of any size containing binary digits and print the corresponding…
casked 6 years, 4 months ago vitor bernardo 3 -
0
votes1
answer166
viewsProblem in issue 1046 of the URI site
I am getting a compilation error (Compilation error) in the URI site judgment on issue 1046, although it is working perfectly in my Code Blocks. Question: My code #include <stdio.h> #include…
-
0
votes0
answers78
viewsProblem with algorithm in C
Good people , is the following , I am developing a project that aims to find a word in a soup of letters , the rules are as follows: The letter can be found at any position ( East, North , South ,…
-
0
votes1
answer133
viewsHow do I show the randomized quicksort step by step?
How do I show the sort process step by step? Either by showing the state of the vector at each change or by showing a tree. I have tried to print each of the three functions and also tried to create…
-
0
votes1
answer183
viewsQuery with Pointer for Struct in C
I am trying to solve an exercise for the college, where the statement requests that I receive a record, with two fields as input data. A vector field for storing name and another for storing…
casked 6 years, 4 months ago Arthur Simões 3 -
0
votes1
answer68
viewsDoubt about date manipulation using time. h
I am studying C and thinking about a problem I came across the need to study the time library. h. Basically, I would like to calculate the difference between two dates without having to reinvent the…
-
0
votes1
answer31
viewsHow do I display the highest height ever read on the screen?
int sexo = 1; float altura; int tm = 0, tf = 0, sm = 0, sf =0; printf ("O valor 0 encera o programa !!!\n"); while (sexo!=0) { printf…
-
0
votes1
answer82
viewsHow to read a file and insert data in c
Hello I’m new in C and have the following doubt I have a program that needs to save and read student data Student example below: typedef struct academico{ char nome[50]; char cidade[30]; char…
casked 6 years, 4 months ago augusto silva 1 -
0
votes1
answer407
viewsRead a text file and separate content into variables
I have a question about how to divide information from a text file into variables in C. Example, I have a txt file with the following data: 3 2 A D E AD DE I would like to read this file, and…
-
0
votes3
answers75
viewsError reading all records from a.txt file in C
Can anyone tell me why this my code just returns the first record several times, instead of returns all the records? Function in the Code void listarDados(int quantidadeContatos) { char caracteres;…
-
0
votes1
answer86
viewsAlways the same output in C
I wonder why the last printf of my program is always the same? I made it in C and I am beginner. The purpose of the program is to check if a number is palindromic or not. But when it comes time to…
casked 6 years, 4 months ago Omeuestilo 69 -
0
votes1
answer72
viewsHow to save value entered by the user in 2 different arrays?
Okay, this code is part of an attempt to solve an exercise. My goal is to convert all values from Kelvin to Celcius or vice versa and to present all values entered by the user whether they are…
-
0
votes0
answers55
viewsOverlapping values in the matrix
Ola has a matrix that is formed by a set of random numbers. However some of these sets of numbers overlap. What can I do? void ransnipa(int (*board)[40]){ srand(time(NULL)); int k; int x[snipa]; int…
-
0
votes1
answer177
viewsDiscover Winner Game Rooster / Old Game
I am developing the game of the rooster / old game and in this game I have to check every new move or iteration if there is any winner. I started by trying to do this for a static matrix predefined…
-
0
votes2
answers58
viewsInsert at the end of efficient-list
typedef struct NODO{ int custo; int linha; int coluna; struct NODO *nseg[2]; }Nodo; Nodo * insertLastEfi(Nodo *L,Nodo *nv){ Nodo * aux =L; if (L==NULL) { return nv; } while (L->nseg[1]!=NULL) {…
-
0
votes1
answer42
viewsReading from a file
I’m trying to read the contents of a file to a string, then use that same string in some operations. At this time I have the following function (at this time just read and print the content): char*…
casked 6 years, 3 months ago MarceloCosta 5 -
0
votes1
answer90
viewsProblem with function call in DLL (C)
I’m having trouble executing a code that uses a function of a DLL, which has a pointer as argument, according to the prototype: DLLIMPORT void add_std_func(object list) Follow the macro definitions…
casked 6 years, 3 months ago thiagofleal 51 -
0
votes1
answer63
viewsStrange error in C
Does anyone know why the value of i change in condition else if(i==721)? It changes strangely, as you can see in video of debuging. teamfile=fopen("team.txt", "r"); if(fgets(c, 3, teamfile)==NULL){…
-
0
votes2
answers552
viewsChanging character values in C
I’m trying to change the value of the characters by adding the current value plus some value provided by the user: char texto[7] = "barfoo"; int tamanho = strlen(texto); for(int i = 0; i <…
-
0
votes1
answer106
viewsCopy one binary file to another in C
Good! I am creating a car management program, and I need to first insert my cars (structs) in a binary file (draft), and then use another function to update, and pass the structs of that binary to…
-
0
votes1
answer94
viewsDouble linked list in C
Hello, I can’t understand what’s wrong with the code below. It was to add an element at the end of the linked list, but nothing happens and everything compiles without errors. Can someone help me,…
-
0
votes1
answer84
viewsReturn malloc to pointer does not stay between functions
I have these two examples here: example 1: void copiaStr(char *a,char *b){ b = (char *) malloc(strlen(a)); for(int i = 0; i < strlen(a) ;i++){ b[i] = a[i]; } } int main(){ char *a = "alou"; char…
-
0
votes1
answer565
viewsPassage by struct vector reference
I have to do an exercise where I get a struct and a vector following this struct with a size N of houses (which I called in the code of QTD) entered by the user. After this the program allows to…
-
0
votes3
answers91
viewsMy program compiles but hangs on the first printf
#include<stdio.h> void main() { int n1,n2,n3,maior,menor; printf("Primeiro numero: "); scanf("%d", n1); printf("Segundo numero: "); scanf("%d", n2); printf("Terceiro numero: "); scanf("%d",…
-
0
votes0
answers50
viewsFork() - Two processes accessing the same variable
Why in the output he does only the multiplication that is requested in the parent process and does not the sum of the child process? Entree: #include <stdio.h> #include <unistd.h>…
-
0
votes0
answers42
viewsRead a file and transfer to a vector
In case, what would be in the file would be like this: Baidu 12 Whastapp 53 . . . and so on, it would be the name of the "app", and the number q would be the size of the "app", But I can’t read a…
-
0
votes1
answer1217
viewsFunction to invert vector c
I’m a beginner in c and I’d like to know what’s going wrong with my code. I know I did a trick on the job, but that’s where I got the closest. #include <stdio.h> void inverte(int vetor_A[ ],…
-
0
votes1
answer957
viewsDoubt in exercise in C - reading with fgets
Good evening, I am learning C language through Luis Damas' book. There is an exercise of it that the program is not ending in condition. I’m using linux so I had to change the function gets() for…
-
0
votes1
answer521
viewsHow to use the strcountc function in C
Good afternoon, I’m not able to compile an exercise of Luis Damas' book C Language. The code is the same as the example but in the compilation the following errors occur: ||=== Build: Debug in…
casked 6 years, 1 month ago Wellington Mazoni 79