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
votes2
answers1096
viewsHow to count how many substrings you have in a C string?
https://www.urionlinejudge.com.br/judge/pt/problems/view/2126 This exercise I thought better read as string or not... #include <stdio.h> int main(void) { char N1,quantidadesdeN1;…
-
0
votes1
answer202
viewsChange a char array within a function
I am trying to pass a char array pointer to a function. I want it to make changes to this char array. Follow the function code: void dhnfe( char tzd, char hverao, char *dh) { if (hverao == 1) {…
-
0
votes1
answer442
viewsStructs vector for function
I’m having a problem passing a vector of structs for a function that checks whether an entire code entered by the user has already been used. #include <stdio.h> #include <stdlib.h>…
-
0
votes1
answer173
viewsudp server does not receive message from udp linux client
Well, I was programming a simple messaging system,when I tested it on the same computer,it worked properly without any problems,but when I tested it on two different computers,? client code #include…
-
0
votes1
answer135
viewsscanf does not stop at a loop
int main(){ char texto[1000]; do{ scanf("%[^\n]", texto); if(!fakeEquals(texto)){ if(palindromo(texto)){ printf("SIM\n"); }else{ printf("NAO\n"); } } }while(!fakeEquals(texto)); return 0; It is a…
casked 6 years, 8 months ago Victor Harry 9 -
0
votes2
answers242
viewsCode::Blocks does not print pointer value
I developed a C code to print the value and address of the variable x using a p pointer, but Code::Blocks does not print the values. #include <stdio.h> #include <conio.h> int main() {…
-
0
votes1
answer43
viewsBreakpoint in Looktree paid function (Binary trees)
Boas, I have an error in the Lookuppaid function, when I try to delete a value from the binary tree nothing happens and if I try to delete the root of the tree I get the following breakpoint:…
-
0
votes2
answers85
viewsSegmentation Fault with malloc()
In one part of my program I need to create a vector full of zeros the size of the user’s interval: scanf("%ld %ld", &n1, &n2); int *vetor; vetor = malloc((n2 - n1 + 1) * sizeof(long int));…
-
0
votes1
answer165
viewsPrint memory available in C
How to know the amount of memory available before doing the malloc()? I would like to print the memory value that is still available in order to be allocated, the code has to run on Windows and…
-
0
votes1
answer1118
viewsDecimal to binary conversion in C language using ASCII table
I have to make a program that reads some characters and "transform" each character into its corresponding number in the ASCII table and then turn that number into binary and store it in an array. My…
-
0
votes2
answers71
viewsWhat’s this Arduino code doing?
I need a description of what he does. if( ! digitalRead(sensor1)) { speed1 = frente; speedv1=0; } else { speed1 = 0; speedv1 = voltar; }
-
0
votes0
answers44
viewsError comparing a code in C
I am starting in C learning and am having trouble with the following code: ` float piValue; float userAnswerPI; char userAnswerYN; piValue = 3.1416; printf("What's the value of PI?"); scanf("%f",…
casked 6 years, 7 months ago Eduardo Dutra 183 -
0
votes1
answer675
viewsMultiply n numbers in c
What reason does my code, regardless of the numbers typed multiply with the number I put in order for the loop to be false? I just wanted to multiply the values I typed and not multiply the number…
casked 6 years, 7 months ago Vitor Gonçalves 552 -
0
votes1
answer681
viewsDelete record in text file
I am making a program that consists of recording movies/series, modifying information and deleting specified records. I’m having great difficulty in designing the functions of rule out and modify…
-
0
votes2
answers53
viewsWhy am I having trouble with C-scanf?
Hi, I’m trying to do a very basic cmd, but I’m having problems... My code: #include <stdio.h> int main() { char arg[300]; scanf("print '%s'", arg); printf("%s", arg); fgetc(stdin);…
-
0
votes1
answer219
viewsHow to store the distinct elements that occur in another vector?
In the vector below 300 elements, I need to store the distinct elements that occur in another vector called values. Then I have to record how many times the i-th value of the vector values occurs in…
casked 7 years, 9 months ago Jonathan Galdino 1 -
0
votes2
answers99
viewsI’m having trouble reading a string inside a function
Good evening, I would like to know methods to read a string in C(Version C99), I have tried a lot, and does not work, below, the defective code. Obs: The error that reports is that just after…
-
0
votes2
answers1521
viewsTest for prime number
#include <stdio.h> #include <stdlib.h> #include <locale.h> int main(void){ setlocale(LC_CTYPE,""); int num; int divisor = 2; int primo = 1; // se primo = 1 é primo // se for primo…
-
0
votes2
answers414
viewsWhat is the code to print only the first number of a value? ex: only the 8 of 8372883
#include <stdio.h> int main(){ int a, b, c, d; printf("Insira um numero de quatro digitos: "); scanf("%i",&a); b=a%10; c=a%100; d=a%1000; …
-
0
votes0
answers73
viewsMy code stops working after it runs integer
I’m programming an exercise for my college and I have to do a String Matching code in KMP, so so far all right I did the whole code, tested some entries, when I went to test the teacher’s inputs…
casked 7 years, 9 months ago Brenno Migliari 1 -
0
votes0
answers118
viewsSegmentation fault (core dumped) in matrix data scanf
This following piece of error code, does not read user data to allocate in 5x2 matrix, can not find the problem int linha=0, coluna=0; int matriz[5][2]; for(linha=0;linha < 5; linha++){…
-
0
votes0
answers42
viewsProblem String Language C
I can’t understand why the program doesn’t run the check. Can someone help me?…
casked 6 years, 7 months ago Jean Beaumont 1 -
0
votes1
answer1522
viewsChange number of digits after comma depending on the situation
I know I can get a limit of digits after the comma with %.2f for float and %.2lf for double. How can I change this limit depending on the occasion? For example: Get a two-digit limit with float that…
-
0
votes1
answer54
viewsInfinite loop in height growth analysis
Gustavo is 1.40 meters and grows G centimeters per year, while Juliano is 1.10 and grows J centimeters per year. My show is giving a loop infinite when I run. #include<stdio.h> int main() {…
-
0
votes1
answer251
viewsPrint a queue item by removing each item from it
I’m making a program that receives a string with words separated by comma that separates these words and lines them up (Until then I was able to do it quietly), then the program has to go removing…
-
0
votes2
answers560
viewsHow to use argc and argv on a windows terminal?
I am creating a stack for valid expression check, but it should be used in this int main( int argc, char **argv ) for input. I compiled and did not make a mistake, but I cannot create an executable…
-
0
votes1
answer31
viewsHow to use struct member variable to preset matrix size
I wonder how to pre define the size of an array within a shape struct: struct exemplo{ int l; int c; int matriz[l][c]; }; compiler claims that l and c on the matrix line is not declared here.…
-
0
votes1
answer4468
viewsMean numbers of a matrix in C
I need to create a program that will build me a matrix and give me back the media of your numbers. I already have the matrix built but I can’t average the values. The code I already have:…
-
0
votes1
answer174
viewsHow to replace/optimize multiple ifs in C?
I’m a beginner in C language, I’m doing an activity that is to register students and averages in a double-chained list, everything is working, however I believe I’m using too many ifs, there is some…
-
0
votes1
answer508
viewsHow does a chained list work in C?
I’m doing a job for college and I still don’t fully understand the logic behind a chained list in C. I need to log in, name and value in a record, of which I created a struct (set of variables); I…
-
0
votes0
answers42
viewsHow do I declare an integer with a storage capacity of 30 bytes?
My question is the following: I know that the Python language interpreter is done in C. In Python the numerical variables have no size restriction, that is, the more we add value to variable, plus…
-
0
votes3
answers694
viewsThe code skips the fgets, not reading the word
The program is not reading mine fgets() getting there he jumps. #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { float altura, peso,pesoidealm,pesoidealf;…
-
0
votes1
answer334
views -
0
votes0
answers126
viewssocket in c error sending numbers from client pro server tcp
my first time here, I need a light , I have a server written in c that is a calculator and this on a machine, the client q runs on another machine takes the two numbers and the operator q the user…
-
0
votes1
answer43
viewsUse of library in different S.O
Guys,have been developing some projects in C but at a certain time there was the need to use the library "Windows. h". So far so good, the problem is that I develop with Linux and researched about…
-
0
votes1
answer228
viewsHow to remove the first node from a list?
void Inserts (List* list){ DadoNo dado; int p = list->size; No* n = (No*) malloc(sizeof(No)); n->ant = list->head; scanf("%s", dado.nome); if (Busca(list, dado.nome) == NULL){ n->dado =…
casked 7 years, 8 months ago Paulo Bomfim 17 -
0
votes2
answers194
viewsDifferent errors in C code on different compilers
In the following code below there is an error that the Lccx86 compiler for Windows claims to exist, but I copied the codes from a C class I am watching. Class link, for those interested In the C…
-
0
votes1
answer51
viewsGenerate an error if the code entered by the user is not a valid value
I have the following code snippet: //Pedir para entrar com o código enquanto for menor ou igual a 0 do{ printf("Entre com o codigo:"); scanf("%i",&CODAUX); }while((CODAUX <= 0)) ; //Pedir…
-
0
votes0
answers72
views"Member access Within misaligned address" with a chained list
I’m solving a problem with leetcode (add two numbers that are inverted, each digit in a node of a chained list and return a chained list as a response). When giving Submit in the reply I get the…
-
0
votes1
answer29
viewsSearch for minor in log(n)
Hello. I am in need of an efficient data structure to search for the lowest value of a disordered vector, being that: The vector cannot be ordered. The vector should be able to update the values in…
casked 6 years, 5 months ago hikoruKazuto 43 -
0
votes1
answer51
viewsSegmetation fault error - Problem in main code for inserting nodes in binary tree
I am making a program that reads records and saves these records in a chained list and in a binary tree. However, I am not able to save the nodes in the binary tree by showing a segment fault error.…
-
0
votes1
answer1043
viewsSegmentation failure (recorded nucleus image)
I’m doing a college job, I did the code, it’s working normally on windows. In Ubuntu it is compiling, when I start using the Inserts function, it gives this error that is in the subject. Just follow…
casked 7 years, 8 months ago user86427 -
0
votes1
answer237
viewsSet uint8_t to int
I am receiving data and in my project storing in an array of uint8_t and then processing in variable int, it’s okay that I could leave everything int but this does not apply to the project. int…
-
0
votes1
answer629
viewsHow to pass information from a file to a dynamic vector of C structures?
Good afternoon! (EDITED) I’m doing a language work C, where I have to show on the console the information stored in a text file, but it is mandatory to pass all information to vetores structural…
-
0
votes0
answers21
viewsCode does not execute a second " var = getchar(); " if an if is true
Why the code below does not allow me to fill in the 'ext' variable if the established condition has been accepted? #include <stdio.h> #include <stdlib.h> void main(){ char ext; char dif;…
-
0
votes1
answer35
viewsTree b is partitioning the wrong node
I’m having trouble with the b-tree structure, it’s misporting the node and it’s missing some keys. I honestly don’t know what I did wrong. #include <stdio.h> #include <stdlib.h> #define…
-
0
votes2
answers194
viewsMatrix vector of records
In the classroom, students were asked to replicate a scheme designed by the teacher. In this scheme he made a vector, within each position he made a matrix and within each position of the matrix he…
-
0
votes1
answer102
viewsSubtleties between Python and C
Good night! Sunday I discovered that I must learn Python, that the subject I will attend will be in that language and there is no way out. I studied well this week and managed to get to matrices,…
-
0
votes1
answer24
viewsValgrind in the eclipse
I’ve been looking for it for a while and I can’t find anything like it. I need to use Valgrind in eclipse (eclipse has support), I have already performed all the package installations I found on the…
-
0
votes2
answers321
viewsHow to place an integer at the end of a string?
I need to loop up n placing an integer at the end of a string. Ex: string "E0" and an integer of 0 to n, getting something like this: E00, E02, E03, ... , E0n char ent[3] = {'E','0'}; char a[1]; int…