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
answer23
viewsTCP server with select(), does not work because printf shows 3x to msg and msg comes with trash at the end and ends automatically
void cria_server_tcp(int porto) { struct sockaddr_in serveraddr, clientaddr; int fd_listen = cria_socket_tcp(); int max_clientes = 20; //numero maximo de clientes em espera int addrlen; int…
casked 7 years ago Frederico Maia E Moura 3 -
0
votes0
answers404
viewsWhat is the reason for a Runtime error in this code?
I have an exercise to do and submit it to an automatic broker (Sharif), in my tests all cases work out, but in the broker I’m receiving a Runtime Error, I’ve reviewed this code many times and I…
-
0
votes2
answers1230
viewsHow do I return only the highest value within an array?
It does not correctly check the largest. For each animal it shows the weight of the animal as being the largest. #include <stdio.h> #include <stdlib.h> #include <string.h> #include…
-
0
votes1
answer1626
viewsdouble free or corruption(out) - Dynamic Allocation in C
In the discipline of Data Structure in college, as an exercise, the implementation of an algorithm that manages the transposed matrix of a given dynamically allocated matrix was passed. I made the…
-
0
votes0
answers15
viewsI need help finding an error in a program
[ in this image is the program code, DEV C++ pointed errors on line 5 and line 6 as shown in the pictures below I’ve tried everything but I can’t find the error…
-
0
votes1
answer42
viewsDetermine the position where the highest value rise occurs in an array
Boa am doing the following exercise in C language I made the following code and I don’t understand why it’s not working... int maior_subida(int *tab, int dim) { int i, pos=0, diferenca=0,…
-
0
votes1
answer53
viewsHow to decrease, except a number of the other value?
In the final value was to have the total of notes greater than 7, another condition would be that the user has to enter a number between 0 and 10, then any number outside of it would give "invalid…
-
0
votes1
answer70
viewspass a struct using extern C on a . dll c++
I have a function that comes from a . lib that returns me a struct tabela GSTV(vector<double> inpA, vector<double> inpB); this struct is defined as follows:: struct tabela {…
-
0
votes2
answers82
viewsHow to work with binary data
I have a function in C that takes two bytes one with higher significant value (msb) and the other with lower value (lsb) and then converts them to decimal. int get_pea(char *buffer) { char lsb[8],…
-
0
votes1
answer796
viewsRead file and sort words alphabetically (with removal of special characters)
I’ve been trying to find the mistake for a while, but I’m not getting it. The program consists of reading a . txt file with the contents below, for example: home-orange, otolaryngologist flower…
-
0
votes2
answers81
viewsProblems in C algorithm
Can anyone tell why the program simply closes when I type the The? #include <stdio.h> #include <locale.h> //Biblioteca locale é uitlizada para definar o idioma do programa. int main() {…
casked 7 years ago Thiago Henrique Domingues 167 -
0
votes1
answer82
viewsHow to omit space to insert only numbers in different lists
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct NBIG{ int numero; struct NBIG *nseg; struct NBIG *nant; }Nbig; int main(int argc,char *argv[]) { char…
-
0
votes1
answer68
viewsAccessing the allocation causes program to stop working
I’m having a problem accessing a subscriber struct typedef struct Inscrito { char nome[50]; float cadastro; float nota; }; Inscrito *inscritos = NULL; it is as a global variable and every time I…
-
0
votes1
answer46
viewsHow to write two unsigned char variables in c
I’m having trouble writing two variables of type unsigned char using scanf, only the second value is saved in variable, I imagine it is buffer with garbage tried to treat and even so did not…
-
0
votes1
answer51
viewsWhy use a pointer to struct instead of the struct itself in this case?
Why, in the struct GERENTE and CLIENTE, I have to use a pointer to the struct PESSOA and not the struct PESSOA typedef struct{ char* nome; int cpf; } PESSOA; typedef struct{ PESSOA* pessoa; int…
-
0
votes1
answer33
viewsHow to pass char matrix as parameter?
I’m doing it wrong. Gosaria to know how could pass this array of names to work on the function? void primeiro_ex(int *lista,char **nomes){} void main(){ int notas[60]; char nomes[60][60];…
casked 3 years, 8 months ago Matheus Pimentel Pilotto 11 -
0
votes3
answers95
viewsIdentify a specific word in a C++ String, is there a function ready for that? Or just in the nail itself?
Hello, I’m getting a series of strings(lines) from a . txt file and putting them into a vector. But there’s a problem, strings come with an unwanted start, example: Depende: lsb-release Depende:…
-
0
votes1
answer61
viewsfind repeated values in the vector in c
I need to create a code that given a number vector it needs to check where it contains repeated values and subtract 1 in the size of the vector whenever it finds, but it is giving time limit error…
-
0
votes0
answers24
viewsWould you like to learn about the operator "," in C and C++?
I will put the example of a code I saw below: while(scanf("%d %d %d %d", &h, &u, &d, &f), h) {... } the input stopped when h received value 0.
-
0
votes2
answers40
viewsHow to pass the value of a variable char to another char in C
My doubt is how I successfully pass the text from one char variable to another also char? I’m trying the following: salva_nomeMaior[30] = dados[i].nome; The variable that is with the text that is…
-
0
votes0
answers22
viewsC: How to read an indeterminate number of integers on the same line that still recognizes n?
I need to read an indeterminate number of integers on the same line to pass to a chained list, however in case no number is entered(" n"), I still need to recognize it to treat it. there’s some…
-
0
votes1
answer71
viewsWhy does the function leValidaText return trash?
I’m trying to validate the license plate of the car, but I’m not getting it. I tried to use the scanf instead of fgets and nothing. I have no idea what might be causing the problem. #include…
-
0
votes1
answer35
viewsCall to the system dup2 vs. write&read
I have a doubt in understanding why in some cases there are examples of conversations in the parent process and the child process - obtained through the call to the Fork system ( ) - which use read…
-
0
votes1
answer515
viewsPass pointer array to function
I need some help with this exercise. I did the whole exercise and runs well only that in the end gives error because of passing the address of the matrix to the function. What’s the problem here?…
-
0
votes0
answers15
viewsI’m having trouble storing an integer
#include <stdio.h> int main() { unsigned long long num = 1073741824; printf("num: %d\n", num); printf("num * 2: %d\n", num * 2); printf("num * 4: %d\n", num * 4); return 0; } With this code…
-
0
votes0
answers19
viewsHow to solve/finish this string exercise?
Code I’ve made so far: int main() { char string[100], c; int removidas; fgets(string,100,stdin); scanf("%c", &c); removidas = funcao(string, c); printf("Numero de remocoes: %d\n", removidas);…
-
0
votes1
answer61
viewsMy program is not adding up the data it receives. Program in C
I need to do a program that: Get the pc model, its price and display the highest value, plus the amount of computers without peripherals. In the main function, receive the amount of peripherals. A…
casked 7 years ago Matheus Coelho 31 -
0
votes1
answer85
viewsBecause in this case I had to use freopen?
I have the following code: #include <stdio.h> int main(void){ FILE *ptr_file; ptr_file=fopen("archive.txt", "r"); short size=0; char c; while(!feof(ptr_file)){ c=getc(ptr_file); if(c=='\n'){…
-
0
votes2
answers1519
viewsHow to compare two chained lists in C?
Guys, I have a problem with this issue: -I have to compare two chained lists and return 1 if they are equal or 0 if they are not. The function is like this and I can’t progress: struct Node { int…
-
0
votes1
answer119
viewsChange string using function parameter
#include <stdio.h> #include <stdlib.h> #include <string.h> void menu_principal(char* monstro1, char* monstro2){ int escolha; char monstro[20]; printf("King of Tokyo\n\n");…
-
0
votes0
answers16
viewsFloat in C changing value
I’m having a problem when declaring a variable float and assigning a value, this assigned value is changed in the execution of 273.15 it gets 273.149994 need it to continue as 273.15 someone has…
casked 3 years, 7 months ago wellington Machioni 1 -
0
votes0
answers12
viewsHow to move multiple folders from one directory to another in C#
Good morning I already have a notion of how I will move 1 file or 1 folder at a time in C# to different directory but I am not able to do when it is a large group of files or folders and the idea is…
-
0
votes1
answer131
viewsShell in C: Segmentation error and execve function, what’s wrong?
#include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <sys/wait.h> void…
-
0
votes0
answers42
viewsgiving error in the places where have comments and I do not know the reason
#include<stdio.h> #include<stdlib.h> #include <string.h> struct pessoa{ char nome[100]; }; typedef struct pessoa Pessoa; struct funcionario{ Pessoa f; char cargo[120]; float sal;…
-
0
votes1
answer71
viewsProblems with Decode and Arduino
Hello, People I have the following code on Arduino if((digitalRead(4) != 1)||(digitalRead(5) != 1)) { Serial.print("\t"); Serial.print(analogRead(A0)); Serial.print(","); Serial.print(millis());…
-
0
votes0
answers1029
viewsHow to convert from Hexadecimal to binary
Good actually I got in brute force wanted to know, there is another way to do my code mathematically #include <stdio.h> #include <string.h> int main(int argc, char** argv) { char…
-
0
votes0
answers26
viewshttprequest with Curl in C returning values
Hello to all who are reading. I am trying to create a code from a simple file md5 hash validation with my web server. Basically I want to send the hash and if it is the same registered in my web…
-
0
votes2
answers1770
viewsHow to scroll through a chained list from the last position?
I have a question about a chained list in C. The exercise is a function that takes as parameter the initial node of the chained list and the position x (counting backwards). With this, I have to go…
-
0
votes0
answers33
viewsIs it possible to buffer overflow these examples?
I was looking for how string "n" functions work and I ended up finding a lot of confusion, so I was wondering if in these examples there is any chance of an overflow // exemplo 1 #define BUFFER_SIZE…
-
0
votes0
answers9
viewsdifficulty in using while
I started language in C but am having difficulty in while for a program where I need to enter 3 options to be typed and when one of them is out (negative) for the program
-
0
votes0
answers674
viewsHow to create QUEUE by passing STRUCT
I am trying to create a code in which I will insert 10 candidate names in a queue using a C structure. But I don’t have much knowledge in C data structure. I did it this way: #define TAM 5 #include…
-
0
votes1
answer69
viewsPrint student grades in a matrix
I wanted to print all the notes at the end of the program, but I’m not getting it. Ex: Aluno 1: Nota 2 Aluno 2: Nota 4 etc... #include <stdio.h> #define resp 3 #define nota_aluno 3 int main()…
-
0
votes1
answer48
viewsWhy does multiplying the percentage give negative results?
#include <math.h> #include <stdio.h> #include <stdlib.h> main() { float altura,peso,soma_altura=0,cont1=0; int idade, cont=0,i; for(i = 0; i < 25; i++) { printf("Insira sua…
casked 7 years ago Juarez Prates 3 -
0
votes1
answer22
viewsProgram for when a structure statement occurs at different locations
Follow the source code... #define _WIN32_WINNT 0x0501 #include <stdio.h> #include <ws2tcpip.h> #include <winsock.h> #include <windows.h> WSADATA data; struct addrinfo tips,…
-
0
votes1
answer671
viewsSort matrix of n rows using the column value in C as a criterion
I have the following code : int** ordena(int **v, int tam) { int i, j,aux; int swap[3]; for (i = 0; i > (tam-1); i++){ aux = i; for (j = (i+1); j > tam; j++) { if(v[j][1] > v[aux][1]) { aux…
-
0
votes0
answers45
viewsHow could I arrange this code for it to print the numbers of the vector increasingly?
//Questão 4 #include <stdio.h> #define TAM 10 int main() { int i, valorVET, VET[TAM]; printf("Digite os 10 numeros:\n"); for(i = 0; i < TAM; i++) { scanf("%d", &VET[i]); } for(i = TAM -…
-
0
votes0
answers91
viewsLetter comparison
I managed to make a letter typed by the user, be shown another Example: c returns A, because the letter A is the one that uses our alphabet the most. So I can unravel a message for example, because…
casked 6 years, 12 months ago Henrique M 87 -
0
votes1
answer656
viewsConvert recursive to iterative function
I have a chained list merge function working. However, recursion is being used and I would like to change the code and iterate. But I was unsuccessful. Follows the code: struct Node { int data;…
-
0
votes1
answer57
viewsWrong output in C
I’m doing an activity and the result is giving some values that I don’t assign anywhere in the code. int main(){ int numeroDePessoas = 0, tarefa = 0; scanf("%d %d", &tarefa,…
-
0
votes1
answer105
viewsError when printing string
#include<stdio.h> int main(){ int numero,unidade,dezena,centena; char *unidades[]={"I","II","III","IV","V","VI","VII","VIII","IX"}; char…