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
votes2
answers879
viewsmajor/minor in vectors
I made some modifications to my code, it is in modifications at the end of the post I will modify it when I find it necessary. hello, I am doing a college exercise, it is very simple, however, I am…
casked 10 years, 3 months ago Leonardo V. De Gasperin 713 -
3
votes2
answers1886
viewsGets function on Linux
I’m trying to use the function gets (language C), but it doesn’t work. Am I using it wrong? The code is like this: #include <stdio.h> typedef struct { int matricula; char nome[40]; int nota_1;…
-
3
votes1
answer148
viewsProblem with C exercise
The exercise asks for this : 5. Make a program that reads a sequence of numbers between 1 and 20 and show how many times each number appeared. The sequence of numbers ends with a number equal to…
casked 10 years, 3 months ago Daniel Bezerra De Menezes 253 -
3
votes1
answer426
viewsConcatenate string with int in printf
It is possible to do this in C: int MAX = 30; printf("\n| %".MAX."s | %8s | %8s |", "Nome", "Salario", "Idade"); printf("\n| %".MAX."s | %8.2f | %8d |", pessoa[i].nome, pessoa[i].salario,…
-
3
votes1
answer91
viewsC file creation error
I am trying to create a C file but it is not working. The operating system is Linux. #include <stdio.h> void main (FILE *file) { file = fopen("/home/Documentos/teste.odt", "w"); fprintf(file,…
-
3
votes1
answer96
viewsError in the calculation of values of a vector
I’m stuck in this part of my job in case two of college, the exit gets all jumbled up, for example: The profit will be -1,#$%#!@ #define vetor 40 struct Produto{ char codigo[10]; char…
-
3
votes2
answers1036
viewsDictionary in C always returns "word not found"
I am having problems with the code below. Although the user type a word available, the return is always palavra nao encontrada. #include <stdio.h> #include <stdbool.h> struct dicionario…
-
3
votes2
answers276
viewsError when trying to pass a struct by C reference?
I’m taking pointer class and I’m trying to do the following exercise: Consider a enrollment of students enrolled in a discipline, with the following information for each student: • Student name: up…
casked 10 years, 2 months ago Igor Ramos 431 -
3
votes2
answers768
viewsString of characters inside the scanf. Why and how does it work scanf("Day %d",&dia);?
Problem I was making a code that would read a string and then an entire value: int dia, h, m, s; char dp; //Dois pontos. scanf("Dia %d",&dia); //Inicio do evento. ... I thought of creating a…
-
3
votes1
answer144
viewsProgram does not compile with miscellaneous errors
What’s wrong here? I can’t see the error. #include <stdio.h> void Main(void) { int a = 9; int b = 3; int c = 0; int *p = &b; c = a/*p; printf("%d \n", c); }…
-
3
votes1
answer704
viewsScatter table (Hash Tables)
I have a hash table closed with open addressing and linear scanning for the following dictionary of words, from a text; The input operation works like this: 1) The program asks for the first line of…
-
3
votes1
answer267
viewssudoku problem with rows/columns repeated
Well I am doing a college job which is to do a sudoku in which the PC plays, first I am creating the rules of the game which is no number can be repeated in the row nor in the row where it is... As…
-
3
votes1
answer165
viewsBinary tree returning empty in search
In my menu it is not doing the correct output in the print. In addition to the search return only empty tree. #include<iostream> #include<string> #include<stdlib.h>…
-
3
votes2
answers681
views"Merge" elements of a single vector
I have a vector with four elements that are numbers represented in hexadecimal form. What I need to do is concatenate these four elements (I believe that this is not the right word, but I have not…
-
3
votes2
answers1296
viewsHow to get operating system time in nanoseconds or milliseconds using Qt Creator?
How can I get system time in nanoseconds or milliseconds in C++ using the Qt Creator? For example, in Java use: long tempoInicial = System.nanoTime(); treinaRNAEpocas(10000); long tempoFinal =…
-
3
votes1
answer691
viewsRemove from binary search tree
Studying BST (binary search tree) did not understand some parts of the code in the function delete of "mycodeschool". That part of the code, more specifically: // Case 1: No child if(root->left…
-
3
votes2
answers110
viewsWhy does the order of these scanf’s make a difference in the outcome?
The program sums up x1 and x2 and puts the result in x1. It doesn’t work if x1 be read before x2. But if you reverse this order, it works. #include <stdio.h> #include <stdlib.h> unsigned…
-
3
votes1
answer952
viewsStructure maze in C
Okay, I’d like to play a game in C "console" but I’m having a question.... Basically the idea is to have a character that advances in a maze thanks to the user, if the user writes "right" the…
-
3
votes1
answer278
viewsProgram does not read file data properly
I have these three structs: typedef struct { char codigopaciente[10]; char nome[50]; char telefone[50]; int idade; char sexo; } paciente; typedef struct { char codigomedico[10]; char nome[50]; char…
-
3
votes3
answers272
viewsIncompatible types?
I am passing 3 parameters: a vector with the name of 30 cities, one with the x coordinates of the respective cities and the other with the y coordinates. I need to print on the screen the cities…
-
3
votes1
answer96
viewsLimit characters in Tesseract Portable
Currently I am using the Tesseract Portable integrated with java to be able to identify some characters, but I’m facing some problems like: Some fields date only as : 01/02/2013 Something like this…
-
3
votes4
answers1489
viewsCleaning the Buffer after getchar
Good Morning, I wanted to know how I can optimize the cleaning of the buffer when using the getchar() function, as an example follow the following codes: I get the following code to have the correct…
-
3
votes2
answers3525
viewsFloating point Exception (core dumped)
This code is giving the error Floating point exception (core dumped), is just a piece of programming in c, but this error occurs after the printf("\nO Total de apostas foram:%d\n", taposta); in the…
casked 9 years, 11 months ago Marcos Correa 33 -
3
votes1
answer1796
viewsChange the value of a vector in a function
How do I do? I’m trying to: #include <stdio.h> #include <stdlib.h> int changeMap(char mp[], int x, int y){ mp[x-1][y-1] = 'X'; return 0; } int main(){ char map[][1] = "gabriel";…
casked 9 years, 11 months ago Gabriel Sales 1,257 -
3
votes1
answer63
views -
3
votes1
answer387
viewsCreate a c-language game with the MCU 8051 IDE
I’m trying to develop a game within the curricular unit of microprocessors, so the game consists of a dummy that has to dodge bombs, so I have to create the dummy, the bombs and get them moving. I…
-
3
votes1
answer276
viewsIncompatible arguments - Pointers for structures
Good afternoon, I needed help fixing some mistakes at the terminal. Summary: I have done some functions to get some information (values) about active clients (where a client is active if he is an…
-
3
votes3
answers677
views -
3
votes1
answer92
viewsAllocation in C - Object was probably modified after being Freed
I am making a data structure program and am getting the following error: Arq(1966,0x7fff7970f300) malloc: * error for Object 0x7fc058404c38: incorrect checksum for Freed Object - Object was probably…
casked 9 years, 10 months ago Guilherme Oliveira 33 -
3
votes1
answer62
viewsHow does strtoull work?
I have tried anyway to understand what is the second parameter to use this function and it in general but I still can not understand.
-
3
votes2
answers269
viewsProgram always returns the same result in C
The code runs normal but only one way out: sunday! regardless of the number chosen. What the programme should do Implement a program with an input number (1-7) which corresponds to one of the days…
-
3
votes3
answers2396
viewsHow to read the first three characters of a string?
I have a C application. It already opens a text file and reads the whole single line that the file has. It’s a long line, for example: Htjxxxxxxxxxxxxxxxxx... I can store this content of the text…
-
3
votes2
answers344
viewsSegmentation Fault (core dumped ) Array reading
I have a problem related to reading a array that produces the error Segmentation Fault (core dumped ) This is only the beginning of code development, but already presents an error after reading the…
-
3
votes1
answer224
viewsHow to make graphic applications in C and C++?
I’d like to know how to make apps with C and C++ GUI. I know logic, like if/Else loops, while, for, swith and while remain the same, but I would like to know how to make a window, button, and…
-
3
votes1
answer631
viewsRead a string with scanf()
My program must read big numbers(0<=X<=10 (100)), what I’m doing is he reads/interprets the typed numbers as char and store in a chained list. My show was fine, until I put one…
-
3
votes2
answers279
viewsAlgorithm for (A+Bi) n
I need to make a program that given the formula : A + B*i n You have to find the lowest value of n for it to be a real number Being A and B inputs and i is part of the complex numbers. I have a…
-
3
votes1
answer118
viewsSorting algorithm does not work
Something is missing in the program. It checks the order with a single number or a single time. #include <stdio.h> #include <stdlib.h> /*4)escrever 10 números e ordenar em forma…
-
3
votes3
answers211
viewsProgram using malloc twice
Why this program that divides a number into decimal notation, transforms it into binary notation and prints the number on the screen in the correct sequence (from bit most significant for the least…
-
3
votes2
answers1237
viewsHow can I get more accurate values by dividing two long?
I’m programming a CNC on my own, and I’m in the middle of my code, and now I have two variables like long which, when divided results in an exact fractional value, but the Arduino returning a…
-
3
votes0
answers114
viewsBuffer and/or C I2C problem
I’m hoping to get some help here. I am programming for Beaglebone Black using I2C sensors via the Eclipse IDE for C/C++ Developers, Version: Luna Service Release 2 (4.4.2). My problem is with code…
-
3
votes1
answer18229
viewsFill a vector with random values (C language)
In another of my studies in the C language, I had the idea of trying to fill a dynamically allocated vector with random numbers. However, I came across the following problem: The Rand function was…
-
3
votes2
answers169
viewsStatic library
I created a static library on C, that is, after compiled the file .c, generated a file with extension .a. In the archive .c implemented some functions. How could I read that lib in another program…
-
3
votes2
answers2555
viewsProgram in C to generate terms from a P.G
I am a beginner to the C language, and found a problem in the code below. The question is as follows: The program runs perfectly, but when inserting values such as (1-5-3), the program, which should…
casked 9 years, 7 months ago José Dantas 31 -
3
votes2
answers129
viewsSorting Doubt - C Language
I am ordering a simple vector, increasingly. The code works. But the next line that got me confused: if (matriz[i] < matriz[j]) Why is the sign there smaller, not bigger? If I want to change…
-
3
votes2
answers116
viewsLeds and Arduino board
Good night, I am programming an Arduino uno using C. I am using an RGB led on three PWM outputs. However, now appears the need to turn on more leds, hundred leds at the same time, but in addition to…
-
3
votes1
answer2021
viewsHow to program GUI in C?
What Apis give me to create GUI using C? I searched and found a GTK+ call, but I want to know the name of other libraries to create GUI using C in the same style as GTK+ but facing Windows. If…
-
3
votes2
answers3318
viewsC - How can I read data from a file (Considering that I use structures for it)
Good night. I’m working on a project for the College in C where I have a data structure to work with the data common to "Offenders," or those who committed an infraction. typedef struct Infractores…
-
3
votes1
answer516
viewsConsole cursor coordinates in C
Taking the following code as an example: #include <stdio.h> int main(void) { printf("Hello world"); return 0; } Where "Hello World" will be written in row 1 and column 1 of the console. How do…
-
3
votes1
answer223
viewsHow does this code restrict entry to a number between 0 and 4?
I was answering this question, but it doesn’t make sense to me. For me I would have to relate values less than 0 and greater than 4. I understood that I understood the inverse of alternative C.…
-
3
votes1
answer127
viewsRepeat commands to restrict a valid value
I need a code that reads a number greater than 1, and if a number less than or equal to zero is entered, another number is requested, and therefore can be tested if true. I wanted help to complete…