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
votes3
answers45
viewsPointer positioning
I wrote this code to make switch between the letters of a string, but it doesn’t even print anything, someone can explain to me why? Code: #include <stdio.h> #include <string.h> int…
casked 6 years ago Marlon Vinícius Buosi 3 -
0
votes0
answers284
viewsRead bytes of colors (RGB) from a bitmap
I’m trying a problem with a code I did that should display the bytes referring to the RGB color values of each pixel of an image in bmp format (bitmap). I know that in the windows api it is possible…
-
0
votes2
answers58
viewsConcatenate n characters of a typed word
I want to make a program in which the user type any word and is stored in a string, soon after it is necessary to store that same word in another string only in the reverse form, for example if it…
-
0
votes1
answer37
viewsPass RGB pixels from a file to C Structure
Good afternoon, I’m doing a project on the Data Structure chair and I have this file, with multiple RGB pixels. I would like to read the file and pass the values to a structure, where each pixel had…
-
0
votes1
answer72
viewsMatrix program error in C
I am starting now in C programming and I have a problem in my C program. The problem is that the printout matrix appears all zeroed. #include <stdio.h> #include <stdlib.h> int main (){…
-
0
votes0
answers70
viewsCalculate all distances
In an exercise, I need to calculate all distances between coordinate points (x,y) which are read from a file, the last point of which coincides with the first. Each point represents a city that is…
-
0
votes2
answers768
viewsCommand "goto" creating infinite loop in "for" loop
I want to simulate a school database that collects name, math and physics grades and averages both for 5 students (defined in a string of struct). Any grade above 10 would be allowed, without any…
-
0
votes1
answer90
viewsBinary search tree in C
I need to use a binary search tree to organize data. In each node I need to have ID and name, but I don’t know how to put two values in the same node. The tree I’m using is as follows: struct No {…
-
0
votes2
answers272
viewsWhat are the benefits of using struct?
As that type variables struct are stored in memory, for example: struct livro{ char autor[10]; float preco; }; //como essas variaveis fica alocado na memória? struct livro livro1;…
-
0
votes0
answers32
viewsReference passage
In an exercise, I need to compare a certain number of distances and tell which are the smallest and print them out. For this, I have the following function: void Permuta(FILE *saida, Cidade *C, int…
-
0
votes1
answer860
viewsChess Game in C
I’m learning C. My college professor asked to do a program that reads a horse’s position in the chess game and prints ALL the possibilities of movement. I’m racking my brain to know how I’ll know…
casked 6 years ago Henrique Ferreira 19 -
0
votes0
answers62
viewsCan I make a char pointer point to each position of a char vector in the C language?
ex: suppose a string called "Gustavo". How I make a pointer point to each position of the string and go applying the following rule. If the pointer finds the vowel A, the contents of that pointer…
-
0
votes1
answer44
viewsPrinting the shortest distances
The exercise asks me to print the smallest routes between n cities, whereas the latter is the same city as the starting point. First, I need to read an input file like the following: 5 1 10 4 4 5 1…
-
0
votes1
answer518
viewsFiles For Structs/C Pointers
I have this little program and I’m able to save, and upload from the file to struct(not perfectly). The error is as follows: after loading the file to struct, if in the function I load the printf it…
-
0
votes1
answer67
viewsSplit sets
Hello people need help with the following algorithm it must have as input an array where the user informs and the program shows the possible combinations, for example: input = [1,2,3] output = […
casked 6 years ago L. Linhares 11 -
0
votes1
answer238
viewsData does not persist on switch case
Write a program that registers the name, height, weight, Cpf and sex of some people. With the data registered, then locate a person through your CPF and print your IMC. When I choose the Query…
-
0
votes1
answer722
viewsDoubt Double chained list with ordered insertion
I created everything but my function of deleting is deleting the record but keeping in print the code 0. Could someone help me find my mistake? I would also like to know if my algorithm was…
casked 6 years ago Gustavo Luciano 747 -
0
votes2
answers1169
viewsCheck the occurrence of each letter in a string - C
I need to write a procedure that takes a pointer to a string p and shows(prints) the number of occurrences of each letter within the word. Example: macaw should show a=3 and r=2 shoe should show…
casked 6 years ago Igor Benavente 3 -
0
votes3
answers1015
viewsThe sum of all non-prime odd numbers that precede an integer?
Example 1 of execution: Entrada ( numero inteiro): 10 Output: 10 So far I have it: num =10; for (i = 2; i < num ; i++) { if (num % i == 1 ){ printf("%d\n", i); soma2 = i + soma2; } } But in the…
casked 6 years ago Juan Santos 11 -
0
votes2
answers86
viewsCode return problem (second-degree equation)
The return of the code below is "-Nan", and I am not identifying the error. #include <stdio.h> #include <math.h> #include <stdlib.h> struct variaveis { float a,b,c; }; float delta…
casked 6 years ago Hugo Cabret Chinês 1 -
0
votes2
answers98
viewsValues in C do not return what is expected
I am in personal studies following a booklet that this algorithm gives the following result: Algorithm of the Apostille #include <stdio.h> #include <conio.h> main() { int n = 10; int m =…
-
0
votes3
answers170
viewsHow do I break a string into several substrings so I can work with each of them separately using the C language?
ex: Suppose the user typed "I’m cute". Then, I would work with "I", then with "I am" and last with "beautiful", separately.
-
0
votes1
answer193
viewsSystem call in c/c++
Hello I need to make a system call (in c/c++) that lists the memory consumption of processes anyone has any idea how I can do this ? i am using linux as s.o
casked 6 years ago Hianuy Esperidiao 1 -
0
votes0
answers50
viewsCode with Sockets locking in the middle
Because of the matter of college networks, lately I have had experiences to learn how to deal with sockets in C. But today, trying to develop a game of sailing to practice, I went through a somewhat…
-
0
votes1
answer79
viewsProblem passing array as parameter
I am unable to pass the array parameters correctly to the function calculos. The code compiles correctly, but the function does not receive the values I am trying to pass. Since it is an array of…
casked 7 years, 6 months ago Graciano Souza 31 -
0
votes2
answers1403
views -
0
votes2
answers83
viewsAccessing variables from a struct
I am studying C and I am doubtful in the difference of the following lines: (*depois).agora = 20 and *depois.agora = 20; From what I understand the point . has priority and the compiler would try to…
-
0
votes1
answer341
viewsProblems organizing a C-struct
I’m having trouble organizing the data of a struct, the data are even organizing, but I always end up receiving memory junk in the first position, the others are organized normally without errors.…
casked 7 years, 6 months ago Graciano Souza 31 -
0
votes1
answer173
viewswhile (Cin >> str) An equivalent code in Python
Need to read multiple items without a fixed amount, in c++ just do while (Cin >> str) what would be an equivalent python code? has an answer in English to this same question here in the stack,…
-
0
votes1
answer224
viewsWhy does the variable x of the double type always print the same WRONG value in scientific notation?
In this first example I would like to know why the variable x read in double, when it is formatted by the function "printf()" does not display the value correctly, and every time the value is the…
-
0
votes3
answers1075
viewsI want to pass a parameter that is in the main for a function and perform a calculation, pointer exercise and function, how do I do?
Hello, good afternoon. I have a pointer in main that points to a variable (variable "Ex1"), and I need to do with calculus with it in another function... what I have now is like this... main() {…
casked 7 years, 6 months ago Braian Freitas 159 -
0
votes1
answer59
viewsI’m having trouble printing a variable in my program
I’m doing a program that simulates a bank, in function criarpessoafisica I’m trying to get the algorithm to check that Cpf is already registered, but it’s not working ! For some reason he printed…
-
0
votes1
answer48
viewsI don’t understand why it doesn’t show all the cousins in this range
#include <stdio.h> int eh_primo(int x){ int i; int cont; for (i=1;i<=x;i++){ if (x % i == 0){ cont +=1; } } if (cont == 2 || cont == 1){ return 1; }else{ return 0; } } void…
casked 5 years, 12 months ago Gabriel Henrique dos Santos Si 9 -
0
votes1
answer54
viewsBase converter - Segmentation fault (core dumped)
I am trying to program a simple program that reads a number in base ten and converts it to binary and I have reached the following code: #include <stdio.h> #include <math.h> int main(){…
casked 5 years, 12 months ago Christus Moura 1 -
0
votes1
answer75
viewsSimply Chained Linear List
My question was how to do the program without dynamic allocation, I’m learning LLSE now, and everyone I think is with dynamic allocation, but my teacher said he would only use dynamic allocation in…
-
0
votes1
answer230
viewsConversion of C-pointers to Assembly
Good afternoon, I will have Assembly test and I have a question that is about pointers in Assembly. I’m trying to do an exercise, but I can’t fix it. "Consider the statements in C: int x=100, y=200;…
-
0
votes1
answer207
viewsWhat are the errors of this chunk of C code that sums the nodes of a binary tree?
int somaFolha(struct NO **Raiz) { int somaF; if (Raiz != NULL) { if (Raiz->esq == NULL || Raiz->dir == NULL) somaF += Raiz->valor; else { somaF = somaFolha((*Raiz).esq); somaF +=…
-
0
votes1
answer55
viewsDoubt regarding string manipulation
I’m starting programming and was trying to do a string manipulation, someone could help me in the code below where I would be missing: #include <stdio.h> int main( int, char ** ) { char nome[]…
-
0
votes1
answer2438
viewsHow to use C’s Pow function?
The program is not complete yet, but should at least run the função1. The following error is occurring: /tmp/ccbRtCar.o: na função `funcao1': iniciosimulado02.c:(.text+0x18f): referência indefinida…
casked 7 years, 6 months ago Lucas Gonçalves 63 -
0
votes2
answers338
viewsError when assigning variable value to vector in C
I am creating a user register using struct. In it, there’s the CPF field. As it is a very large field to store in number format, I decided to save as a string, as well as in a database where Cpf is…
-
0
votes1
answer307
viewsA vector in C, which updates the values in real time, according to the numbers reported
#include<stdio.h> #include<stdlib.h> #define tamanho 5 struct test { int vetor5; }casa[tamanho]; //funcão para o vetor da struct void recebe (void) { for (int p=0; p<tamanho; p++) {…
-
0
votes1
answer26
viewsGetopt getting other options as argument
I am making a code that should receive two strings for the execution with the parameters -i and -o, both of which can be null or not,the problem is found when the value of -i is not informed, it…
-
0
votes0
answers734
viewsLottery game program using matrix
I need to make a program in C, that the user enters with 5 games of 6 dozens stored in a 5x6 matrix. I need to create a function that draws a game of six dozens stored in a vector of 6 positions and…
casked 7 years, 6 months ago Adriano S Guimarães 3 -
0
votes1
answer76
viewsWhat logic do I use to write this program in C?
I’m solving a list of exercises on stacks and queues and stuck on a question where ask to write the program according to pseudo code of the question. I have very little experience with C, so I’m not…
-
0
votes0
answers228
viewsProblem with C/C++ sorting methods (Radix Sort)
I’m having trouble with this code... when I run it it’s returning me to negative run time. He was supposed to show me the execution time of each method. And not being able to change the function…
-
0
votes2
answers156
viewsHow to create a file within the users directory?
For each different pc, the Users/User folder tbm is different, I want to know how to create a file inside that directory. I was trying and I got to the following code: FILE *bug; bug =…
-
0
votes1
answer319
viewsCode in C displays error "Segmentation failure (recorded core image)"
Code compiles and runs normally until "switch". #include <stdio.h> int main(){ float mg, sp, rj, ms, produto; int escolha; printf("Digite o preço do produto: "); scanf("%f", &produto); //…
casked 7 years, 6 months ago user71383 -
0
votes3
answers218
viewsDictionary does not return all possible words
The idea of the program is to be a dictionary, the user informs the word, the program performs a check on the characters of the word finds the position in the vector and returns the definition if…
-
0
votes4
answers1889
viewsFill vector in C
I have an exercise that asks the teacher to type 5 notes, and display the typed notes, I wrote the code, but it’s not running the right way, someone can help? Follows code #include <stdio.h>…
-
0
votes2
answers77
viewsHow to hide another program window?
I am making a program that opens other processes on the computer for its operation, however, depending on the form to be used by the user, many windows will be opened unnecessarily. How to hide…