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
-
4
votes1
answer158
viewsHow to receive input data from a C program from a file?
I have a program in C. Let’s assume that its name compiled is a.out (pattern). When I use the following command to execute it... ./a.out < arquivo.txt ...how do I read the content of arquivo.txt…
-
4
votes2
answers14165
viewsDynamic allocation for struct
I need to dynamically allocate space for a structure, but I am not able and I do not know my error is at the time of the statement or allocation, follow the functions consistent with the statement.…
-
4
votes3
answers2449
viewsHow to do terminal loading effect on just one line?
How can I do a loading effect by refreshing a terminal line when running a program in c? Example: carrying... points are increasing. I can do this effect in a while loop but just cleaning the screen…
-
4
votes5
answers294
viewsProblem with calculator program
Good morning, I would like to know, why is my calculator program not printing the value of operations?? Below is the code: #include <stdio.h> int main (void) { float A, B; char op; scanf("%f",…
casked 9 years, 7 months ago Gabriel Vinicius 339 -
4
votes3
answers4136
viewsProgram does not read scanf
I am doing a school job, doing a blackjack (21) on C. In a certain part of the program, I created a while (while the option is yes) to show the cards, the score and ask if the user wants to bet…
-
4
votes1
answer509
viewsPlay Sound (WINDOWS)
How do I play sound in a program developed in the C/C language++? Environment ()
-
4
votes4
answers1177
viewsHow not to repeat terms on printf
I have another problem. My activity this time is to create and read the elements of two vectors, A and B, with 5 and 7 values, respectively. Then the program will show which elements are repeated.…
-
4
votes1
answer216
viewsHow to manipulate Widgets from the main window through a signal function ( C and GTK+)?
I have very little experience and am coding a program for a college job. I am using the GTK+ 2.0 library. There are several widgets in the main window, among them a button that I connected to a…
-
4
votes1
answer536
viewsDisplay student grade in C
I wanted to display the student grade when all the notes were typed, in an array of 10 positions, I tried out for, but it returns me only the last. #include <stdio.h> #include <stdlib.h>…
-
4
votes1
answer3307
viewsIs OS development restricted to beginners?
One thing I’ve always wanted to do is develop my own operating system (not necessarily as good as Linux or Windows, it would have some basic functions at prompt). I’m not a complete beginner in this…
-
4
votes2
answers1591
viewsWhat happens when I convert String to an array of bytes?
I have: String msg = "Texto a ser encriptado"; byte array[] = msg.getBytes(); What happens when I convert the string to an array of bytes? I’m concerned about an application I’m developing. I need…
-
4
votes2
answers260
viewsDoubt about pointers
This code creates matrix, initializes and prints, as well as adding, subtracting and multiplying matrices: typedef struct{ int nl; int nc; int **elementos; }MATRIZ; void criar_matriz (int, int,…
-
4
votes1
answer61
viewsFORTRAN and C interoperability
Each language has a unique character, that’s a fact! However, how to work with code C in FORTRAN and vice versa? It is possible to enter the code FORTRAN in the C with the directive # include…
-
4
votes1
answer4972
viewsPrint data from a dynamically allocated two-dimensional matrix
I would like to know how I print the information collected in Cria_matriz using the function Prints. This is the code I have done so far: #include <stdio.h> #include <stdlib.h> float…
casked 9 years, 8 months ago Bernardo Kowacic 567 -
4
votes2
answers1045
viewsCalculation to determine whether triangle is rectangle gives no expected result
The program I created takes three integer values, calculates within the if these values and if the condition is correct it should show on the screen the YES (the triangle is rectangle), and if the…
-
4
votes2
answers225
viewsSource code in Projects
If I have 10 projects in Netbeans, these 10 projects will use a log recording system, this system contains a log. h and a Log.c. Since all projects will have to use these two log files to generate…
-
4
votes3
answers4312
viewsHow the end of file loop is done
Type, I know that the function feof() returns 0 if it did not find a file end and that it requires 1 parameter, which is the pointer_pra_variável_tipo_FILE, so far so good. If I do the while so it…
-
4
votes2
answers1216
viewsCompare two strings with C accentuation
I have the following problem, I need to compare two strings ignoring the accent, for example: Étnico | Brasil Using a normal comparison function it is returned that "Ethnic" comes before "Brazil" in…
-
4
votes2
answers4158
viewsHow to create a dynamic chained list within another dynamic list in C?
I’m having a really hard time creating a dynamically chained list inside another one using data structure. I can create a dynamic list, but I can’t create another one inside it. To illustrate what I…
-
4
votes1
answer315
viewsHow to use Javascript JSON to recover C result?
I learned that JSON is used to communicate between systems. So it is possible to communicate with C, recovering variables through a JSON generated by the code and sending through the Javascript AJAX…
-
4
votes2
answers7055
viewsWhat is the purpose of the sizeof command?
What is the purpose of the command sizeof in c language? I know I can use it to allocate memory and create vectors dynamically as follows vetInt = malloc(sizeof(int) * tamanho);. Other than that…
-
4
votes2
answers122
viewsDoubt - Logic of numbers changing places
I’m trying to put together a C algorithm to find integer numbers that change places by multiplying by another. I haven’t found problems like this on the Internet, I don’t even know if there’s a way…
-
4
votes3
answers633
viewsLoop variable declaration error
I made the following command: for(int i = 1 ; i <= 3 ; i++) {etc } Then it made the following mistake when I went to compile: game.c:11:2: error: "for" loop initial declarations are only allowed…
-
4
votes2
answers12278
viewsC: Change color of letters (multiple colors on one screen)
For example, I want print on the same screen: printf(".___. .___. .___.\n"); printf("._1_. ._2_. ._3_.\n"); printf("Digite 0 p/ sair ou outro número p/ continuar: "); but I want the letters of each…
-
4
votes1
answer196
viewsProblem reading strings
I’m making an algorithm that gets the number of affairs, then a name with surname, one color and a size. He must make a comparison and print them ordered by color in ascending order, size in…
-
4
votes2
answers400
viewsReading an array of a file
I am wanting to read from a file that has an array inside, the amount of rows and columns and printable on the screen, but my program does not appear anything, it simply stops and does not print the…
casked 9 years, 5 months ago Gabriel Vinicius 95 -
4
votes1
answer898
viewsHow do bit operators work?
I have the following code: volatile long Hex_To_int(long Hex , char bits) { long Hex_2_int; char byte; Hex_2_int = 0 ; for(byte = 0 ; byte < bits ; byte++) { if(Hex& (0x0001 << byte))…
-
4
votes2
answers815
viewsWhy declare pointer to array if arrays are already pointers?
if an array char is already a pointer, why declare a pointer to the array? And what’s the difference between char exemplo[10] and char *exemplo[10]?
-
4
votes2
answers212
viewsCreating buffers in PHP
Staff need to create in PHP a buffer (string) from a data set (array) to send via socket. In this buffer i want all attributes of the set that are stored in it, obey its size. Example: Whether I…
-
4
votes2
answers109
viewsUnix and linux are reserved words?
Even if the variables are not declared unix and linux and even without including anything in my teste.c compiling with the GCC on Linux have: Compilation gcc teste.c -o teste Execution ./teste Exit…
-
4
votes1
answer666
viewsGenerate random number between -99 and 99
I’m having some difficulty here in my code which is the following, I know that to generate random numbers between 0 and 9 is - x = rand() % 10. So now I wanted to generate numbers between -99 and…
-
4
votes2
answers630
viewsJava Fork/Join Does it work the same as C Fork?
Discussing with a friend about a matrix calculation solution that we are developing, the following question arose. Java Fork/Join Framework operation is equal to C? Reading a little I could not…
-
4
votes1
answer67
viewsInclude a. c file inside a project. c
I am developing a simple program to deliver at the end of the first semester and would like to know if it is possible to create a main project and make the menu in one menu.c separate. Then include…
casked 9 years, 1 month ago Marcielli Oliveira 1,597 -
4
votes1
answer1450
viewsManipulating batteries in C
I’m a C beginner and I have the following exercise: The Parking Stationhere contains a single boulevard that guards up to ten cars. There is only one entry/exit in the parking lot, in one edge of…
-
4
votes1
answer94
viewsNested pointers and references
I’m having a doubt in the interpretation (the way I read my code) on pointer assignments in the C language. I did not understand the logic of the following assignments: "If i and j are whole…
-
4
votes5
answers5371
viewsSplit a string with empty spaces
I’m trying to divide an entrance of the following kind: 1444771699,Andre Alves,SAQUE,-500.00,,200 I’m trying to use the strtok, but it ignores the empty space. Any idea of how to split the string…
-
4
votes4
answers3096
viewsrecursive superfatorial problem
I have a doubt in the realization of this recursive function of mathematics. Calculation of the superfatorial: The superfactor of a number N is defined by the product of the first factorial N of N.…
-
4
votes4
answers872
viewsI need different ways to rearrange characters within a string, how do I do that?
I would like answers in C, C#, or just an algorithm, but preferably an implementation already in the C# language because that’s what I’m using. For example, suppose I have to find out if a number is…
-
4
votes2
answers1313
viewsC++ - Stop condition in repeat structure
How to put this code in a repeat structure so that after the calculation is shown the option "Type S to exit or C to continue"? #include <iostream> #include <string.h> #include…
-
4
votes3
answers847
viewsFactorial is not being calculated
Make a program to read an array A of type vector with 15 elements. Construct an array B of the same type, each element of matrix B being the factorial of the corresponding element of matrix A .…
-
4
votes2
answers468
viewsCheckbook batch sum, total value and validation
Write a C program to validate a batch of checks. The program should initially request the sum of the batch and the number of checks. Next you should read the value of each check by calculating the…
-
4
votes2
answers421
viewsHow to write a recursive function?
I’ve been tasked with making this function recursive, but I have no idea how to do that. int existe (int x){ FILE *arq; int y; char buf[MAX]; arq = fopen ("cliente.txt","r"); fgets (buf,MAX,arq);…
-
4
votes1
answer2274
viewsChained list without head in c
I wonder how I create a function to remove at the top of the list headless. #include <stdio.h> #include <string.h> #include <stdlib.h> #define MAX_NOME 50 typedef struct pessoa{…
-
4
votes1
answer6989
viewsDouble chained list in C
Edited code I’m having trouble removing function #include<stdio.h> #include<stdlib.h> #define MAX_NOME 50 typedef struct pessoa{ char nome[MAX_NOME]; int idade; }Pessoa; struct celula{…
casked 9 years, 2 months ago Matheus Francisco 650 -
4
votes1
answer152
viewsTyping a pointer to struct
I was suggested to build a chained list using the following struct knotted: typedef struct node *link; struct node{ int item; link next; }; As I did not understand what the pointer operator means…
-
4
votes1
answer229
viewsSegmentation fault when accessing pointer content
I need to declare a pointer vector, which will point to types float, and make a simple reading of values. The program compiles but after typing 4 values I get a Segmentation fault (core dumped). Why…
-
4
votes2
answers108
viewsCast in sockets
Guys wanted to understand what the reason of doing these cast below is just by aesthetics? What does it really affect in the code? struct iphdr *ip; char *buffer ip = (struct iphdr*) packet; icmp =…
-
4
votes1
answer1154
viewsChained lists in C
I have two lists in C, where you should include several records in the list of customers, and then make sure that some customer can book a car that is stored in the list of cars. The part of…
-
4
votes2
answers180
viewsVery large integer does not work
My code is like this: #include <stdio.h> int main() { unsigned long int L, N; scanf("%lu%lu", &L, &N); printf("%lu\n", (L-(N-1))*(L-(N-1)) + (N-1)); return 0; } When the test case has…
-
4
votes1
answer12161
viewsHangman game with C functions
I’m trying to make a game of hanging in C to go learning better, even because I need to learn more functions such. While the game is running, I wanted when the user put a letter, it would appear…
casked 9 years ago Marcielli Oliveira 1,597