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
votes2
answers82
viewsDoubt with recursive function in C
Good night, you guys! I am performing an activity whose goal is to use a recursive function to perform a whole division only through successive subtractions. I made a while loop and only it (which I…
-
0
votes2
answers76
viewsProblem in the scanf, infinite loop
When I put a char on scanf the program printa lot of "height" and does not give me the chance to choose another value, only enters an infinite loop. Code: int main() { int result; while(result <…
-
0
votes1
answer77
viewsWhat is the best way to make an if-lse?
The two examples below are equivalent, but what represents the best way to make a if-else? My goal is to display "num é igual a 0" if num is equal to 0, and "num é diferente de 0" case num has any…
-
0
votes1
answer41
viewsI wanted to understand the exit of this code
I’m trying to make a simple code that takes more than one sentence and puts it in an array of size (number of sentences) N. I was able to make a code but with the size of the array already defined:…
-
0
votes1
answer152
viewsHow to write read information from a . csv file to a C Language struct
I’m needing to open a . csv file and save your information in a struct array I need the way out: Code - Region - UF - Date But you’re being: Code - Region - UFDATA - DATA I would like to know what…
-
0
votes0
answers27
viewsPointer matrix with no type and variable size in C
I am creating a game for my college work and need to read a txt file to build a level (phase) of the game. The txt example can be accessed here: https://pastebin.com/f778Ucxa. The dash represents an…
-
0
votes1
answer33
viewsProblems in C file creation
Good night! I am trying to create a txt file from a client list, for this I created a looping in order to store 2 clients and I hope that the created file stores this data in txt, however it is only…
-
0
votes2
answers114
viewsI’m doing a c job for college in case anyone can help
I made my code normally, but when it comes to testing it right for some and wrong for others, besides varying the answer depending on the compiler if you think the error would help a lot. #include…
-
0
votes1
answer71
views -
0
votes0
answers12
viewsCannot compare variables in C
My code should recognize the character "(". But unfortunately it does not recognize, and I do not know why. Breakable Ahead starts with "(", but when I compare it to '(', it falls on the last Esol,…
-
0
votes0
answers24
viewsGet specific value from a file
Hello, how are you? I have the following file format: username=teste1; status=ONLINE; username=teste2; status=ONLINE; username=teste3; status=OFFLINE; Where one of the lines represents the user name…
-
0
votes0
answers55
viewsProgram enters Infinite Loop - Problem "Horse Ride" in C
The problem of the horse consists of which, the horse is placed on the board emptiness and, following the rules of the game, need to go through all the houses exactly once in consecutive moves. ie…
-
0
votes0
answers37
viewsI’m having trouble storing a value in the C struct
When it comes to printing, they are somehow superimposed. I have no idea what it might be. The FOR is strange because it is necessary that Tsala data[FLOOR][ROOM][TURN] be this way and in that…
-
0
votes2
answers59
viewsFunction in C that counts how many times the string appears in a file
I need to make a function that receives as parameters a pointer for a string and the name of a file and return to the main how many times the string was found in the file. I only managed to get her…
-
0
votes1
answer23
viewsProblem with spaces and structs in C
I’m starting to learn about C structs, but I’m having trouble trying to store data in user-filled empty strings. When the user inserts a product description at the first time of the repeat loop, the…
-
0
votes0
answers26
viewsVscode compiles and debugs but does not execute C programs
After configuring Visual Studio Code to compile and debug C, I am unable to run the code. A . exe that works properly, but for reasons of practicality, I wish the output and input of data to be…
-
0
votes1
answer91
viewsDoubt in variable manipulation in C
The following code uses the decision structure to choose the command consistent with the operation chosen by the user. How could I simplify that? I tried to modularize instruction printf but I…
casked 3 years, 10 months ago David Faria 15 -
0
votes0
answers20
viewsWhat is the best way to synchronize these C threads?
Considering the following code, what is the best way to synchronize the threads that add the vectors with the threads that populate the vectors ? I have tried several ways, such as mutex and/or…
-
0
votes1
answer59
viewsHow to do an operation using the CHAR variable TYPE?
Follow two codes. The first makes the desired operation with if and else. The second (which I am doubtful about) I try to recognize the char typed as an operator to perform the operation. #include…
-
0
votes1
answer37
viewsError assigning malloc to an integer in C language
Hello I’m following a tutorial on Youtube about dynamic memory allocation in c language, but I’m getting an error regarding the attribution of a malloc() to an integer type variable. The strange…
-
0
votes0
answers39
viewsHelp with C Vectors
Staff helps me out on a C. I have a lottery question. My lottery looks like this: 5 numbers from 1 to 60 and 1 number (sixth) from 1 to 4. I generated an X vector to generate 5 random numbers…
-
0
votes1
answer79
viewscompiles code but does not work, just successfully finishes
Well I am new to the C language and I decided to venture into the world of multithreads, I thought of making a program that would find primes in a range from 1 to N, and for that I would divide the…
-
0
votes0
answers22
viewsMultithreads running the same function in parallel
I’m trying to get this code to run the function calculaPrimo() on each thread in parallel to find prime numbers in a range of 1 up to the maximum value passed via command line, for example if the…
-
0
votes0
answers33
viewsHow to do cellular and date validation in a C++ application
Hello, I am a beginner and I have an activity to do, I need the following steps: . In the cellular attribute, it is necessary to validate the input so that numbers are accepted within the range…
-
0
votes1
answer56
viewsHow do I pick up two values obtained in a function through pointers?
I am building a program, whose enunciation is to make the user provide 20 numbers and these are analyzed as pairs or odd. In this case, the intention is to create a vector A that takes 20 integers…
-
0
votes1
answer39
viewshow to do a subroutine on e1_insert,
Guys, I CAN NOT create a subroutine for the 'e1_insert' function (SECOND SNIPPET). This function will be called every time you want to insert a drink. In this piece of code that I put here, it is…
-
0
votes1
answer49
viewsAdd nodes to the chained list using loop
I did not find any similar question, in case you have, please indicate and I delete the post. How to create a chained list so I can use a for loop to put the nodes in the list. I’m using two…
-
0
votes1
answer65
viewsHow to pass a char vector * (*) to a function?
Guys, I have this code: #include <stdio.h> void exibir_nomes (char *nome) { for (int i=0; i<5; i++) printf("Nome[%d] = %s\n", i, *nome); } int main () { char…
-
0
votes0
answers36
viewsPointer pointer in C
Come on, guys, I’m trying to understand the pointer-pointer behavior, but I can’t figure it out. Well, I already have an idea that the pointer points the memory address of something, to another…
-
0
votes2
answers90
viewsPrintf() showing strange characters
The purpose of the code is to show all substrings of the variable firstString that has the same size as the second string that is the variable secondString. However, when I use the printf("%s\n",…
-
0
votes1
answer38
views -
0
votes1
answer44
viewsHow to write a function that returns appropriate values of a date (day, month and year) so that these are assigned to struct-type variables?
I wanted to develop a function responsible for analyzing the format of the date inserted, however the appropriate values would have to be returned to another function responsible for registering…
-
0
votes1
answer65
viewsProblem assigning values to a struct in C
Hello, I know how to program in other languages but I’m a beginner in C and I’m burning my brains out doing a job for the college that asks to store information of 10 vehicles in an array of…
-
0
votes0
answers51
viewsMake two functions act simultaneously
I need to make a Duck Hunt style game in C is almost everything ready, but we are not able to make the target move at the same time as the projectile, what happens is that we press to shoot, and…
-
0
votes1
answer30
viewsThe variable of a vector is replacing that of another vector, only in a specific case
When vector 3 is 5 in size, vector 2[0] will receive, even though it already has an assigned value and without any command to do so, it receives the vector value 3[4]. Whether this occurs only when…
-
-1
votes1
answer107
viewsProblems with Dev-cpp
I installed Dev-Cpp 5.5.1 and it presents an error like this when I try to compile: "Failed to execute (and the file path)". Can someone help me with that? I already tried version 4.9.9.2 and the…
-
-1
votes3
answers121
viewsProblem with the C
I’m with the [Error] expected expression before '<=' token, with the following code: #include <stdio.h> #include <stdlib.h> int main () { float VS, VF; printf ("valor do salario: ");…
casked 11 years ago matheus ferreira 357 -
-1
votes2
answers167
viewsscanf shows number always as pair
I have a problem and I don’t know how to solve it because I’m starting to use Dev-C++ now. I don’t know much about him, the problem is the following I managed to solve an error I was having, which…
-
-1
votes3
answers5814
viewsError 'Else' without a Previous 'if'
I got a problem and I don’t know how to fix it. The program in C that I developed this presenting several types of errors and do not know what could be: #include <stdio.h> #include…
casked 11 years ago matheus ferreira 357 -
-1
votes5
answers1352
viewsPrevious "Else" without "if" error
I am trying to correct and always erring in the same place, always with the if and the else or between them. The problem always occurs with other codes. #include <stdio.h> #include…
casked 11 years ago matheus ferreira 357 -
-1
votes4
answers409
viewsHow to transform, for example, "0" to "ZERO" in C? What problem in this code?
I have to do a program for college whose main objective is another, but in one of the stages of the program, I need to pass two integer random numbers from 0 to 9 for their extensive written…
-
-1
votes1
answer123
viewsCan be improved
Good to have how to improve? I believe so. But improve what? the code make it lighter, improve performance these things. I would like tips and as I am still studying. I will post below 3 vector…
casked 10 years, 8 months ago Leonardo V. De Gasperin 713 -
-1
votes1
answer490
viewsRead the elements of a struct in another function
I need to access data from struct in my job CalcN, how should I proceed? int main(){ int calcn(); struct user1{ string Nome; int Dnx; int Nxhu; }; struct user1 x; x.Dnx = 4; x.Nxhu = 3; int…
-
-1
votes1
answer896
viewsOpening and reading giant C files
How can I open a file for reading in C language, above 100 MB? With this code placed below, I can read a file with more than 18,000 lines, but what I really need is to read a file with approximately…
-
-1
votes1
answer68
viewsCompiler error in code
I’m new to the C language. #include <stdio.h> #include <stdlib.h> int main() { char card_name[3]; int count = 0; while(card_name[0] != 'X') { puts("Enter the card_name: "); scanf("%2s",…
casked 10 years, 5 months ago Leonardo Oliveira Santos 1 -
-1
votes1
answer142
viewsSaving stream in a file
I have the following problem, saving the struct, the position 1, ends up losing the value of street, city and state. I do not understand why this happens if in the following positions it allocates…
-
-1
votes1
answer74
viewsProgram runs but does not respond
I am programming a simple TCP/IP server on Linux, but after running it on the terminal, I get no answer, nor even print a line that I should print at the beginning of the program. When compiling…
-
-1
votes2
answers113
viewsCalling function without signature knowledge
If I have a function called calculator() in C. And I want to call this function, obviously I would call it by name, ie by her signature. But if I don’t know the signature of this function, and its…
-
-1
votes2
answers7835
viewsWhat is the difference between c and c++
I am starting in programming and would like to know the difference between c and c++ and which should I start to facilitate studies.
-
-1
votes1
answer103
viewsQueues with checks and customers
I want to create a Checkbook Or Pool.. of checks.. as if it were a Queue waiting (FIFO) and I have some difficulties. For now the code I have is giving me some errors. I’m having such mistakes:…