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
-
2
votes2
answers292
viewsHow to reuse a pthreads?
I’m using pthread.h and using the following functions: // // Cria A thread // thread_argsPP[contthreadsPP] = contthreadsPP; pthread_create(&threadsPP[contthreadsPP], NULL, ReceivePinPad, (void…
-
2
votes1
answer192
viewsProblem with Dynamic Allocation - Segmentation Failure
I defined two structures to represent a straight line. I need to open a file that contains the values of a line by line, put the values in a chained list. This I was able to do.…
-
2
votes3
answers1174
viewsConversion of variables type int to char*. C++
I have the following method that takes two int variables as parameter and I need to concatenate these two values into a char variable*, only for this to be possible it is necessary that these two…
-
2
votes1
answer107
viewsHow to customize the size of a window?
How I can customize the size of a window I made using Win32? My Code: #include <windows.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){…
-
2
votes2
answers886
viewspointer casting
Guys , I can’t understand why casting between pointers has some impact on the code or just to make the code readable as for example this line of a function: void* getPhysicalAddress (pdirectory*…
-
2
votes1
answer316
viewsQuicksort with last element as pivot
The following code should receive a sequence of characters separated by space and sort them: #include <stdio.h> #include <stdlib.h> int particiona(int *vector,int inicio,int fim){ int…
-
2
votes4
answers4551
viewsRecursive multiplication in C
I’m learning recursion in C, and I was able to do some programming using recursion. However, I am getting to make a simple program that the user sending two numbers, for example: 6x2, I multiply…
-
2
votes1
answer4641
viewsHigher value of a vector, with recursion
I’m studying recursion and vectors, but I can’t understand how this method works, which returns the highest value using recursion. int maximoR (int n, int v[]) { int x; if (n == 1) x = v[0]; else {…
-
2
votes0
answers261
viewsHow to exchange the UUID of a partition via C code?
I am making a program in C, and through Linux, I have been able to "get" UUID easily, with the command blkid. This program needs to know if the disk on which it was installed is still the same and…
-
2
votes1
answer199
viewsWrong return of ping command
Taking into account that the ${parameters} is an array that can contain valid IP addresses or not, I wrote the following code: for ((i=0; i<$#; i++)); do eval "arg=\${$i}" ping ${parameters[i]}…
-
2
votes2
answers2146
viewsIs it possible to connect a C-based application to a database?
We usually use files to save data using language C (at least). It is possible to connect a relational database to any application made in C? If yes, do you need a library for this and how is this…
-
2
votes1
answer310
viewsIs there a way to call a C function in C#?
Let’s say I have a library with a C function, which was compiled using gcc, there is how to call this function in C#, if yes what would be the performance of it compared to the same function created…
-
2
votes1
answer3201
viewsHow do I know the address of each vector position in C?
I’m having trouble knowing the vector address and address of each vector position. #include <stdio.h> int main(){ int vec[]={52,13,12,14}; printf("Endereço de vetor %d",&vec);…
-
2
votes2
answers2311
viewsHow do I create a C Makefile
I’m having problems running Makefile. main: ex09.o funcao1.o gcc -c ex09.o funcao1.o -o main ex09.o: ex09.c gcc -c ex09.c funcao1.o: funcao1.c funcao1.h gcc -c funcao1.c clean: rm *.o One of Linker…
-
2
votes3
answers1650
viewsHow to highlight text (change color) in ANSI C
Good evening to you... I’m wondering how to use the textcolor function in c but I couldn’t find it in the conio library... does anyone know where this function is located or if I have to create it…
casked 8 years, 1 month ago Gabriel Ribeiro 163 -
2
votes1
answer2608
viewsSort stack items A and B on stack C
I am learning how to manipulate stacks in the Data Structure discipline, but having difficulties in implementing functions such as sorting and reeling is presenting errors in the scope of the if…
casked 8 years, 6 months ago Jordana Lopes 21 -
2
votes2
answers9106
viewsRemove array element in C
I have the following struct. struct cadastro{ int codigo; char nome[200]; char cpf[11]; char rg[10]; char tel[12]; char end[100]; }cadastro;//struct do tipo cadastro. and the corresponding vector…
-
2
votes0
answers498
viewsARDUINO Writing data to SD card over Shield ethernet
Good night I am wanting to make the Arduino uno record data on an SD card I do not have the module for SD card for Arduino However I have the module ethernet Shield, which has an input for SD card…
-
2
votes3
answers582
viewsHow to dynamically increase struct size?
How to increase the size of struct when the current size is reached? #define TAM_MAX 50; typedef struct{ char nome[TAM_NOME]; /* nao pode ser vazio*/ char sobrenome[TAM_SOBRENOME]; char…
-
2
votes1
answer109
viewsLibrary similar to Boost and STL in C
Is there a library similar to Boost and STL C++ with data structures, etc., in C?
-
2
votes2
answers1180
viewsDrawing of numbers with exception
How do I draw lots n of numbers in C language where I can exclude the possibility of drawing a certain number from my range given a certain condition? Exemplifying in code: #include <stdio.h>…
-
2
votes1
answer995
viewsToo Many Arguments to Function 'address* finds()'
I am trying to compile this code in Devc++ but keeps giving this error [Error] Too Many Arguments to Function 'address* finds()' #include <stdio.h> #include <stdlib.h> #include…
-
2
votes2
answers698
viewsFactorial with recursion
I have to make a program that calculates the factorial of a number using recursiveness within the main. #include<stdio.h> #include<stdlib.h> #include<conio.h> int main (int argc,…
-
2
votes1
answer193
viewsProblem with dynamic allocation
I need to make a code where the user fills in an array as many times as he wants, but the code stops running. If I register only 3 values, like (1) (2) (3) it works normally, but in some moments…
-
2
votes1
answer234
viewsPrint all results of a vector with a given value
I am starting the studies in C. I have a question of how to go through a vector looking for a value and print showing with printf all values found. The program I’m doing:…
-
2
votes1
answer234
viewsIntegrate C and C++
Good morning, everyone. I have a main program in C, and I just want to call a function that is in another C++ file and get the return of this function. How do I do that? I researched and saw that…
-
2
votes1
answer631
viewsList of structs
I would like to know the advantage of using a list in this way. typedef struct Pessoas { char nome[20]; int idade; struct Pessoas *prox; }pessoas; typedef struct Funcionario { pessoas *pessoa;…
-
2
votes1
answer88
viewsHow to decide the type of a function?
In many C written codes on which I see on the internet I only see type functions void and int Is it possible to declare functions of other types? For example struct and float. I did a simple test…
-
2
votes3
answers6084
viewsRecursive palindromus C
My functions are not working properly, always the program tells me that it is not palindromic, for any situation. Follow the code: #include<stdio.h> #include<string.h> int inverte (char…
-
2
votes1
answer188
viewsnome.exe has stopped working. I can’t fix this
My C code gives a crash displaying following po error: filename.exe has stopped working I don’t know how to fix it. Follow the code I’ve already made: #include <stdio.h> #include…
-
2
votes1
answer46
views"SIGSEGV" error when receiving a large data packet
Hello, I am facing a "SIGSEGV" error when receiving a large data packet with the recv function of the library using C language on a Posix - UNIX system, if any soul can help me a thank you. buffer:…
-
2
votes2
answers131
viewsWhat is the limit of multidimensional vectors?
I’m doing a test and it gives me an error when I try to create a vector[1000][1000]. There are limits to vectors? The error code (application ceases to respond) is the following: int main (){ int…
-
2
votes1
answer350
viewsProblem in C language, issue with prime numbers
I am solving exercises, in C language, on vectors. The exercise is as follows: Make an algorithm that uses a menu with the following options: sort an ascending 5-position vector, sort a descending…
-
2
votes1
answer90
viewsWhat’s wrong with my show?
I am trying to better understand the functioning of pointers in C and C++ and for this I am trying to make this small program of chained lists (I took the example of the book "Data Structures" of…
-
2
votes1
answer1505
viewsHow do I get this list double-chained and circulated?
#include <stdio.h> #include <stdlib.h> #include <string.h> struct Tipo_Lista{ char cod[50] ; struct Tipo_Lista *Prox; struct Tipo_Lista *Ant; }; struct Tipo_Lista *Primeiro; struct…
-
2
votes1
answer776
viewsHow can I clean the buffer?
I am working with file. I have difficulties cleaning the buffer already used the fflush(stdin) after reading but it doesn’t work. void EscreverFicheiro(FILE * ptr,LISTA dados){ ptr =…
-
2
votes1
answer419
viewsImplementation of ANSI C queue
I have a code (end of question) that allows manipulation of a queue in ANSI C, my question is as follows: The code declares a data type of its own to store the data of the queue and has a function…
-
2
votes1
answer80
viewsHow do I warn the compiler that this is an IEEE 754?
i need help. I have, for example, a hexadecimal number 0x41140000 which is 9.25 by the IEEE 754 standard, but how to read this value (contained in an integer variable) by casting a float and picking…
casked 7 years, 8 months ago Murilo Formiga 163 -
2
votes1
answer874
viewsHow to store letters in a variable and display them all at the end by forming a phrase/word
I’m holding up programming and I’m making a code where I’m supposed to turn a binary code into a phrase. I’m turning the binary value into decimal, and taking the decimal value and comparing the…
-
2
votes0
answers63
viewsReading a special character like char using locale does not work. How to fix it?
I’ll give a very simple example to explain my doubt: #include <stdio.h> #include <conio.h> #include <locale.h> main(){ setlocale(LC_ALL,"Portuguese"); char a; printf("Insira um…
-
2
votes1
answer73
viewsProblem in C code running a function
Hello, I have a problem with this code. I am implementing the function of Bubble Sort. But something curious happens when running this code. The variable n that indicates the amount of vector spaces…
casked 8 years, 3 months ago Gabriel Morikawa 41 -
2
votes1
answer1133
viewsReference struct inside another in C
I need there to be a reference to struct inside the other. But in the example below as the struct TAnimal does not yet exist, her reference in struct error player. How to get around this situation?…
-
2
votes1
answer241
viewsHow to increment an Enum in C?
Objectively as I do to increment ++ or += 1 one of the variables of enum (the increment will be in a loop / switch): enum {um = 0, dois = 0 ... seis = 0}; I read that one question and I didn’t get…
-
2
votes3
answers6535
viewsSequence reading of space-separated numbers
It is necessary to read only a line with a space-separated set of integers, each space-separated item will be inserted in a linked list: 1 41 2 15 6 7 87 4 2 1 9 0 List would be something like = [1,…
casked 8 years, 2 months ago Daniela Morais 4,687 -
2
votes1
answer3401
viewsConvert hexadecimal string to C-readable output
I would like to save a text in hexadecimal, and calling a function, the hexadecimal string is converted to a readable char string, i.e., decoding the hexadecimal, for example 0x6f0x69 for oi. I…
-
2
votes2
answers1192
viewsMaximum value for srand((unsigned)time(NULL);
I was reading about the random numbers not being so random and I saw that one way out was to feed a seed with the srand((unsigned)time(NULL) ); To make tests I generated a vector of 100,000…
-
2
votes0
answers45
viewsHow to define a listStore to render a progress bar in gtk2?
I am looking for an example to create a listStore (to use in a treeview) that may contain a progress bar type field. I am writing in C (not in c++) and using gtk2 in my code:…
-
2
votes1
answer776
viewsTotal number of elements in a stack
I want to know how to return on the screen the total number of elements in a stack. For example: I have an array stack of size 10 and stacked 6 elements in it, will have to return me the total of 6…
-
2
votes1
answer118
viewsHow to make a C routine run and do not stop until I execute a command?
Good evening, I’d like to do a C routine like this: Let’s say I have a loop that keeps printing the letter 'a' and while I don’t type anything it keeps printing, but the moment I press 'c' for…
casked 7 years, 8 months ago Philipe Matheus 21 -
2
votes1
answer532
viewsWhat is Ansi Escape Code?
For handling of the linux terminal (other OS console also), is using a string started with a hexadecimal value 0x1B known as ANSI Escape Code. For example printf("\x1B[32mMy Text\n"). How does the…