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
answer306
viewsProblems with header in. h
I am using the code below to check the IP of the computer, but the Code Blocks is giving error. #include <ifaddrs.h> #include <ip.h> #include <stdio.h> int main() { struct ifaddrs…
-
1
votes2
answers273
viewsApprentice of C (Factorization in C)
Can anyone help me with the logic of this code? the beginning of it I understand but I get a little confused in the part of the for, someone can help me to understand ? #include <stdio.h> int…
casked 5 years, 11 months ago João Vitor Camargo de Alemida 151 -
1
votes2
answers208
viewsDeclaration of a global array of C structures
I created a structure cliente and the next idea would be to create a array clientes. My idea would be to declare array clientes globally, so that all functions can interact without passing it as an…
-
1
votes1
answer51
viewsWhy can’t I access the data from this struct with the dot, just with the arrow?
I allotted that struct by dynamic allocation and can only access the data idade via arrow and not by point wanted to know why? #include<stdio.h> #include <stdlib.h> struct pessoa { int…
-
1
votes0
answers30
viewsHow does the compiler interpret separate files from a project?
As the modularization it has the header file, the .c and the main function, as the compiler joins all the codes and turns into the executable file?
-
1
votes1
answer196
viewsChained Allocation - Data Structure - C
Consider a storage area of 5 nodes. Over this area will be mounted a list simply chained with ascending ordering by the INFO field, named LIST. Initially create PND and NODO-CABEÇA to make this list…
-
1
votes2
answers76
viewsError while creating string array
I’m having trouble trying to initialize a vector of strings my code is like this: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ char *str[3];…
-
1
votes1
answer164
viewsDoes the r+ C mode for files not create the file if it does not exist?
I am working on this code below and would like to store some random vectors in a file. From what I read the r+ mode reads the file and writes to it, and if it doesn’t exist it will be created.…
-
1
votes0
answers94
viewsthe program is printing memory junk, where would be the error?
/* Make a program that receives two integer values, one of lower limit and the other of upper limit. Its function must print all values in the closed range defined. */ int main() { int max, min, n;…
casked 5 years, 10 months ago Guilherme Völker 11 -
1
votes0
answers174
viewsMake file and build on the terminal
I need my Makefile to run on the terminal so that it is not necessary to insert on the terminal $ time make run, and yes only make run, and let it show execution time in the same way. Can someone…
-
1
votes2
answers91
viewsIs it possible to assign the first column of a row of a/a vector/matrix?
taking as an example a two-dimensional vector of the type char 2x2: char vet[2][2]; Is it possible to assign to the first line indices of this vector? or they work like a pointer to the other rows…
-
1
votes1
answer2701
viewsOn what occasions should I use an unsigned char or a char in C?
Recently I’ve been reading a little bit about the difference between a char and a unsigned char. I was able to understand the basic difference between the two, however, I didn’t get the idea behind…
-
1
votes0
answers36
viewsI need to relocate my vector to every new entry, any ideas?
Implement a program that requests a sequence of values to be stored in a dynamically allocated vector and reallocated to each new entry. #include <stdio.h> #include <stdlib.h> int main…
casked 5 years, 10 months ago Bruno Santos 21 -
1
votes1
answer1574
viewsBalancing of parentheses
I am doing a C programming activity involving TAD and STACK. The purpose of my activity is to make a library (pilha.c) using only the functions of pilha.h. In the lisp.c, I must make my program…
casked 7 years, 2 months ago Lucas Arkantos 21 -
1
votes1
answer130
viewsSeg Fault using strcat and strcpy
This is my code: char CodificarCesar(char *texto_nao_codificado[256], int chave){ char…
-
1
votes1
answer3516
viewsSort a matrix in C
I’m trying to sort an array in C. The logic I used would be to create an array size, copy the values there, sort the values and then copy them to the array again. To do this I use a function that…
casked 7 years, 2 months ago Diego Soares 403 -
1
votes2
answers672
viewsAllocation overflows memory in recursive function in C
I created a program that keeps allocating 4 in 4 bytes of memory successively through a recursive function: #include <stdio.h> #include <stdlib.h> #define BUF 2 void overflow(int…
-
1
votes3
answers141
viewsIsolate processor to run only my program
It has as I isolate the processor to run only my program in C? It’s more of a didactic and scholarly question that my I.A teacher passed on to me. He asked us to perform millions of operations to…
-
1
votes2
answers333
viewsSingle variable declaration for scanf
I already know how to declare a variable in the traditional way using the scanf(), but I’m thinking of a way that I can use fewer lines and make the code more organized (that’s what I tried with the…
-
1
votes1
answer159
viewsRepeat(while) structure conversion in C to Assembly mips
Suppose that i and kcorrespond to the registers $s3 and $s5, and the basis of array save is in $s6. What code Assembly MIPS corresponding to that code segment C? while( s a v e [ i ] == k ) i += 1 ;…
-
1
votes2
answers1023
viewsReading on the same line
I have a struct to define the type DATA. typedef struct data { int ano, mes, dia; }DATA; DATA nasc; Now, I will read this information from the user input. printf("Digite sua data de nascimento");…
-
1
votes1
answer90
viewsAlgorithm bugs that encrypt text
I’m writing an algorithm that encrypts text using a word as a password, Vigenère cipher. Upper and lower case characters should encrypt, special characters and numbers should be ignored. My…
-
1
votes2
answers5665
viewsDoubt in While with two conditions
I have an exercise to do and I have a problem in while. The pro condition while end would be when it went through 20 even numbers and 20 odd numbers, but when it reaches the first condition…
casked 7 years, 2 months ago Augusto Stroligo 13 -
1
votes3
answers1665
viewsDoubt in percentage in C
The user has to give a value that would be the price of the product and a value that would be the discount When it comes to giving the ultimate value I can’t I’ve tried some things #include…
casked 5 years, 8 months ago Luiz Felipe Zimbrão 25 -
1
votes0
answers65
viewsHelp in an exercise in c
Good night. I’m doubting how and where to start the following algorithm: Write an algorithm that in c that receives a check number and writes the equivalent word. For example, the value 112.43 must…
casked 5 years, 8 months ago Alberto_Santos 29 -
1
votes2
answers826
viewsC Password Validator
I’m trying to solve the problem 2253 - Password Validator, URI, but is giving 10% wrong answer, but all my tests are working, someone can find the error? #include <stdio.h> #include…
-
1
votes1
answer121
viewsCode matching verification on a vector within a C struct
next, I created a struct struct eventos { int codigo; char data[11]; char atracao[50]; int ingresso; float valoring; }; And then I created a vector that way struct eventos ficha[5]; My goal is to…
-
1
votes0
answers71
viewsDoubt in the printing of results
The exercise asks me to print, in a file, all possible paths between n cities, where the end is always the starting point and each city is represented as coordinates (x,y). That first part I managed…
-
1
votes2
answers928
viewsSegmentation failure (recorded core image)
I’m making a program for a simple purpose: Take a sentence and turn it into a version of it with the characters of each word isolated to the contrary, as: "I’m in trouble" would become "uotsE moc…
-
1
votes1
answer2656
viewsVector Union in C
good evening. I am with an evaluative activity of the college to be delivered but I can not think of logic and solve the first activity. Can someone explain to me where is my mistake and a piece of…
-
1
votes1
answer438
viewsPrint on dynamic list screen
Staff can not perform the function of printing on the screen, could help me in this function below. void imprime_lista(Lista* li){ while (li != NULL) { printf("%d ", li -> struct amatricula); li…
-
1
votes2
answers299
viewsInserting elements in a dynamic list
I did this function, but I do not know if it is right, there is no error in the compilation, but it gives an error when the prompt that the program has stopped working. Insertion at the beginning:…
-
1
votes2
answers280
viewsProblem with pointer and array
I wanted to print the corresponding locations and values of a array using a pointer but when I ask the pointer to add the vector location to 8 (which corresponds to the 8 bits of an integer) the…
-
1
votes1
answer134
viewsA generic vector only works with pointers? Why?
Hello, I know it works: typedef struct stack TStack; struct stack { int size; int top; void **S; // <------ vai apontar para um vetor de ponteiros // tipo void*, que pode ser de qualquer tipo };…
-
1
votes1
answer510
viewsHow to turn pointer into matrix
I’m doing a program that transforms a matrix into a transposed matrix. I am using 3 functions because I want to learn how to pass parameters of arrays. The function main() calls the function…
-
1
votes2
answers305
viewsHide bombs in a minefield with ASCII 2
Using a two-dimensional matrix, create a program to implement a minefield game. To fill the matrix positions, use random numbers so that 0 represents a free position and 1 represents a pump. The…
casked 7 years, 1 month ago Pedro Joao 53 -
1
votes0
answers55
viewsProblem with my horizontal bar
I am having problems with my horizontal bar, the problem is that it is not increasing the value of the variable "Ivar" 1 in 1, is increasing 5 in 5 or even more dependent on how much I pass the…
-
1
votes2
answers1339
viewsRemove first element from a simple chained list
I would like to do a function to remove the first element from a chained list, the way I did it is only removing the first node and removing the second element. struct lista { int info; struct…
-
1
votes1
answer377
viewsFOR syntax in C
I’m new to the community, and I recently noticed in a C code, a FOR loop, with the following syntax. for(;;). Someone could explain that syntax to me. Thanks in advance.
-
1
votes1
answer168
viewsFunction removes chained list
Save everyone, I’m learning chained list in python, as I already have some knowledge of list in C hit me doubt about node removal, the basis of the algorithms I used in some exercises is this:…
-
1
votes1
answer125
viewsWhat is the difference between char (*ptr)[20] and char *ptr[20]?
I’m studying pointers and came across these statements, but I couldn’t understand it very well. Could you help me? Thank you.
-
1
votes3
answers444
viewsFactorial from 0 to 20 using For
I need to do the following exercise: "Using the for loop, calculate and print the factorial of all numbers between 0 and 20. Use Double type. Ex: 0! =1 1! =1 2! = 2 ... 20! = 2432902008176640000"…
-
1
votes1
answer656
viewsassignment to Expression with array type
I’m having an error when associating an array address on a pointer to struct, I’m getting a type error: assignment to Expression with array type The code I’m using is this: struct MaxHeap { int…
-
1
votes1
answer70
views"format specifies type" error, C language
I have the following code in C: struct crPlayList{char music[120], singer[120];float mustime;struct crPlayList *next;}; struct crPlayList *start, *end, *aux; I have a music search function: void…
casked 5 years, 6 months ago Luiz Roberto Furtuna 593 -
1
votes3
answers76
viewsHow to judge all typed numbers? Only the latter is being judged and displayed
@Edit people cannot use vectors only for, while and while :x I made this code but at the end when and to display the numbers I typed it’s only appearing the last number typed instead of all, what I…
casked 7 years, 1 month ago Gustavo Carvalho 67 -
1
votes1
answer56
viewsHow to create a function with matrix and then use it in the main int by substituting values from another matrix?
I’m wondering how to create a function where you will use the values of an int main matrix, and then how to replace the values obtained in the function matrix for the int main matrix? I was creating…
casked 7 years, 1 month ago Renan Mela 13 -
1
votes1
answer276
viewsFloating rand in C matrix
Good afternoon, I am using the Rand function to generate random numbers in a C matrix, but I can only generate integers. I would like to generate floating numbers. I did not find anything of the…
-
1
votes1
answer2223
viewsHow to view contents of a file . bin generated in c
I had to create a C program that reads a motion sensor activation file (.txt) and produces a binary file with the same information. The file . txt has the following information: 3B2 20051023…
-
1
votes2
answers841
viewsProblem with recursiveness and pointers
I am struggling to resolve the following issue: Make a recursive function that allows you to sum the even elements of an integer vector, you must use pointers to traverse the vector My code is not…
-
1
votes0
answers51
viewsOld game with Minimax does not work good
I have a problem with my code that I can’t identify. In some moments my Minimax does not make the right move in which it should prevent the user from winning. I already searched everything, but I…