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
votes1
answer688
viewsHow do I write a file in c with names of several variables?
Good morning. I have a problem to be able to create a file that stores the time when the user modified a particular program, for example: If the user ran the file at 2h34min32s, I want to save this…
casked 5 years, 6 months ago Reinaldo Coutinho 1 -
0
votes1
answer1969
viewsBinary search tree in C
I need to develop an algorithm that finds the largest sum value of all nodes of the most varied possible paths of a binary search tree in C. For example, the tree: 50 30 90 20 40 95 10 35 45 It has…
casked 5 years, 6 months ago Bruno Bavaresco 1 -
0
votes1
answer1020
viewsHow to count elements of a C File?
I have the following problem to solve the college, but so far I have not seen a valid solution... I made the following code up to the time of sending since help request. // // 2.c // IFTM Exercises…
-
0
votes0
answers41
viewsBug in AVL tree implementation
I’m trying to implement an AVL tree, but when I call the Inserts function in the main and step some value(int) happens something strange. The first time the if (of the Inserts function) is…
-
0
votes1
answer55
viewsError in binary vector search
Hello, I’m having problems in an exercise where I want to pursue a certain age in an ordered vector. The error you are giving is "Expression: result_pointer != nullptr" I did a search, and I saw…
-
0
votes1
answer297
viewsC CHAR reading that works with %s but not with %c, why? And how does INCREMENT work on a pointer?
I hosted the code complete in the Pastebin: https://pastebin.com/feKaxAiz. It is a matrix where it is possible to perform the SUMMING UP or AVERAGE of the elements above the MAIN DIAGONAL. It is…
-
0
votes2
answers124
viewsPrintf does not show all variables
I am studying C/C++ in college and came across the following problem, when I run the following code: #include <stdio.h> void main(){ char name[10]; int faltas; double media; printf("Digite seu…
-
0
votes1
answer81
viewsuse Fork on linux
I started studying the function fork(2) recently and I tried to create a small program to calculate the sum of two numbers. The algorithm is made for the child process to receive two values while…
casked 5 years, 5 months ago user147847 -
0
votes2
answers75
viewsHow to print the two vector values in the pointer struct?
I made a code with struct Pessoa to save more than one note and print using pointer. My question: how do I print in function listar() the two notes I recorded in the function main()? I’m doing it…
-
0
votes1
answer171
viewsHow to return a specific element within an array?
I’m trying to return the largest among 4 numbers, for this I’m using the function qsort() available on <stdlib.h>. Follows the code: int comparison (const void *a, const void *b){ if (*(int*)a…
-
0
votes1
answer80
viewsHow to read only one line of the C file?
I’m studying file now, I just want me to be able to read a file line: I made this code, but it reads everything. I’ve tried using fscanf, fgetc, fgets, "n"; but I couldn’t find a solution. Can you…
-
0
votes1
answer40
viewsHow to correctly receive an argument by creating a thread
I’m trying to create a thread to wait a while and then create a second thread using: pthread_create(&thread_intermedia, NULL, criar_thread, &init); where init is an integer, let’s say it is…
-
0
votes1
answer97
views -
0
votes0
answers82
viewsThere are strings in my executable that I didn’t put in the source
I compile a very simple program, which has no string literals. It only deals with mathematics. Then, when examining the contents of the executable I see things like this, even if I have not typed…
-
0
votes1
answer248
viewsString in Struct - C Language
I can’t use a string inside the struct I created. Without this string, the program gives some warnings but works normally. PS: I only need help with the string error, as the error message has become…
casked 5 years, 5 months ago Stefany Alves 1 -
0
votes1
answer111
viewsComparison of equal elements and exclusion C++
I’m racking my brain to solve an exercise, I need to create a program that inserts elements into a chained list and then create a function to verify that among the elements there are equal elements,…
-
0
votes1
answer185
viewsWhen is an operating system created the compilers of ASM, C language, CPP must be created as well or are portable?
1 - AHTAH! Another crazy wanting to re-invent Microsoft - Because this me$#%%$#$ question? To give a little context to my doubt: I have always programmed in high-level languages, to solve…
-
0
votes0
answers34
viewsProblem: I have two strings, if I fill all the positions of the first string, it concatenates with the value of the second string
A simple algorithm to compare two cpfs: #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> int main(){ char cpf[11], cpfBusca[11]; for(int i = 0; i…
-
0
votes1
answer48
viewsProblems with printing float variables
Hello folks I’m solving the 1098 issue of the Judge URI, it is apparently quite simple just have to print the results of a sequence in which i goes from 0 to 2 increasing 0.2 and j that goes from 1…
casked 5 years, 4 months ago Ygor Takashi Nishi 77 -
0
votes1
answer117
viewsDoubt about reading text files in C
My problem is simple, I created a following file listing some movies: What I want is to literally read what is inside and print on the terminal, I am aware of the existence of functions of reading…
-
0
votes2
answers155
viewsVariable receiving trash
Considering this simple password validator in C: #include <stdio.h> #include <string.h> int main(void) { char buff[5]; int pass = 0; printf("\n Entre com a senha : \n"); gets(buff); if…
-
0
votes0
answers103
viewsC Pointer Vector Search
Consider a type that represents an employee of a company, defined by the following structure: typedef struct funcionario Funcionario; struct funcionario { char nome[81]; // Nome do funcionário float…
-
0
votes1
answer103
viewsHow to place a two-dimensional matrix, without defined size in a struct in C, and access the elements of this matrix by the struct itself?
I’m a beginner in C, and I’m having a bit of a problem with matrices and structs and pointers. My question is a little confusing to understand, but come on. I have two typedef, to define two types…
casked 5 years, 3 months ago Pedro Lemos 13 -
0
votes1
answer62
viewsWhat can make the texture disappear in Opengl?
I’m using a flame engine Engo, and made a Fork and I’m adding some things and at the same time trying to learn more about Opengl. As it is a graphic question there is how to put an image of what is…
-
0
votes1
answer102
viewsRemove an element previous to the element specified by the user in a List. C
I have to create a program, which will create a dynamically double-chained list and this program should do the following: the program will read values that the user writes and add to the list. Then…
-
0
votes1
answer57
viewsDoubt to return arrays on pointers. below is the code I tried, but only returns addresses
Good night, you guys. following, I would like a help to return a vector, whose goal is to implement a function that takes an integer vector V and returns another integer vector dynamically allocated…
-
0
votes1
answer61
viewsScan string in multiple of 3
People how to scan a string every 3 characters? I was doing like this for(x=0;str_P[x];x++){ if (str_P[x] == 'ABC'||'abc'){ printf("1,"); }if(str_P[x] == 'CBA'||'cba'){ printf("2,"); }if(str_P[x] ==…
casked 5 years, 2 months ago Axion Ions 19 -
0
votes1
answer52
viewsPointer
Good afternoon, I am trying to solve an exercise of a college subject, however I am not able to correctly manipulate the use of pointers, follows down the statement and the code. We have seen that…
casked 5 years, 2 months ago Guilherme Oliveira 43 -
0
votes0
answers33
viewsDoubt in stdin flow of scanf() function
Greetings to all. I am a beginner in C and I came across the following question regarding data entry; int number1,number2; printf("Digite o numero : "); scanf("%d",&number1); printf("Digite…
-
0
votes1
answer249
viewsI cannot execute some C codes by Sublime Text 3
I have a folder with some simple C codes, I can compile, but the code does not run correctly in the terminal of sublime text 3. Does not return any information or display this message due to the…
-
0
votes2
answers526
viewsC++ program for day of the week (with code example)
It is known that the day of the week of a date provided between 1° March 1700 and 28 February 2100 can be determined by the following method: n=int(365.25∗g)+int(30.6∗f)−621049+d…
-
0
votes0
answers51
viewsPython ctypes ERROR: Exception: access Violation writing 0x00DEF6CC
I’m trying to import a dll C/C++ with the lib ctypes and use a function that it has internally, when passing the parameters to this function I always come across the error: ERROR: exception: access…
-
0
votes1
answer30
viewsAfter finding the answer to the question does not end the application
The question is, the first question would be if it is reptile and then if it has hull, the answer will be turtle, but even if the answer already appears the algorithm continues, before it closed…
-
0
votes1
answer22
viewsUnexpected exit on my variable!
# include <stdio.h> float calcula_media_ponderada(int N_1, int N_2, int Peso_1, int Peso_2) { float Media; Media = ((N_1 * Peso_1) + (N_2 * Peso_2)) / (Peso_1 + Peso_2); return Media; } int…
-
0
votes3
answers95
viewsIf counter in a text file
Guys I’m trying to make a program that counts the number of ifs in any text, but for some reason it doesn’t count all, if you can help me thank you #include <stdio.h> #include <stdlib.h>…
-
0
votes1
answer66
viewsForce user to enter integer numbers in an array
Person, what would be the best structure to force the user to enter positive integers within an array (array), the code fragment I copied here is inside a function, it works ok when first executed,…
-
0
votes1
answer43
viewsError printing accented character in C!
# include <stdio.h> # include <stdlib.h> # include <locale.h> int main() { setlocale(LC_ALL,"portuguese_Brazil"); int Quantidade_De_Clientes, i; float Saldo_Total, Media_Total;…
-
0
votes1
answer31
viewsPseudo-Object Orientation in C and Dynamic Allocation
I’m trying to make a minefield in c using ncurses. h and when I’m going to do the vector of "bomb objects" Linux says it can’t find the memory space in which the values of the bombs are: PS: no I…
-
0
votes2
answers326
viewsNumber represented as sum of square of consecutive primes in C
I’m working on a code, but I can’t figure out what’s wrong. The sequence only works for the first input, and then simply erases. The user is supposed to enter any number (0 to 10ˆ8) and the program…
-
0
votes2
answers359
viewsHow to intersperse the values of two rows in C, in a third row?
I am trying to intermediate the values of two rows in C, F1 and F2, in a third row, inter, as function below (n would be the amount of F1 and F2 elements): Fila *intercala_fila (Fila *f1, Fila *f2){…
-
0
votes1
answer20
viewsProblem alternating fgets and scanf_s
I have a problem that the user has to enter the name and age of 5 people, and have to print on the screen the name of the younger person. I made the following code #include <stdio.h> #include…
-
0
votes1
answer69
viewsI’m having trouble separating an integer from a variable
Good morning Guys, I’m having trouble on the following issue. Write a program that receives a time provided by the user as a single integer (hhmmss) and write time in the form: hh:mm:ss. The program…
-
0
votes1
answer127
viewsCode with if and Else does not work
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> main() { int n1, n2, n3, n4, n5, ma, mp, mav, mev, dp, p1, p2, p3, p4,…
-
0
votes1
answer51
viewsStack algorithm problem in C (Struct and function do not "recognize")
Hello, I’m starting in the study of data structures and one of the algorithms passed is for data increment in a vector as in a stack (ie, the last incremented is the first to come out) I am in the…
-
0
votes1
answer144
viewsSquare and cube of the same variable in C
Good guys, I have a question. My teacher was teaching functions in C and asked us to do a function with a variable that calculates the square and cube and prints the two. My code so far has remained…
casked 5 years ago João Marcelo Tavares 3 -
0
votes1
answer799
viewsHow do I use if inside the for, without the outside if appearing?
printf("\nDigite o usuario que deseja pesquisa, pela Matricula: \n"); gets(strL); busca=atoi(strL); for(i=0; i<quant; i++) { if(busca==dados[i].matricula) { printf("Aluno: %d\n",i); printf("Nome:…
-
0
votes1
answer449
viewsSave data from one vector to another vector in C
I have a code where I am reading character by character within a file and saving them within an array called "input". I am using a comma (the 44 character of the ASCII table) as the stop character,…
-
0
votes1
answer81
viewsreplace drop by loop
I am making an options menu, with input option 1 or 0 and I want to appear an error when not typed 1 or 0, and so on until the user chooses a valid option and so the program redirects the user to…
casked 5 years ago Víctor Vianna 19 -
0
votes1
answer254
viewsalgorithm that finds prime numbers in an interval
I’m having trouble with this code, I’ve seen it in many places how to fix it, but I can’t really find the error, it prints out values of the whole range, not just primes. // The program will inform…
casked 5 years ago Víctor Vianna 19 -
0
votes1
answer51
viewsStruct in C print nothing
Hello, I am doing a program for college and have to add books in a struct and then print your data, I created a menu of options and used ifs as a switch, one of ifs is used to add books to struct…