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
-
2
votes1
answer77
viewsC library Function in Postgresql
I am using Visual Studio 2015 to create a function in a dll, and when I try to use it in Postgres, I get the following message: server closed the Connection unexpectedly This probably Means the…
-
2
votes1
answer45
viewsCapture Started Strings with %t and %u
What modification can I make to capture humidity and temperature of my serial port to insert within a variable the humidity that is printed on the serial port as %u00.00 and the temperature %T00.00.…
-
2
votes3
answers160
viewsFunction prints while list
How do I do this function with the loop while? void imprime(lista* recebida){ lista* aux; for(aux=recebida; aux!=NULL; aux=aux->prox){ printf("Informacao %d\n",aux->info); } }…
-
2
votes2
answers153
viewsPrint number of nodes in a list
This code below does not work properly, I type 5 knots and was to return the number 5 (total amount of knots entered). It happens that returns me 4. int qtd_no_lista (tipo_lista * recebida) {…
-
2
votes2
answers5533
viewsReturn string in C for manipulation outside the function in which it was declared
I must develop a calculator that reads strings in the algebraic form of the complex number operation. I need to manipulate the "main" vector outside the function in which it was declared (receives).…
-
2
votes1
answer2197
viewsBubble Sort in list
I’m trying to order a simple chained list, but I’m not succeeding, only changes the first node because the value is smaller, the rest does not change. void ordenar(lista **l) { int tam =…
-
2
votes3
answers611
viewsIncorrect counting in electronic voting program
I created an urn with the C language. The code is apparently correct, but the vote count always results in zero. The code was developed in Linux code:Blocks, so in order for it to work in windows,…
casked 8 years, 2 months ago Luis Fernando Consulo Martins 89 -
2
votes1
answer540
viewsInsert in Tree B with a large number C/C++
I need to build a B Tree that reads the name of the files in a folder and sorts them. "Create a repository of images(100 images with 5 of each category-ex: trees, boat, dogs, houses, computers,…
-
2
votes2
answers402
viewsOperation to release a circular list
I am in doubt in the implementation of the method of releasing the memory of a circular chained list: void liberarLista() { if(head == NULL) return; //retorna original(NULL); lista *aux, *temp =…
-
2
votes0
answers236
viewsPrint list simply chained backwards in C
I have a list simply chained where each node has a value, they are respectively 1, 2, 3, 4 and 5. I want to print the values of the list only for aesthetic reasons like 5, 4, 3, 2, 1 without…
-
2
votes2
answers1461
viewsRead a txt file and place each character in a position of an array in C
I tried the code below, but it didn’t work The big problem is fscanf placing each character of the text in an array position #include <iostream> #include <stdio.h> using namespace std;…
-
2
votes1
answer1466
viewsHow to store the return value of a function in a local variable in C?
I created a function that returned a certain value when using this function in the function main of the program, how can I store its return, and for example, display this return in a printf in main?…
-
2
votes3
answers159
viewsDoubt about the lower value of banknotes
I’m having a question about the conditional test to store the lowest value, it’s not really a doubt, the problem is that when it prints, the value of the lowest value is 0.0, which hurts to…
casked 8 years, 1 month ago Italo Zuckerberg 63 -
2
votes3
answers178
viewsProgram in C : A certain doubt
The program I made compiles, but what is requested does not appear on the screen. That’s the thing about: Construct an algorithm in PORTUGOL, which receives three values, A, B and C, and store them…
-
2
votes1
answer1614
viewsHow to represent algorithm in C for Pseudocode?
I have the following code : setlocale(LC_ALL,"portuguese"); int numeros[5]; int media; for(int i = 0; i < 5; i++) { printf("Digite um número : "); scanf("%d", &numeros[i]); } media =…
-
2
votes1
answer2214
viewsPercentage in C
Given the following statement: Write an algorithm to show on the screen if each N number, typed user is even or odd. The algorithm should also show on the screen the sum of all even numbers, the sum…
-
2
votes1
answer68
viewsDoes the amount of bytes during a file read vary according to the mode chosen?
In C, if I open a file in binary mode, read it byte-by-byte and then take the file and read it in text mode, will the amount of bytes be different? If so, why?
-
2
votes1
answer416
viewsPointer to pointer array
I wonder if in the code below (the variable 'p') is a Pointer to an Array of Pointers ? #include <stdio.h> int main () { double valor = 7; double *balance[5] = {&valor, &valor,…
-
2
votes1
answer142
viewsData Structures - List Differences
Please would like to know the real difference between these structures below: typedef struct { int info; struct lista * prox struct lista * ant; } tipo_lista; and that: struct noCliente { int…
-
2
votes1
answer635
viewsChained list within Chained list
I’m struggling with chained lists inside a chained list. The program is a card game in which there is a doubly chained list of players and within each node of that list, a list (the hand) of cards.…
-
2
votes2
answers1061
viewsMost odd number
I spent hours trying to solve, I started to think that the problem might be in the compiler, since it returns me a different (and wrong) number at each run What could be the mistake? #include…
-
2
votes2
answers1130
viewsHow to replace 1 bit of an integer without changing the other neighboring bits?
I want to change 1 bit and keep the same values of the other neighboring bits. The bit operator shifts to the left or right by changing the bit of 1 pair 0, but it changes the entire 8-bit sequence.…
-
2
votes2
answers940
viewsChange command prompt properties in c
I am new to the language c. I wonder if it is possible to change command prompt properties by c, such as cmd size, width or even font?
-
2
votes1
answer396
viewsVector and matrix ordering
Do you have another method to sort vector/matrix in ascending or descending order other than the one I used ? ( What would you change in this code to make it " better " ? ) #include <stdio.h>…
-
2
votes2
answers2251
viewsChained list - remove function
I am programming a chained list without head, in this program there is a remove function that aims to eliminate all the repeated integers in a list, px: taking the values 8 2 8 3 the function has to…
-
2
votes1
answer62
viewsError removing element from a chained list in c
The function retiraLifo is not working and there is some syntax error, but I did not find it. This function is to remove element from the list. A insereLifo is working. The following error occurs:…
-
2
votes1
answer51
viewsError condition in C
When I moved in Python I remember I had how to make one if if any assignment or operation returned error. Type like this int v[]={1,2}; int v1; if((v1=v)==ERRO) //faça isso; There’s something like…
-
2
votes3
answers2408
views -
2
votes0
answers269
viewsGenerate random numbers in a vector of floats in the C language
I would like to know methods of generating a sequence of random numbers, ranging from 0 to 10, of type float in a size 10 vector.
-
2
votes1
answer1098
viewsWhy is this error? - invalid application of ?sizeof' to incomplete type
When I try to compile(gcc test.c) it generates the following error: The code: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct aluno Aluno; int main() {…
-
2
votes1
answer2495
viewsBubble Sort in Assembly (MIPS)
My teacher asked us to implement Bubble Sort in the MARS environment but I’m not getting it. There is some error in the code. Can anyone find the error? The way out should be {1, 2, 3, 4, 5, 6, 7,…
-
2
votes3
answers95
viewsHow to search a string for X and replace it with a number and use it to calculate?
I’m creating a C program to do the Newtow-Raphson method, it should automatically calculate for the person. But in one part of the method should be done the automatic substitution of values in the…
-
2
votes2
answers186
viewsWhy do you accept values beyond the size of the vector?
INT vetor[3]; vetor[0] = 110; vetor[1] = 12; vetor[2] = 30; vetor[3] = 13; vetor[4] = 1; Cout << vetor[0]; Cout << vetor[1]; Cout << vetor[2]; Cout << vetor[3]; Cout <<…
-
2
votes1
answer612
viewsWhat would be Pro*C/C++?
From what I saw it is using in Oracle, but I can use with another Bank? Pro*C/C++ useful these days? Could pass a Code Example? Does it differ from PL/SQL? Or are they used together?…
-
2
votes1
answer110
viewsPrinting a vector... Differences between C++ and C... Where did I go wrong?
I’m having problems printing vector structs in C, in C++ it worked... First I will show the version in C with problems (in the execution because compiles without errors) CACHE cache =…
-
2
votes3
answers16313
viewsComparison of char in C
I need to find out if each element of a chained list is a vowel or not. How can I fix my code? int BuscaNv(LISTA* resp){ NO* atual = resp->inicio; while(atual){ if(atual->letra == 'a' || 'e'…
-
2
votes3
answers6300
viewsHow to add numerical values inside a C string?
Good morning, I need to write a code that receives a number and returns the sum of the digits of that number. For example, if the user type 123456789 the program must print 45 (1+2+3+4...). I think…
-
2
votes2
answers3980
views"Undefined Reference" error when compiling in C
I have a simple program where when compiling an error Undefined Reference to `increment'| main.c: #include <stdio.h> #include "incrementar.h" int main() { printf("Numero incrementado%d!",…
-
2
votes2
answers62
viewsPerform function at each given time period
ola i would like to implement a function in my program that performs a task every time having this code as an example something so I am wanting void main(){ while(1){ if(passou 5 minutos){…
-
2
votes1
answer1026
viewsDoes the scanf record string on pointer that does not have a defined size?
I’m trying to understand how the strings in C. I noticed that even not defining in any part of the code any limit for the vector TextoUm[] (which follows in the code below), the function scanf can…
-
2
votes2
answers887
viewsSplit double chained list with head
I have a problem with the Divide function, where I am getting a list and want to return to the right and left part of the list. Can someone give me a hand with logic. #include <inttypes.h>…
casked 7 years, 1 month ago Matheus Francisco 650 -
2
votes2
answers159
viewsInversion of array (positions)
I’m trying to do an array inversion in the language C. For example: I have an array [1, 2, 3], I need to invert the numbers in the SAME array, giving an output like this: [3,2,1]. I’m trying, but…
-
2
votes2
answers1221
viewsC: error in srand(time(NULL);
I’m playing a little game in C(college project) and I’m finding an error in main, follow: int main () { int x, y, i, j, linha, cnt=1, jl=0, jc=0, jogada_a=0, jogada_b=0; char coluna, jogador;…
-
2
votes2
answers3142
viewsHow can I print the fifth part of a real number?
How could I print the fifth (index 4 from the dot) part of a real number without using libraries or a "complex" code for initial chapters. Make a program that reads a real number, and print the…
-
2
votes1
answer64
viewsRecursion in C - The crash program
The goal of the program is to ask the user for two digits and generate a list of sequences, each containing information from the previous. For example: User writes 1 1 and the generated list is: 21,…
-
2
votes2
answers143
viewsOverload of C++ operators, is the auxiliary variable necessary in this case?
I am studying for the book Introduction to Object-Oriented Programming with C++ (Antonio Mendes da Silva Filho), and implemented an example of it as follows: #include <iostream> using…
-
2
votes2
answers167
viewsHow do I pass an array of structure pointers to a function?
#include <stdio.h> #include <stdlib.h> #define NUM_NOTAS 5 #define TAM_NOME 20 struct Aluno{ char nome[TAM_NOME]; int numero; int notas[NUM_NOTAS]; }; void preenche(struct Aluno*…
-
2
votes1
answer2293
viewsHow do I stop organizing tables in while?
How do I stop organizing this table ? Sum, subtraction and multiplication respectively ? #include <stdio.h> int main (){ int i=0, num=0; printf ("Digite um n£mero: "); scanf ("%d",&num);…
-
2
votes1
answer66
viewsDifferent values between variable without value and variable with null value?
#include<stdio.h> int main ( void ){ int die1[7]; int die2[7]; int sortedDie, i; srand(time(NULL)); printf("Rolling die 1\n"); for( i = 0; i < 6; i++){ die1[i] = 1 + rand()%6; }…
-
2
votes1
answer405
viewsOptimized word counter in C
I’m trying to understand an example of code in C to count words (from the book Programming Pearls). But I’m having doubts in some parts of the code (maybe I didn’t type correctly): nodeptr…
casked 7 years, 10 months ago Marcus Becker 724