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
votes0
answers76
viewsSeg fault em free(char **)
I’m developing a shell for my OS discipline. It was going well until some strange mistakes appeared! I can’t give free(args) for I receive seg fault, if I don’t give this free when running multiple…
casked 8 years, 7 months ago thomaz andrade 93 -
0
votes1
answer32
viewsList printing problem because of repeated values
How can I not repeat a value on this list? Every time I do something, I can’t print. #include<stdio.h> #include<stdlib.h> #include<iostream> using namespace std; typedef struct…
-
0
votes0
answers114
viewsRead TXT with Extended Ascii
I made the code below to read a TXT file that contains extended char from ascii table. int main(void){ printf("%c %c %c %c %c %c %c %c %c \n",205,187,186,187,200,201,205,188); FILE…
-
0
votes1
answer57
viewsCan someone help me with the Pointers in function, in this code?
Guys, after implementing the function deleting my code no longer works, could someone help me? without deleting function is working, what is wrong with it? //biblioteca #include<stdlib.h>…
-
0
votes4
answers2799
viewsString reading with two or more names
How do I read a string with a compound name for example: "Vitor Martins"? I’m doing this program that stores a student’s name and note but it gives a bug when you type two names.…
-
0
votes1
answer401
viewsSeparate array and save to strings for later use
I have a bond for* what account of 1 to 8 and keeps in a array calling for str, but I would like that when the variable str to reach 8 is stored the value of str[i] in the array str_line[b];…
-
0
votes1
answer247
viewsError in conversion from infix to posixed notation
When inserting (3+7) the result of the operation is 37+ and when placing only 3+7 without the relatives of the segmentation error and when I place (3+7)-(2+7) of the error also and I am not finding…
casked 8 years, 6 months ago Matheus Francisco 650 -
0
votes0
answers123
viewsHow to receive an indeterminate number of variables in a C function?
I’m studying lists in c, and I have a function to remove element, Lista* retira(Lista* l, int v), how do I get an indeterminate number of variavas v to remove? similar to varagars in java.…
-
0
votes2
answers90
viewsC - Openssl (d2i_RSA_PUBKEY, d2i_RSAPrivateKey and d2i_RSAPublicKey)
I created a private RSA key via the following command: openssl genrsa -out keypair.pem 2048 I need these keys to be stored in DER format (PKCS#1). Thus, I converted this private key, which is in PEM…
-
0
votes1
answer945
viewsHow do you assign data to a struct by reading from a CSV file?
I’m having difficulty assigning read values of a file in csv format to a struct, my file has the following structure: 1;República Checa;156.9 2;Irlanda;131.1 3;Alemanha;115.8 4;Austrália;109.9…
-
0
votes1
answer35
viewsParameters in the Signals Handler
I have a doubt and even after searching I could not solve. Let’s say I have the following signal handler: struct sigaction conf_signal; conf_signal.sa_flags = 0;…
casked 8 years, 6 months ago Lucas Schneider 430 -
0
votes0
answers44
viewsProgram to print Windows paths
Good, I have a program to print Windows paths like "C:..". I have created the following code: Lista_Viagens cria_lista_viagens(void){ Lista_Viagens aux; aux = (Lista_Viagens) malloc(sizeof…
casked 8 years, 11 months ago Diogo Martins 9 -
0
votes1
answer936
viewsDynamic allocation with struct
/* [Error] expected primary-expression before'*' token [Error] 'dia' was not declared in this scope [Error] 'mes' was not declared in this scope [Error] 'ano' was not declared in this scope */ This…
-
0
votes1
answer7041
viewsFunction that counts number of vector elements
I tried to use this function to count the number of vector elements, but it doesn’t work. int tamanho(int *p) { return sizeof(p) / sizeof(int*); } I wanted to stop by for: i< tamanho(vetor). It…
-
0
votes2
answers86
viewsProblem with dynamic allocation of bidimencional matrices in C
I need to make a product of matrices in which the user must enter the dimensions and terms of the matrices, but the program simply stops working. Follows the code: #include<stdio.h>…
-
0
votes2
answers105
viewsParameters, functions in C
I am a beginner in programming and I have a lot of doubt about the functions and the parameters. Follow a code example: #include math.h int main(int argc, char *argv[]) // Dúvida nessa linha {…
-
0
votes1
answer321
viewsHow to create an array of roulette colors?
#include <stdio.h> int main (void) { char cor[35]; // declarar vetor para receber nome das cores int numeros[35] = {0}; // declarar vetor para receber o numero respectivo das cores int i = 0;…
-
0
votes2
answers2623
viewsSquare Root in C
Follows the code: #include <stdio.h> #include <math.h> int main() { double distancia; double x1, y1, x2, y2; scanf("%lf %lf ", &x1, &y1); scanf("%lf %lf ", &x2, &y2);…
-
0
votes1
answer380
viewsrequest for Member 'attributeOuDecisao' in Something not a Structure or Union
Tree initialization error, the problem with the category variables and atributoOuDecisao. typedef struct node { int categoria; int atributoOuDecisao; struct node *prox; struct node *lista; } No; No…
-
0
votes2
answers54285
viewsAnalyze whether the number is even or odd, and which of the numbers is higher
setlocale(LC_ALL,"Portuguese"); int num1,num2; printf("\nInforme os números: "); scanf ("%i""%i",&num1,&num2); if (num1 % 2 == 0){ printf ("\nO número %i é par e",num1); }else { printf("\nO…
-
0
votes1
answer1856
viewsCount rows and null columns of a matrix
Guys, help me on the following question: Write a complete program in C language that declares a square matrix of size 5x5. Then your program must fill this matrix randomly with 0s and 1s (the matrix…
-
0
votes1
answer312
viewsString help
Make a program that finds the set of 5 consecutive digits in the sequence of only numeric characters that generates the largest product, print that set of 5 digits and the result of your product.…
-
0
votes1
answer244
viewsCounting Numbers using Array in C
How to count integers using a C array in this model: Input > two strings with "integers" ex: 8 15 Output > A string with range numbers, inclusive: ex: 8 9 10 11 12 13 14 15. Probably a basic…
-
0
votes0
answers178
viewsIndex of Vector in C
I have this function which is called through a menu of options: char cad_cliente()//cadastro de clientes { char resp;//variavel de resposta se cpf invalido system("cls");//limpa tela for(int c = 0;…
-
0
votes1
answer49
viewsInteger Overflow with PID in C
Hello. I’m trying to implement a C (for 3DS) program that manages processes and finishes them until I can generate an Integer Overflow in the PID to be 0, but I don’t know exactly how to do it. What…
casked 8 years, 5 months ago Luiz Fernando Elesbão 11 -
0
votes2
answers189
viewsHow to calculate the distance in fewer lines?
I have this exercise on C to calculate the distance between two points using structs, but he repeats the point code a lot, to x and y, how to do it in fewer lines or use array? #include…
-
0
votes3
answers208
viewsRepetition of elements
I’m having difficulty generating as output the amount of elements repeated in the vector. Follow the code: #include <stdio.h> #include<stdlib.h> int main() { int N, i, temp, repetidos =…
-
0
votes1
answer463
viewsread from binary file to linked list c
Good people, I’m having a problem reading information from a binary file to enter it in memory on a linked list. PERGUNTAS val; lista_perguntas * aux = original->next; lista_perguntas * base =…
-
0
votes1
answer147
viewsHow to divide 2 numbers represented by a circular list into C?
Hi, I’m writing algorithms for large numbers. I implemented the operations of sum, division and subtraction but for divide I have no idea just an algorithm to use with binary base. It is not an…
casked 8 years, 10 months ago Ale Chaito 25 -
0
votes1
answer490
viewsIs giving error in the matrix using the while loop
How do I make the matrix be rotated with the while loop? My teacher wants the matrix to be displayed with the while loop I only know how to do with the for loop. Follow example with errors of how I…
-
0
votes1
answer80
viewsThe function writes to the file in txt. I need to sum but the vector is as char
My teacher passed this code that writes to the txt file. Inserts random number. After executing this code he wants me to sum the values written in txt, but they were written in a char vector and for…
-
0
votes1
answer158
viewsCreate a c file on linux
I have a college job, which I am asked to implement a "C" program that produces files containing random integer numbers of the type long int, where the random numbers must be between 0 and RAND_MAX.…
-
0
votes1
answer89
viewsInvalid argument in mmap
I want to write to the "server.log" file and when I compile the code, the result is "Invalid argument" in the "mmap" function". void MMP(){ char* addr; int fd; struct stat sb; fd =…
-
0
votes0
answers983
viewsProgram C queue and stack
I created a program in C, to remove (or copy) the values of a queue, using the output rules of a stack and add them into a new structure. But it’s not working the way I’d like it to. You are adding…
-
0
votes1
answer172
viewsWhen to use a scripting language?
When to use a language of script and what is the ideal setting for its use? I’ve been reading about languages script and I thought about the possibility of using them in my C/C++ project for a game…
-
0
votes1
answer73
viewsDoubt about arrays and pointer
#include <stdio.h> #include <locale.h> int main () { setlocale (LC_ALL,"Portuguese"); // Formatação. int notas1[50],notas2[50],notas3[50],soma[50]; // Declaração. for (int i = 1; i <…
casked 8 years, 10 months ago user48471 -
0
votes1
answer56
viewsUse vector on functions outside main
I learned to use functions a few days ago and now I wanted to use an array on them. My teacher taught, but my code just doesn’t work. One of the numbers ends up being repeated.Follow the code:…
casked 8 years, 10 months ago Megawarboy 1 -
0
votes1
answer540
viewsProgram to calculate media
#include <stdio.h> #include <stdlib.h> int main() { int sum = 0; int times = 0; int number; int average; while ( number != 9999 ){ printf( " Type the number and i will make the average,…
-
0
votes1
answer268
viewsProblem with scanf in %d receiving a keyboard letter
I’m having a problem, I’m reading a int %d for scanf, but if the user type a letter the program enters loop. void chama_menu_switch(Fila **f, int n){ char confi; int i,y,x,a,z; double r; a = 0; int…
-
0
votes1
answer438
views -
0
votes1
answer3626
viewsInvert stack values
I’m trying to reverse the order of the stack elements using the loop while, but I’m not getting it. pilha* inverte(pilha **p) { pilha *outra = cria(); //aloca e seta a qnt com 0 while(vazia(&p))…
-
0
votes1
answer630
viewsVector sorting of character vectors with qsort <stdlib. h>
The following program is not ordering the chars vector correctly, but I don’t know why. Maybe it’s my auxiliary function "cmpstr" that isn’t returning the right value in some cases, or my qsort…
-
0
votes2
answers71
viewsMatrix in dynamic allocation with execution failure
Hello! The following code compiled, but shows error in execution: #include <stdlib.h> #include <stdio.h> #include <conio.h> typedef struct { char *nome; int valor; int peso; }…
-
0
votes0
answers66
viewsProcedures nested in C being ignored by the previous procedure
I’m having a problem in the last procedure of the following code, where the procedure receive Tring to make the comparison with another registered is being ignored and jumping straight to receive.…
casked 8 years, 10 months ago Vinícius Valentim 29 -
0
votes1
answer111
viewsError when debugging program: "No Symbol table Loaded"
When debugging the program the following error message appears: Debugger name and version: GNU gdb (GDB) 7.10.1 Starting the debuggee failed: No Symbol table Loaded. Use the "file" command. Debugger…
-
0
votes1
answer128
viewsCreate Project from DLL
I’m trying to work with XFS, but in the documentation asks to create a DLL for each service, but the dll’s do not come in the api, they must be built, only in the installation of the environment…
-
0
votes1
answer90
viewsSpace spent by variables
Hello I would like to know how I do to calculate the space spent by each code variables, functions. Example I have a code to order a list double chained by Selectsort, but I want to calculate the…
casked 8 years, 10 months ago Matheus Francisco 650 -
0
votes1
answer224
viewsError Segmentation fault (core dumped) in read and break string code
I need to read each line of an input file, break it into tokens and save each token in a position of a struct. I am able to do this partially, but at a certain point in the file, Segmentation fault…
-
0
votes1
answer343
viewsUndefined error Reference to `print`
Guys I’m making a code here and it’s giving 2 errors that are: error: ld returned 1 exit status undefined reference to `print` I checked the code and found no error, which could be? #include…
casked 8 years, 9 months ago Gabriel Ribeiro 163 -
0
votes1
answer63
viewsDoes anyone know why there’s a glitch in this program?
void ordenar(struct piloto *vetor,int contador_pilotos) { int z,i,x,j; for(x=contador_pilotos-1;x<=1;x--) { for(i=0;i>x;i++) { …