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
-
3
votes1
answer1067
viewsHow to Calculate CRC Modbus RTU
I’m trying to calculate a crc Modbus in an application for PIC, but the returned crc is always incorrect compared to online simulators. follows the code void CRC (unsigned char* msg, unsigned char*…
-
3
votes2
answers115
viewsWarnings interfere with the program?
I’m performing the following exercise: After a few attempts I reached the following final code: int proximo_da_media(int *vec, int dim){ int i, *pos; float media, soma=0, diferenca; pos=vec;…
-
3
votes1
answer1348
viewsEvaluate ascending order with repeating structure
Write a program to determine if a sequence of n numbers entered by the user is in ascending order or not. The user must provide how many numbers will be typed, ie the value of n. I’m having trouble…
-
3
votes1
answer2008
viewsDoubts regarding the use of memset and memcpy functions
I’ve been sifting through some codes on the internet and at a certain point I came across the functions memset and memcpy. I was able to understand superficially the functioning of the functions…
casked 6 years, 6 months ago user105951 -
3
votes1
answer119
viewsProgram has memory junk 2 in C
That’s the question of the program: Make a program, using the function below, that displays the highest salary of each department of a company and how many employees earn the department’s highest…
-
3
votes1
answer1363
viewsPass data from a struct within the function
I’m doing a college job where I have a separate function that gets two values (WEIGHT and HEIGHT) and returns the BMI. I have tbm a struct called STUDENT where is stored weight and height and a…
-
3
votes1
answer37
viewsI cannot print, in the main function, values from a vector created in another function received by a double pointer
The following source code is the miniaturization of a larger problem I’ve been working on for two days that I can’t solve the problem. I need to print the values of the vector generated by the…
-
3
votes2
answers895
viewsOutput error - C language
Good afternoon, Currently studying Language C and I come across a situation that has locked in the progress of studies,I made a structure that receives registration and address. The compiler does…
casked 6 years, 5 months ago Jeferson Silva 65 -
3
votes1
answer474
viewsIn C, can declaring variables in the middle of a block of code lead the program to undefined behavior?
I have read in several books that in C variables should be declared at the beginning of a code block. But what happens if I declare them in the middle? I was doing a program in c that shows a text…
-
3
votes1
answer96
viewsLexicographically compute the letter of a string
My function needs to lexicographically calculate the value of the characters (by the ASCII table) of the string. For example: "Alibaba" and "Came"'A' = 65 and 'V' = 8665 - 86 = -21. Then the…
-
3
votes2
answers560
viewsWhat exactly does '%02x' do?
I was seeing some examples function hash of Openssl and I came across the format specifier %02x. I do not know very well its purpose we codes that I saw. I even understand that the %02x serves to…
-
3
votes1
answer103
viewsGenerate build error in C for not using a function
A problem has arisen in creating a mini-library to simulate Threads on a PIC. It would need to force the programmer to implement a function. I wonder if there is any way to use the preprocessors…
-
3
votes1
answer1651
viewsStore positives in one vector and negatives in another
Make an algorithm that reads a set of 30 integer numerical values and distributes them between two vectors, separating the positive numbers from the negative ones. Vectors must have 30 positions…
-
3
votes1
answer113
viewsHow to set a pointer as the default parameter in C++?
I am "programming in C", but compiling using the extension .cpp and the g++ to have some facilities. My goal is to make a program that receives a starting salary and calculates the final salary…
-
3
votes2
answers122
viewsWhat is it for { } inside the main
I came across a situation in C that I do not know and had never seen anyone use before. Within the method main() there are several keys, I believe that to isolate the code but there is a same…
-
3
votes2
answers121
viewsUsing float to check overflow in unsigned long int
Hello, all right? Please review this code: #define max 4294967295 unsigned long int collatz(unsigned long int n, unsigned long int passos, float *maiorN) { float overflow = 3 * n + 1; if (n == 1)…
-
3
votes1
answer75
viewsVector problem with dynamic allocation
The intention of this program that I am doing is to serve as if it were a banking system in which the amount of accounts to be created does not have a previously defined amount. In the main(), i…
-
3
votes2
answers175
viewsDoubt of if He is
Good evening, I was testing this C code of an activity* of my course, works ok if (c<101||c>103), works ok if if (c=101), but if (c=102) if instead of returning me ns=s+(s*0.2), is returning…
-
3
votes1
answer202
viewsProblem with dynamic allocation - realloc()
I’m doing a program that works as a payroll system, but I’m having trouble with the dynamic allocation part. The program runs only once and stops. No int(main) i put: printf("Sizeof :…
-
3
votes1
answer511
viewsError printing struct member: request for Member in Something not a Structure or Union
I have the following struct: typedef struct{ int Numerador ; int Denominador ; } TNumeroRacional ; In this function I ask the user to insert 2 numerators and denominators to form 2 rational numbers.…
-
3
votes1
answer743
viewsAccept uppercase and lowercase character
I’m making a draft just to train the if and the else which will be subject in my next class in college. I want to get there and at least already have a basis of what the teacher will teach. My…
-
3
votes2
answers2007
viewsConcatenate Strings in C
Good afternoon, you guys! I have a problem in Strings using the C Language. The problem asks the user to enter a name, then to enter a special character, and finally how many times he wants the…
-
3
votes1
answer214
viewsProblem removing at the beginning in a doubly chained list
Hello. When I try to use the "remove" function to remove the first element from the list, apparently nothing happens. But, soon after using the function removes and try to insert a new node in the…
-
3
votes1
answer272
viewsRunning time in C
I would like to take the runtime in milliseconds of an application, I did the following algorithm. double writingFS(char* Filepath, char* PenDrivepath, clock_t* thput) { clock_t t1, t2; long size =…
-
3
votes2
answers2190
viewsHow to pass a matrix as a reference to a function?
I’m trying to pass as a parameter a matrix for a function as a reference, and in this function do operations in this matrix but I’m not getting. I don’t want you to use define or const int for the…
-
3
votes1
answer156
viewsWhy does this c code work?
When I call the call malloc, I only had space for one char, but it works for words of any size, so I got confused #include <stdio.h> #include <stdlib.h> #include <string.h> int…
casked 6 years, 1 month ago jofernando 31 -
3
votes2
answers4471
viewsHow to Store Strings in Vectors - C
How do I store more than one name in a type variable char, why put, let’s assume name[20], I’m defining that she was given 20 characters, and not that she could receive 20 elements, the code I’m…
-
3
votes2
answers141
viewsComparison of string characters in C
I’m trying to do an exercise that tests if there’s any white space before a string and remove if you have, but is returning the following error: Segmentation failure (recorded core image) I can’t…
-
3
votes1
answer62
viewsProblems with dynamic matrix allocation
I’m trying to dynamically allocate a matrix, but I’m having some problems with running time and I’m also getting a Warning of GCC in the compilation time. Follow the code below for a better analysis…
-
3
votes2
answers2077
viewsC Encryption - Caesar Cipher
Good afternoon, I’m developing a basic encryption code (Caesar’s cipher) in C. I am using the logic of traversing 2 vectors: vetText and vetLetras, where the comparison of char and then replace it…
-
3
votes2
answers162
viewsHow do I set up Git to ignore trivial changes (for example, file timestamp) in a file?
The problem I’m facing is this:: The C application has an option where the build date of the application is displayed. To prevent the developer from managing the application before the current day…
-
3
votes3
answers337
viewsError calling function that returns string in C
I made a program that asks for name and surname to be concatenated through a function: #include <stdio.h> #include <string.h> int main(void){ //Declarando Funçãoo char retornaNome(char…
-
3
votes0
answers45
viewsscanf(), gets() and fgets(). What’s the difference?
Good afternoon to all, I was studying some algorithms in C [especially Strings] and I couldn’t help noticing that fgets()and scanf() for reading strings often, but rarely use the gets() [Which is…
-
3
votes1
answer83
viewsC code error
#include <stdio.h> typedef struct { char nome[10]; float altura; float peso; char cpf[12]; char sexo[10]; }Dados; void imc(Dados x); char consulte[12]; void imc(Dados x[1]) { int i,c;…
casked 5 years, 9 months ago Guilherasmin silva 47 -
3
votes0
answers136
viewsProblem reading string(logic) characters - C
I was doing a program to register students, teachers and subjects in different structs. However I have to link them. For this I made a function only to do this task, but I can not solve a logic…
-
3
votes2
answers84
viewsError of memory allocation
I am creating a C script to classify a triangle according to the 3 sides passed. For this I use three distinct variables, lado1, lado2 and lado3, as illustrated by the code below: #include…
-
3
votes2
answers69
viewsI need to know where in that code is my mistake - MATRIX C
In the letter i was to give 9,2 but the result that shows is 9,50. How to find out which class has the most homogeneity in relation to grades? float turma1[4][5] ={ {8.2,9.2,8.7,6.0,7.0},…
-
3
votes1
answer111
viewsHow to allocate in contiguous memory a structure that contains 1 vector with user defined size?
I was wondering how to answer this issue and I came to the conclusion that I would need a data structure with: the size of a set a previously reported size vector It would be something like the…
-
3
votes1
answer575
viewsError Unknown type name 'typeTelephone'
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> typedef struct{ int id; char nome[20]; tipoTelefone telefone; }tipoCliente; typedef struct{ int…
-
3
votes2
answers626
viewsWays to initialize struct’s
I know these two ways to boot struct's. #include <stdio.h> typedef struct { char s[10]; int a, b; double x; } TIPO; int main(){ TIPO v1[10]={"foo", 5, 13, 4.3, "bar", 0, 0, 2.3}; TIPO…
-
3
votes1
answer61
viewsDo vectors and structures always have continuous addresses?
Why vectors and structures are continuous in memory? I believe that it is not just coincidence. #include <stdio.h> int main(void){ char s[10]; for (int i=0; i<10; i++) printf("%d=%p.\n", i,…
-
3
votes2
answers165
viewsVariable appears as undeclared when trying to use it in the "while" loop
When trying to create a program that converts Celsius into Fahrenheit to get practical and I come across the following error message: Erro "sair " undeclared (first use in this function) My…
-
3
votes1
answer76
viewsWhy doesn’t the matrix print out all the typed values?
#include <stdio.h> #include <stdlib.h> #include <locale.h> int main() { setlocale(LC_ALL, "Portuguese"); int linha=0, coluna=0, i, j, l, m; int matriz_A[linha][coluna],…
-
3
votes1
answer107
viewsDivisions miscalculating in C
#include <stdio.h> int main() { double A, B; double MEDIA; scanf("%f", &A); scanf("%f", &B); MEDIA = (A + B)/2; printf("MEDIA = %5f", MEDIA); return 0; } In this program I have already…
-
3
votes1
answer125
viewsWhere does the memory space required for each element in a C string array come from?
In C, you can group a set of string's, which are arrays of char's within a array without having to define 2 dimensions for this? That’s why you use a array pointer char's and simply defines the…
-
3
votes4
answers1648
viewsCount consonants in the sentence
The program must count the number of consonants in the sentence. If only one word is typed it counts right, but if I give space, ie, write a sentence it does not count right. #include…
-
3
votes1
answer169
viewsReturn function of the next ASCII character in C
Do a function: strShift() that receives a string with alphabet letters and returns a new string with letters replaced by their successors in the ASCII table. For example, "Ana" returns "Bob" and…
-
3
votes1
answer218
viewsStack implementation in C, how to pass values?
I am trying to implement a stack in C. The prompted by the teacher is already basically done which was to show an error if the stack was full or empty. But when going to main I found great…
-
3
votes1
answer134
viewsProblems with a date validation function in C
I’m developing a system for patient registration. It’s a college project. I’m splitting function groups into different files. It turns out that I created a function to validate the date…
casked 4 years ago Rodrigo Diniz Monteiro 33 -
3
votes1
answer40
viewsshellcode amended "Segmentation fault"
Well I have a file called test.asm with the code (for windows): section .text global _main extern _printf msg: db "%d", 0 _main: mov eax, 10 add eax, 20 push eax push msg call _printf add esp, 8 ret…