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
answer53
viewsPower function returning incorrect values within the while loop
I have a function power that returns the value of a potentiation receiving the parameters n and p (n^p). Outside the loop while the function returns the correct values, but within the loop function…
-
1
votes2
answers47
viewsHow to stop receiving keystrokes?
This is a memory game and while the numbers are playing I want the user not to be able to type. **for (i=0;i<2;i++) //Exibe os números que estão no vetor numeros[] { printf ("%d\t", numeros[i]);…
-
1
votes1
answer165
viewsPointer return pointing to a local character vector?
#include <stdio.h> char *local(void); void main(void) { char *ponteiro = local(); printf("%s\n", ponteiro); /*Saida = - (*/ } char *local(void) { char nome[12] = "programador"; char *ponteiro…
-
1
votes1
answer147
viewsSwitch command does not work and shows no errors
I’m trying to solve the following exercise: Devise an algorithm that assists in controlling a cattle farm that has a total of 2,000 head of cattle. The database consists of a set of structures…
-
1
votes2
answers2198
viewsProgram Ignoring the Scanf
I need to create an algorithm as requested below, but every time I run the program it "skips" steps. For example: I want you to stay like this Product: "Potato" Sector: "Food" Quantity: "15" Price:…
-
1
votes1
answer211
viewsPointer Statement in a struct and calling it in function
I must solve the following problem by creating a function for reading, one for calculation and using pointers. #include <stdio.h> #include <stdlib.h> #include <math.h> struct ponto…
-
1
votes1
answer135
viewsGraphs - return a pointer to the adjacency matrix
I am implementing a work of Graph Theory that deals with the game Flood-It which is a problem in flooding in Graphs. I’m right at the beginning and implemented the graph structure yet. The structure…
-
1
votes1
answer65
viewsPrintar value of a struct by pointers
I want to print the "attribute" name of a "Person" type struct, but the printf returns (null) but I declare the struct name. Follow the code below: typedef struct pessoa{ char *nome; struct pessoa…
-
1
votes1
answer2329
viewsSort a student list by name in alphabetical order
That’s what I thought: Aluno *ordenarNome(Aluno *aluno){ Aluno *aux; Aluno *aux2 = (Aluno*)malloc(sizeof(Aluno)); Aluno *aux3 = (Aluno*)malloc(sizeof(Aluno)); Aluno *aux4 =…
-
1
votes1
answer275
viewsdynamic reallocation - struct array
I need to do an exercise where the code allocates the memory as needed, but I need to reallocate an array of struct, only I ended up locking in this part. My Struct is: typedef struct{ char…
-
1
votes2
answers113
viewsQsort ordering in the wrong way
My activity is to read a sentence and ordered in alphabetical order, but is giving error #include <stdio.h> #include <stdlib.h> #include <string.h> int ordena(const void * a, const…
-
1
votes0
answers177
viewsCode Issues in C Chained List
I’m having a problem with a C code. I’m trying to open a txt file that has movie name, year , actor,... And I’m putting the movies on a chained list. The problem is at the time of sorting the movies…
-
1
votes1
answer132
viewsDoubt about chained list in C
Hello, I made a simple chained list in C, with the insert start and insert functions at the end, as I do the removal functions? #include <stdio.h> #include <stdlib.h> typedef struct no{…
-
1
votes0
answers138
viewsPointer array in which each element is a row
Hello. I wanted to create a pointer array in which each element pointed to a supposed queue, but when I try to access the (pointer vector) -> (TAD queue) -> (vector inside the queue TAD), I…
-
1
votes1
answer79
viewsWhat is wrong in the double variable
I need to make an algorithm that the user informs two values and return the biggest among them using double, but when compiling it from the error pointing something in double but do not know how to…
-
1
votes2
answers52
viewsHow do I display the values of a matrix one to one in C? example: line 1: 1.2 line 2: 3.4 line 3: 5.6 " " " " " " " """
example: linha 1: 1,2 linha 2: 3,4 linha 3: 5,6 " " " " " " " " " " follow what I’ve done so far: #include <stdio.h> #include <math.h> #define max 50 int main() { int…
-
1
votes1
answer113
viewsSyntax errors in C
I’m doing this exercise in C, but I’ve locked into this part of passing parameters with pointer. Basically the program below sums up the share of real numbers and integers. The problem is that the…
-
1
votes1
answer1197
viewsHow to do searches in txt files in C?
I’m a beginner in programming, and I have a paper due in college. In it I have to register clients using files, and then do a search in the file and print on the screen the data of the registered…
-
1
votes1
answer64
viewsRead and split C files
I’m doing a project for the college, the code already reads the files and divides the lines taking into account the ";", how can I save these tokens in variables? struct informacaoFicheiroInput{ int…
casked 6 years, 6 months ago Bruno Bacelar 55 -
1
votes1
answer123
viewsProblem with socket C
Good afternoon to you all! I am doing academic work on Sockets in C Language, in which I need to create an MP3 file transfer program in Windows. In it I have two programs, client and tracker, in…
-
1
votes1
answer375
viewsHangman game problem in c
all good? I am creating a hangman’s game in C and I am facing 2 problems. The first is the defeat condition I created. Even if the user types a certain letter, the program gives the answer as right…
casked 6 years, 5 months ago Rodrigo Springfield 11 -
1
votes0
answers91
viewsBinaria tree with 3 pointers has special treatment?
I am setting up a hospital program and the order of the patients will be by a binary tree, taking into account a degree of urgency existing in the patient struct, as shown below. My question is: Do…
-
1
votes1
answer856
viewsWhat causes the error "(.text+0x5b5)Undefined Reference to 'printf'"?
#include <stdio.h> #define MAX 100 #define INVALIDO "Operção Inválida!\n" #define IDENT "A matriz é identidade\n" #define NAO_IDENT "A matriz não é identidade\n" #define SIMETRICA "A…
-
1
votes0
answers113
viewsRecursiveness - Why am I entering a loop?
I’m trying to implement an algorithm called Minimax, but I’m finding problems in effecting its recursion, it goes into a loop that I can’t identify why. The depth of the algorithm should vary…
-
1
votes3
answers407
viewsCheck if a string is composed of digits
I want to check if my strings (which are stored in an array), are integer or not for example a for the fourth row of the matrix have the following code. #include <stdio.h> #include…
casked 6 years, 5 months ago Bruno Bacelar 55 -
1
votes0
answers66
viewsNodemcu does not receive the data as I send via UDP Protocol
I am developing a simple application, the goal is to simply send the reading of a sensor connected to an Arduino Nodemcu to a Raspberry PI, and perform a similar reading using Raspberry and send to…
-
1
votes1
answer511
viewsArithmetic error from 20 decimal places in C
I’m solving Uri Online Problem 1120. The problem is given a number D such that 1 D 9, and a number N such that 1 N < 10¹ I remove all occurrence of D in N. Examples and test cases: Entrances: 5…
casked 6 years, 5 months ago Thiago Soares Mota 316 -
1
votes0
answers141
viewsHow to use dates in C?
I wanted to know how to implement the library time.h The application must identify the customer, the start and end date of the rental, and the price paid for the rental and the date paid. We have…
-
1
votes1
answer591
viewsStruct declaration and initialization outside the main function in C
I’m playing a little game in C that has the card structure: typedef struct { int numero; int cor; } TipoCarta; A method to put the values in the chart: void inicializaCarta(TipoCarta *carta, int…
-
1
votes1
answer52
viewsSorting an unordered list does not work
The code works until the part I have ordered a list already created using a new list, only I can not identify the error. That’s when I created the functions Ordain and Addordenado that started to go…
-
1
votes2
answers99
viewsHow to have a cycle interval, up to n and up to 0
In a validation function that passes the tests all will return 1, and if you enter one of the conditions will give return to 0. I want to cycle until the line breaks, so I’m using the interval:…
-
1
votes3
answers107
viewsHelp with string programming logic?
I’m new to this string area and I’m having a hard time. My algorithm should find and return the first time of the key(which the user enters) in the string, otherwise -1 must be returned. q is wrong…
-
1
votes0
answers144
viewsRemove() and Rename() functions do not work!
Hello, I’m doing a program on has a part of it that should delete a client and the data of such that are in a file . txt! So far so good, I create a new file with a different name that copies all…
casked 6 years, 5 months ago Renan Maia 11 -
1
votes1
answer457
viewsprint a string array
When I do a print on my string matrix a symbol is appearing and not the words. The matrix is located in the void query function. I put all the code because it might be a mistake somewhere else but I…
casked 6 years, 5 months ago Igor Vargas 274 -
1
votes1
answer1897
viewsSplit the program with libraries . c and . h
Friends, I just made a program to calculate the transposed matrix. My question is: how can I turn this program into a function, so that I have two more files (one .c and one .h) besides main. c?! I…
-
1
votes1
answer470
viewsDelete a struct record using free()
I’m creating a record using struct, where I must have a menu to include, show and attend (exclude) patients. The problem is in the exclusion function that because of my lack of knowledge I do not…
-
1
votes1
answer2674
viewsMatrix multiplication and storing in another matrix?
is a function that receives three integer matrices A, B and C, and two whole n and m representing the number of rows and columns of these matrices. This function shall calculate the multiplication…
-
1
votes1
answer640
viewsError: Conflicting types for 'first'
I made a function where I pass as argument two integers and two pointers of two struct that I created in order to write the Return in a txt file. When running the program, if I give printf() to the…
casked 6 years, 5 months ago Rodrigo Marcelino 13 -
1
votes1
answer92
viewsHow do I store data in a structure and then use it in different functions?
Guys I’m trying to schedule this work for days and I can’t get out of the corner, it’s a library system that in turn needs: a) Register, view, change and remove data from a book; b) Register, view,…
-
1
votes0
answers78
viewsC Array of Sockets
I am studying in C and I am creating a program that exchanges messages between pc’s in client/server style. Created an array of sockets and threaded them. int main () { pthread_t *servidor =…
-
1
votes0
answers56
viewsGraph represented as list linked to list
I am trying to implement a graph with list structure linked to list by pulling the data from a txt file (input.txt). A 100 2 B 3 D 4 B 150 2 C 3 E 2 C 150 1 F 2 D 150 1 E 4 E 100 1 F 1 F 200 0 The…
-
1
votes0
answers85
viewsFunctions in File C
I’m doing a job that lists players and performs some functions using File on link C and I need the program to list in option 2 the player by name and in 3 by shirt number. My code so far: #include…
-
1
votes2
answers95
viewsList item causing error in C program
Good evening, everyone. I’m having trouble with a simple code for a college job where I can’t figure out why the bug is wrong, since Dev-C++ does not report any errors. To prevent someone from my…
-
1
votes0
answers56
viewsProblems when deleting an element from a list within another chained list
I’m having a problem removing an element, I have a function that is responsible to delete the element within double-chained lists. How it works? In the main function is called the name of an…
-
1
votes0
answers153
views(c) Sort Struct Matrix
Good to all! I have a little problem that I can’t solve and I seek help from the members. In my code, I read the contents of a file and save in a string for use in the code, in the main loop, I…
-
1
votes2
answers257
viewsMystery Square
The integers positioned on an Nxn square such that all lines and main diagonal have the same sum. For example, the square below 2 7 11 9 5 6 4 3 13 is a mysterious square of sum 20, since all lines…
-
1
votes3
answers6645
viewsUnion of two vectors in C
I need to perform the union of two vectors, resulting in a third vector: a[5]={1, 2, 3, 4, 5}, b[5]={6, 7, 8, 9, 10}, c[10]; else if (select_menu == 4) { int select_f4, i, j, x; printf("Esta é uma…
-
1
votes2
answers74
viewsPrinting bug
Someone could answer me because in Cpf is printing the value 6422276 ? #include<stdio.h> #include<stdlib.h> typedef struct{ int dia; int mes; int ano; }data; typedef struct{ char…
casked 6 years, 4 months ago user114629 -
1
votes2
answers332
viewsRecursive program doubt for writing vowels in C
Make a recursive function written in the C programming language with two parameters: a string and the initial position that should be considered in the search. The function must write the vowels…
casked 6 years, 4 months ago william petry 11 -
1
votes1
answer72
viewsHow do I create a CSV in C by incrementing the first number?
I ran that csv: 1;0 2;0 2;0 2;0 2;1 2;2 2;2 2;2 2;2 2;3 ... How to get from this file the first number of each line to increment it? And there’s like the first line not to be skipped? int…
casked 6 years, 4 months ago Felipe Santos 96