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
votes4
answers316
views"Pure" structs (no pointer) and C error handling
Messing with data structures (filas, pilhas, etc), I reached an impasse in trying to create search functions for these structures. By default, functions that can contain errors return 0 or even -1…
-
1
votes1
answer207
viewsIs it correct to clean an internal malloc to a function with it?
Well given the following code is easy to do memory management: Code Example (in C): #include <stdio.h> #include <stdlib.h> int *criarValor(void){ int *valor = malloc(sizeof *valor);…
-
1
votes1
answer350
viewshow to write a name using pointers
I need a program that uses memory heap to store any name. input we have the number of characters of the name and then the name, for example: 32 Josefina Penacho Reis dos Santos The output must be…
-
1
votes1
answer58
viewsIs it possible to include Allegro in a C kernel?
I have been studying for some time the construction of Operating Systems with bootloader in Assembly and kernel in C, and recently I started studying Allegro. Theoretically it is possible to include…
-
1
votes1
answer74
viewsWhy, within the function, is the program not comparing correctly?
The program receives the number of questions, the number of students, creates a vector of type char for the feedback and compares with the result of the other students, in a matrix, but within the…
casked 9 years, 5 months ago Gabriel Vinicius 339 -
1
votes1
answer1157
viewsAid on a family tree in C
Good afternoon, I need to build a family tree in c, but I only find examples with numbers that are compared, and if it is smaller than the previous one, the same is played to the left, but my doubt…
-
1
votes1
answer8213
viewsError compiling C in gcc: No such file or directory
I’m trying to compile a file. c but I’m not getting it. I type the following command: gcc main.c -o HELLO and the following error appears: gcc: error: main.c: No such file or directory gcc:fatal…
-
1
votes1
answer79
viewsError Segmentation fault
And having a problem with my job, I’m getting her address and I’m going through it, where it’s uppercase I convert to minuscule and wherever there’s a dot, exclamation, interrogation, two dots and a…
casked 9 years, 5 months ago Gabriel Vinicius 23 -
1
votes1
answer64
viewsRead a vector to a stop bit
I want to read an 8-bit binary vector backwards and stop until I read the last 1. For example: [00010101] <--- Read until you find the last 1 Vector read: [1010] Then associate a function for…
-
1
votes1
answer556
views -
1
votes1
answer51
viewsAllegro does not perform anything graphic
It simply does not appear anything graphic, the functional (close the window) works perfectly, but the graphic (background color and "ship") do not work. #include <allegro5\allegro.h> #include…
-
1
votes1
answer743
viewsSocket TCP in C
I’m having trouble sending a 32k buffer from a client to a server. For example: I have an A program on one machine, which is the client, and a B program on another machine, which is the server. When…
-
1
votes0
answers94
viewsSending an icmp echo in C
I’m studying the use of raw sockets and its functioning in the C language, but I was left with a doubt: When I send echo, I need to give value to the checksum of my icmp header that will send the…
-
1
votes1
answer112
viewsBest way to distribute program using a Shared library
I wrote a program that uses a library called curlpp. The program is very simple and all it does is make an HTTP request that returns a JSON (use the curlpp to perform this request), parse this JSON…
-
1
votes1
answer67
viewsMatrix with dynamic columns?
I have a matrix like this: int numeros[qNum][6]; In reality it stores an integer number per line, separating the digits, for example: I have the number 1234, in the matrix will be: numeros[0][0] =…
-
1
votes2
answers241
viewsExtensive matrix makes the program stop working
I have the following problem, when I define a matrix that is very large, for example: int matriz[2000][2000], compile and run, the program stops working. I tested only on Windows and it appears that…
-
1
votes1
answer135
viewsProblem with Segmentation Fault
I’m creating a program that simulates a minefield, and option number 1 should take from a computer file an array (that contains points (where there is no bomb) and asterisks (where there is bomb)…
casked 9 years, 3 months ago Gabriel Vinicius 45 -
1
votes1
answer45
viewsDoubt debugging a program
I was debugging a program and I came up with the following question, had architecture is 32 Bits Intel and had the following instruction MOV EAX, DWORD PTR SS[0X401049], and below that instruction…
casked 9 years, 1 month ago alexsander 483 -
1
votes1
answer79
viewsError in . / executable
Good afternoon, I have this error when it comes to compiling the program: * Error in `./executable': realloc(): invalid next size: 0x00000000012d12f0 * Aborted (recorded core image) My program…
casked 9 years, 3 months ago Gabriel Vinicius 45 -
1
votes2
answers181
viewsCompiling C for raw binary
How to compile a C code for low level? (.bin, example). I’m using IDE Code::Blocks, and the mingw compiler (I’m on Windows, but if you know for Linux the commands are almost identical).…
-
1
votes2
answers208
viewsHow do I force entry into "while"?
This program allows to calculate the table from up to 10 to a given number x. But in the cycle of the while after the first iteration it does not enter and jumps to the end. For example, if I insert…
-
1
votes1
answer118
viewsOptimization of Cache Memory usage
I received a code implementing Dijkstra in C, and my mission is to optimize this code. The code is this: #include <stdio.h> #include <stdlib.h> #include <string.h> #define…
-
1
votes1
answer629
viewsOpen a file using secondary function
I need to create a function that "points" a file pointer to a particular file in computer memory. I was able to do this: #include <stdio.h> void abre(FILE*); void procedimento(); int main () {…
-
1
votes1
answer41
viewsAccess memory allocated on a pointer
If I have a pointer vector of the type *p[tamanho], in which each position will be occupied by p[tamanho] = malloc(10*sizeof(int)), how to access each position of this vector allocated with the…
-
1
votes2
answers582
viewsDoubt pointer cast
Folks when you got a line like this: u_char variavel_teste struct teste *p ; p = (struct teste *)variavel_teste; What is the use of this , and what it means, can you give me an example of a program?…
casked 9 years, 1 month ago alexsander 483 -
1
votes2
answers783
viewsHow to pass a . sh file as parameter to a C code?
I need to pass a file with extension . sh . I have tried it as follows and the value that is read from the file is wrong: . /program . /file.sh How do I get this argument through? Do I need to add…
-
1
votes2
answers172
viewsError in reading, strings and integers
#include <stdio.h> struct tetris{ char nome[16]; int pontuacao; }; int main(){ int i, nteste = 1, J, k, total = 0, maior, menor, pontos; while (scanf("%d\n", &J) && J != 0){ struct…
-
1
votes2
answers147
views -
1
votes0
answers443
views -
1
votes1
answer254
viewsDynamic allocation and pointers in Lua
I would like to know how I make dynamic allocation and pointer of a structure in Lua, I have the following instruction in C that I need to pass to Lua; typedef struct ilha { char name; struct ilha…
-
1
votes3
answers3092
viewsHow to make an integer store a 12-digit number?
I need to find the largest prime factor of the number 600851475143. Because it is a very large number, I cannot store it in a normal integer type variable. The code I made to find the largest prime…
-
1
votes1
answer119
viewsPointer use
I need to use pointers, but I’m not sure how to express the syntax, it’s part of the goal of the task (change the value of the parameters passed by reference to the functions, such that these…
-
1
votes2
answers89
views -
1
votes1
answer542
viewsGiven a list of words, return the size of each descending anagram group
I have a file with a list of words, each in a line of the txt. I need to group those that are anagrams and return the size of the group, in descending order. Follow an example: cat, bed, aeds, drop,…
-
1
votes0
answers155
viewsHow to create a System Call to extract data from an ongoing process?
I need to make a System Call that receives a PID as parameter and returns the number of bytes that this process read from the standard input, disk, and how many bytes it wrote on the USB port. As I…
-
1
votes1
answer330
viewsConcatenate string with integer array and write to file?
I have a dynamic vector of integers. For example: 1 2 4 6 8 9 10 I want to attach it to a string, like this, for example: [B]: And record this in a row of the file, then read the file with the…
-
1
votes2
answers129
viewsHow to do operations between functions in C?
The function funA() stores a value entered by the user. The function funB() will allow the user to choose an option. My difficulty is in the third function: I need to create a function that…
-
1
votes1
answer92
viewsDynamic Vector + Dynamic Allocation
Good afternoon, I would like to know how to create a dynamic vector in C, to store the following information: host(on, off, broken) | time_total_status to display on the screen, as if it were a…
-
1
votes1
answer924
viewsArrange search function in double chained circular list
People have how to arrange my function to seek or give the idea of error ? I have to fetch the name of the person who is inserted in the list and remove this function with a bug vlw hug. #include…
casked 9 years, 2 months ago Matheus Francisco 650 -
1
votes0
answers68
viewsCalling C for R?
How do I program in C inside the R or call a code of C in R? I’ve read a few tutorials, but I don’t quite understand.
-
1
votes1
answer90
viewsWhy do I get this Segmentation Fault?
Why when I declare: char *s = "string"; fscanf(stdin, "%s", s); I get a Segmentation Fault?
-
1
votes2
answers83
viewshow to capture what is printed on the console via a command into a vector in C language
When I do some commands on the linux console, for example man fprintf, is printed on the screen a series of information. I need to collect this information that is printed on the screen but instead…
casked 8 years, 11 months ago user3903094 75 -
1
votes2
answers313
viewsHow to access the pointer of a struct within the pointer of another struct?
typedef struct vertice { int num_vertice; int profundidade; struct vertice **vertices_adja; } Vertice; typedef struct grafo { int qtd_vertices; int *Vertice; } Grafo; I want to access the attributes…
-
1
votes1
answer146
viewsStruct pointer cast doubt
I can’t understand the meaning of this cast: the function will execute and returns a type type_t, which is a typedef for void*. Then is made a cast for header_t*, which is a struct, but I can’t…
-
1
votes0
answers47
viewsHow to use dialogs in GTK+
I’ve been looking on the internet how to use dialogs in GTK+, and I ended up finding a handful of articles in English and none in Portuguese. Reading the articles in English, since I have an…
-
1
votes2
answers922
viewsError executing file. exe generated by Code::Blocks
In the folder bin/debug from Code::Blocks project, it warns this error. how to fix it? I downloaded the DLL and sent pro system32, but the error persists.…
-
1
votes2
answers279
viewsError including library using Linux
I’m just trying to compile examples from the book and I get fatal error: No such file or directory trying to include conio. h, io. h and even curses. h. I read in the Soen and it was suggested just…
-
1
votes1
answer4344
viewsEquation of 1° degree in C
How can I implement a algorithm calculating an equation of 1° grade in C? I know that a first-degree equation to be solved must follow three steps: 1°: Group the numbers on one side of the = all…
-
1
votes2
answers414
viewsBack to top in C
I created a calculator in C, with menu and everything, with the switch case when choosing a function from +, -, *, /, etc. You enter two values and they are executed according to the function. How…
-
1
votes1
answer375
viewsbitWrite function code for use with PIC microcontroller
I am therefore an Arduino code for the PIC pro compiler Mikroc. I arrived at a part that contains the following: byte data[3]; // pulse the clock pin 24 times to read the data for (byte j = 3; j--;)…