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
answer108
viewsword manipulation with Allegro
Hello, I am in doubt about the string manipulation with Allegro, as well as using "fgets" or "scanf" in C to receive a keyboard word I want to know how you do it with Allegro.
-
1
votes1
answer115
viewsFunction count left tree
This function below compiles correctly, works. int qtd_niveis (tipo_arvore * raiz) { if (raiz == NULL) return 0; int esquerda = qtd_niveis(raiz -> esq); int direita = qtd_niveis(raiz -> dir);…
-
1
votes1
answer4962
viewsLvalue required as left operand of assignment
I get this mistake lvalue required as left operand of assignment in the code if (a*a = b*b + c*c) { printf ("TRIANGULO RETANGULO\n");}…
-
1
votes1
answer208
viewsProblems with dynamic allocation and struct
I intend to create a struct where there will be a vector of structs... The way I thought of doing it was kind of like this: typedef struct{ char *teste_str; int teste_int; }TESTE_A; typedef struct{…
-
1
votes2
answers342
viewsDoubts about the realloc function
realloc realoca "negatively" the memory? That is, if the original size of a vector is greater than the value passed in the reallocation, the vector will be reduced? For example, if I do this: char…
-
1
votes2
answers285
viewsWhere to use accumulators in a unique peer-review algorithm?
Where should I fit the accumulators of this code I have written for now? #include <stdio.h> int main() { int N; int somapar; int somaimpar; do{ printf("\n Digite um número qualquer: ");…
-
1
votes1
answer68
viewsFunction insert in list
Hello. I am developing this function below: void inserir_inicio (tipo_lista * p, tipo_lista * novo_no) { novo_no -> prox = p; p = novo_no; } And in the main I’m calling for:…
-
1
votes1
answer393
viewsCopying strings in C
I would like a help on the following question: I have a char with a text of 32 characters, so I would like to know how to separate this char in two of 16 characters. Type: char textao[32] = "Oi meu…
-
1
votes2
answers57
viewsSelected language error
I copied a source code made in the program Code Blocks and pasted it in a project in Visual Studio C 2010 Express, compiled and is giving some errors, one of the errors is in this line: int main(){…
-
1
votes3
answers59
viewsWhat am I doing wrong? (struct)
struct book{ char code[5]; char title[30]; char category[15]; char author[30]; float price; }; struct book book[100]; book[0].price = 1; You’re making a mistake on the last line…
-
1
votes1
answer1337
viewsCharacter stack
Good night guys, all right? With my RPN calculator program here and apparently everything is working normal despite great difficulties to work with char stack.Missing implement the potentiation…
-
1
votes2
answers424
viewsCompare char in a matrix function
I’m playing an old game and I need to compare the positions if they’re equal to check the winner, but it’s not working. Here is the code: #include <stdio.h> #include <string.h> void…
-
1
votes2
answers2506
viewsHow to create a password mask in C
I created this code in C to generate mask in the password, but it does not let delete the characters later nor save the variable correctly. What can it be ? Follows current code: void login(){ int…
-
1
votes0
answers414
viewsDOUBT GAME 2048 IN C
Eai Galera, I have a job for college in which I must make the game 2048 in C. I’m killing myself with this ja, the teacher asked that the user could choose the size of the board and with what value…
-
1
votes0
answers651
viewsHow to draw frames on the console, along with accented words?
I use the function BoxDraw below to draw frames, in a program with output in text mode (console). I cannot use this function if I use accent words, because when I include the library <locale>…
-
1
votes1
answer41
viewsDoubt regarding the passage of parameters
In the code below, in line 5, the function foo1t calls the function foo1 passing two parameters to it, however, the function foo1 has only one parameter. Is it possible to do this or the code is…
-
1
votes2
answers5595
viewsHow do I validate input in c?
My problem is that I have to force the user to enter a whole value only, if he puts anything else (characters or decimals) I have to make him type again. I’ve already tried to validate scanf but it…
-
1
votes1
answer395
viewsChained list without head, intersection function problem
I’m doing a series of function with chained list without head, but a function called Intersection is not working properly, the problem compiles without errors but this function specifically does not…
-
1
votes1
answer100
views -
1
votes1
answer1567
viewsstrcpy() in struct string
I have a struct Time that has a vector char name[30], the problem starts when I try to copy a value to that string with the function strcpy(), follows the code of stuct: typedef struct Time{ char…
-
1
votes2
answers2441
viewsHow do I round a float number from two decimal places to one if you only have one number? example: 2.10 to 2.1
The problem is that the numbers have to have two decimal places at all times, only in cases where it is type '3.10' you have to format to '3.1'. How do I do it in C?
-
1
votes1
answer152
viewsproblem with file reading/data sorting in c
Hello, my problem is this, in the topic created by Rafael. /users/24666/rafael About problem reading strings. Problem reading strings Who asked about ordering t-shirts in c and then got the answer…
casked 8 years ago carlos cunha 53 -
1
votes1
answer79
viewsExecution time of arrow problem
I’m looking to solve a programming problem. The statement is here: http://olimpiada.ic.unicamp.br/pratique/programacao/nivel1/2014f1p1_setas I made a code, but at the time of sending gives problem…
-
1
votes2
answers668
viewsFunction help to delete repeated values contained in a double-chained C List
I’m not able to develop a function within my code that removes duplicate values within a doubly chained list, could help me? Follow the code done so far, the function I need to fix is the…
-
1
votes1
answer43
viewsError declaring a matrix
I made a matrix[day][time], but I get error when initializing it. I get that mistake and I don’t know how to fix it error: expected ':', ',', ';', '}' or 'attribute' before '=' token The code is…
-
1
votes2
answers57
views -
1
votes3
answers289
viewsError Segmentation fault without indentification
Hello, my friends! I am creating a program that will read a text. This text should be allocated one line at a time (up to 75 characters per line). The program receives, in the input , the user’s…
-
1
votes2
answers67
viewsString reading
char nome[100], endereco[100], sexo[100]; printf("Digite seu nome: "); scanf("%[^\n]s", nome); printf("Digite seu endereço: "); scanf("%[^\n]s", endereco); printf("Qual seu sexo: ");…
-
1
votes2
answers1267
viewsHow to create a vector by joining together 2
I’m doing an exercise with vectors where I need to read two vectors of 5 positions each, and after that, concatenate these two into a 3 of 10 positions. My program is correctly printing the first…
-
1
votes0
answers159
viewsOptimize slow heap deployment
The goal of my program is to implement a heap of limited size, whose entries are just numbers. To set the priority of each element, it is necessary to search when it will repeat again for the first…
casked 8 years ago Daniela Morais 4,687 -
1
votes0
answers61
viewsArray vector has "n" elements, but lenght returns "n+1" in C
Hello, I have the following question: I have a vector and I’m sure it is passed to him only one element through the following loop: char uid[1]; while(indice1 < indice2){ printf("Valor de indice…
-
1
votes2
answers163
viewsConverting a vector<struct> to C++ into C
I am trying to adapt a C++ function into pure C. I have changed the variable names and structs because it’s beside the point. typedef struct struct1 { int a; int b; int c; string d; } STRUCT1;…
-
1
votes0
answers24
viewsDoubts about Dynamic Allocation
As I can in C pick up a variable, as in the example below, make N = vector. In case I go to play N in another role and put inside a for, and then want to reallocate the vector value by increasing N…
-
1
votes2
answers102
viewsCreate sets for 16-bit variable composed of two 8-bit
I wonder if there is any way to create a define for a "variable" in C that has 16 bits called PORTAB, so that writing: PORTAB = 0xAAFF; is equivalent to: PORTA = 0xAA; PORTB = 0xFF; Thank you.…
-
1
votes1
answer133
viewsConvert assignments from C++ to C
I would like help to convert these made assignments into C++ to C: string binario = bitset<256>(address).to_string(); int InicioDado = 256-log2(cacheconfig.lineSize); string dado =…
-
1
votes1
answer68
viewsProblem after applying a patch to generate random names in ffmpeg
I applied the following patch below, it works as expected, but occasionally transcoding for and in other cases(rare cases, depending on the compiled ffmpeg version) keeps running but instead of…
-
1
votes3
answers4341
viewsI cannot use accents in Code Blocks
Hello! I have a code: include stdio.h> include locale.h> int main() { setlocale(LC_ALL,"portuguese"); printf("Agora não tem mais problema algum para utilizar acentuação!\n"); return 0; } Set…
-
1
votes1
answer837
viewsPrint sequence of numbers repeating in arithmetic progression
Make a program to print: 1 2 2 3 3 3 ..... n n n n n n ... n for a user-informed n. Use a function that takes an integer n value and prints up to nth line. Why doesn’t it work? #include…
casked 7 years, 2 months ago Pedro Joao 53 -
1
votes1
answer223
viewsHow to install C++ compilers and previous version libraries in visual studio 2015?
How do I install older versions of c++ compilers and libraries in visual studio 2015 without having to install the IDE together? (i.e., only what is necessary to compile, run, and debug…
-
1
votes1
answer8939
viewsCount the lines of a txt file in c / c++
In file class the teacher used " EOF " to determine whether the file had reached its end, but by reading the wiki about c files, I saw that the implementation of the end check of a file is " FEOF ",…
-
1
votes1
answer108
viewsRead array of a file diagonally
Hello! I have a fixed-size file that has a random character array. However I’m having trouble using fseek and fread to read the file diagonally. To explain the problem, I need to do a kind of word…
-
1
votes2
answers5472
viewscalling a function within another function in c
I need to receive values float to store in a struct, however, these values must be validated by means of a validation function.` The function that reads and validates these values is working…
-
1
votes1
answer85
viewsHow to transfer an array of floats to an array of integers?
How do I convert an array of floats to an array of integers? Ex: float grade{12.30, 15.55, 16.25, 0.00, 3.68} Output: {12, 15, 16, 0, 3}
-
1
votes3
answers473
viewsDoubt char C pointer
Hello. I need to make a pointer char point to a memory position holding a phrase, in C. I’m doing like this: char *ptr; char array[3] = {'o','l','a'}; ptr = &array; But I don’t understand what’s…
-
1
votes2
answers44
viewsHow to print only values other than 0
Guys, I have a question. It is possible in C to print only the different values of 0. A Case: We have the exits: 2.56000, 5.00000, 3.60000 and 27.36800 And I want you to print as follows: 2.56, 5,…
casked 7 years, 1 month ago Lucas Katayama 101 -
1
votes1
answer101
viewsAbout passing parameters in compiled programming languages
What would be more advantageous when calling a function, putting in the stack from right to left or vice versa? And cleaning the stack? The function that calls (Caller) or what is called (calee)…
-
1
votes3
answers69
viewsHow could I read a 3-digit value and print them on the screen reversed in C?
If I stored the '123' value in an integer type variable, how could I print the contents of the variable on the screen in reverse? For example, for the value '123' the expected output would be '321';…
-
1
votes1
answer8780
views -
1
votes2
answers258
viewsRemove stopwords listed in a txt file from another txt file
Good evening guys, I need help. I am doing pre-word processing and for that I need to remove from a book in format . txt all stopwords found in a text file also "stopwords_br.txt". I found a program…
-
1
votes1
answer1766
viewsHow do I do vector product by matrix and between matrices?
I can’t think of a for that performs this multiplication, because the number of columns of the first matrix has to be equal to the number of rows of the second matrix...
casked 7 years, 1 month ago Lucas Gonçalves 63