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
votes1
answer111
viewsChained list - Multiple error defenition of main
Good evening, would you be kind enough to help me with my project? I’m trying to create a chained list, but when I try to compile an error appears as the image below: I do not know what is occurring…
-
0
votes2
answers596
viewsChained list - Error inserting element - [Warning] Passing argument 1 of 'strncpy' makes Pointer from integer without a cast
Good afternoon, would you be kind enough to help me with my project? I have to create a chained list that records bus schedule data, but when I try to execute, soon after entering the time data…
-
0
votes1
answer177
viewsI learned to pass a vector as parameter, I would like to change and return the vector (vector_y1) to main, is there any way to do it without allocating? Please
#include <stdio.h> #include <stdlib.h> #include <locale.h> int vetor_y1(); int main(){ setlocale(LC_ALL, "Portuguese"); int i,j; printf("Inf. o…
casked 7 years, 6 months ago Braian Freitas 159 -
0
votes2
answers767
viewsHelp with code implementation and functions
Dear friends I really need a help, follow the details: Vehicles may enter or leave the ring road only if they are in the outer lane of the ring road (lane 1). Vehicles can only develop high speed…
-
0
votes1
answer156
viewsI have a problem trying to use an increment in the printf - C function
Can anyone help me understand why the output of this code is: 24 23 and not 23 23 ??? int a =23; printf("%d %d",a, a++); }…
-
0
votes2
answers62
viewsVector Help in Programming Logic
The idea is to print according to the condition, only that I am lost in logic, because there is no position of the vector to receive the two values. #include <stdio.h> int main (){ int…
casked 5 years, 11 months ago Bruno Gomes 19 -
0
votes1
answer80
viewsExercise Vectors, I’m stranded
It is intended to elaborate a program that asks the user for integer numbers and stores them in an array, this procedure is repeated until the user type the value zero. At the end the program should…
-
0
votes2
answers148
viewsfunction using char and vector in c
Good evening, I’m facing a problem. I’m trying to fill a vector in C that way. int a[5]; void lerValor(char grupo, int posicao, int valor) { grupo[posicao] = valor; printf("%i", grupo[posicao]); }…
-
0
votes1
answer627
viewsList simply chained and unordered
When running the code below, we have the following problem, when calling the function imprime_lista, when an element has already been allocated in the list, it is giving segmentation fault. How to…
casked 7 years, 5 months ago Lucas Katayama 101 -
0
votes1
answer29
viewsWhy can’t I create an IPC key with the ~/. bashrc file?
I was working out some school exercises and in the statement there was a question: One can generate an IPC key with the file . bashrc? I not knowing the answer to the question, I created a C program…
-
0
votes1
answer506
viewsC string array
I know that to define a word (string) in C, it is necessary to use a vector of characters, with a defined number of characters that will be used. However, how can I use a multi-word vector, that is,…
-
0
votes1
answer92
viewsAccessing a function variable
In C, I can use a variable outside the scope where it was declared? I know that the best thing to do is to declare her out of any role, because then she will become global. But I want to know how to…
-
0
votes1
answer59
viewsLibrary #include <Hsffi. h>
Hello, I am integrating a system based on C with Haskell, but I need the library #include , the content I found on the internet has not helped me in almost anything, if anyone knows something…
-
0
votes2
answers125
viewsRun time exceeded in c
I’m doing a program that adds the amount of prime numbers from 1 to 2000,000. When trying to compile, it returns that there was exceeded runtime. I would like to know ways to optimize the time of my…
casked 5 years, 10 months ago user148289 -
0
votes1
answer107
viewsRead multiple scanf numbers separated by space and place in a vector in C
I need to make a program that receives a lot of elements and put a vector, but I want to put the elements in the scanf separated by space and then pass in the vector. Only I don’t know how to do…
casked 5 years, 9 months ago Edson Modello 1 -
0
votes2
answers42
viewsHow to place multiple ordered outputs in a table
I need help to improve visualization, can anyone help me ? I’m using C #include <stdio.h> int main() { int tab, mult, result; printf("Tabuada de 1 a 9.\n"); tab = 1; for (tab = 1; tab <= 9;…
-
0
votes1
answer3094
views"Warning comparison between Pointer and integer" - what is it?
during the compilation of the code in C language I appeared this error: [Warning] comparison between Pointer and integer for this step of the code: if(livro > TAM) { printf("------- Você já…
-
0
votes2
answers87
viewsString scanf() time problem
I wanted a help in solving the problem of a string, because when you read the program automatically from as invalid option any option, so you do not use the option I chose. No if I’ve tried with…
-
0
votes0
answers56
viewsWhat is the application of the concept of pointers for functions?
I would like a practical example for the use of pointer to function as well as a function having as one of the parameters a pointer pointing to a function; it is not necessary to show some code, I…
-
0
votes1
answer84
viewsDoubt about processes in language c
I would like to know of some library in c, that can serve me to create a program that sees the running processes... system("ps"), I would like to see if a program is running and if it is not, then…
-
0
votes1
answer176
viewsFunction to invert strings in C
Inserts the orig string at the beginning of the dest string, returning dest. char *strins(char *dest, char *orig) My code is as follows:: char *strins(char *dest, char *orig) { return…
-
0
votes1
answer512
viewsSorting by name and number plate
I have this List simply chained and n know how to order it. I need to sort by name and number. #include <stdio.h> #include <stdlib.h> void BuscarMatricula(); void Inserir(); void…
-
0
votes1
answer53
viewsVisual Studio 2019 vector error
Good evening, someone can tell me why this message appears in the program in c language, and if it has how to solve? Run-Time Check Failure #2 - Stack Around the variable 'note' was corrupted. Float…
casked 5 years, 9 months ago Bruno Ritter 13 -
0
votes1
answer56
viewsError in storing names in.txt file
#include <stdio.h> //inicio do programa main() { //cria estruturas typedef struct { char nome[10]; } movimentacoes; //cria as variavéis FILE *arq; movimentacoes nome; //recebe o nome da conta…
casked 5 years, 9 months ago Daniel Soares 73 -
0
votes0
answers298
viewsUnderstanding the Quick Sort algorithm graphically
I have this code below working correctly. #include <stdio.h> #include <stdlib.h> #include <string.h> void quicksort (int *vetor, int inicio, int fim) { int i, j, meio, aux; i =…
-
0
votes1
answer101
viewsBizarre error with dynamic allocation
I wrote this simple program: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char *nome; nome = (char *)malloc(10 * sizeof(char)); if(nome == NULL) {…
-
0
votes0
answers38
viewsWhy do I get "Segmentation Fault", but if I remove * in the printf call it doesn’t happen?
int alloc(int * pointer, int num){ scanf("%d", &num); pointer = (int *) malloc(num*sizeof(int)); return(*pointer); } int main(){ int *pointer; int num; …
-
0
votes1
answer349
viewsWhat is & no printf in C for?
Oops, I wonder how the & (and commercial) works, in the case of the printf, in the scanf I know, that it takes the variable to a memory address, but in the case of the printf? I have this…
casked 5 years, 8 months ago Brenno Carvalho 51 -
0
votes2
answers190
viewsHow can I print a string instead of char?
In the following code I have a char with 2 characters, H (Heads) and T (Tails), at the time of printing will clearly be printed one of these 2 letters, but I wanted to make a change and print…
-
0
votes1
answer24
viewsReceive a user’s data and show that data at the end
I want to receive the input of a user and at the end I run the program I want to show them, but I think the variable address is not like that, because the program jumps from name to age directly,…
-
0
votes1
answer43
viewsLoop is not being completed
I’m a beginner in programming and I’m still making several mistakes, you could help me find out why the loop is not completing the loop? #include <stdio.h> int main(){ int N, X[N], controle =…
-
0
votes1
answer952
viewsValidate user typed only number - C
I have a string declared as follows: char cpf[12]; I want to validate that the user typed only numbers when he typed ENTER. I captured the value typed by the user like this: gets(cpf); Soon after, I…
-
0
votes1
answer569
viewsExample of Callbacks in c
I would like an example of using callback in c that allows logging callbacks to be called when an event occurs.
-
0
votes2
answers49
viewsDoubt loop FOR in C
the code’s working as I need it, my doubt is why For didn’t go wrong? For example, if the exponent is 3, it will no longer be greater than 1 and then it would already stop the loop? I was trying to…
-
0
votes0
answers22
viewsError in Sum of conditional fractions
I can’t do this exercise by using it, you could help me. I can not find where I am missing, I put two && no for to carry out the two operations but it is not compiling, thanks. Make a…
-
0
votes1
answer56
viewsWork in C "Bank" giving error
Hello I am doing a work in c and is giving the following error: after I make the Deposit/ Withdrawal instead of going back to menu the program asks to type again. main(){ int matriz[5][2],i,…
-
0
votes1
answer105
viewsJoining of vectors in C
I have a doubt in this code because the function should print {1,2,3} but I printed {1,2,3,4,10,24,73} void uniao(int A[], int B[], int C[]){ int i; for(i = 0; i < TAMANHO ; i++){ if (A[i] == 1){…
-
0
votes2
answers78
viewsWhy does the program work despite the invasion of memory in the vector?
#include <stdio.h> #include <stdlib.h> int main() { char s[2]; int i; printf("Entre com os caracteres\n"); for(i=0;i<4;i++) …
-
0
votes2
answers47
viewsStruct array accepting more than defined, what’s wrong?
In the code I created a array of the kind Pessoa containing only 2, but when it starts to iterate on the for loop and accesses index 2 and 3 the condigo continues without generating error at compile…
-
0
votes2
answers80
viewsProblem with neighboring positions in C++ arrays
#include <iostream> using namespace std; int main(){ int myVector[] = {2,6,4,1,9,5,7,3,8,0}; int tamanhoVetor = sizeof(myVector)/sizeof(myVector[0]); //Imprime for (int i=0;…
-
0
votes0
answers17
viewsStruct error reading second name
Good afternoon, I’m doing a struct that stores name and age,the first step of the loop,but when it goes to read the second name it jumps,. #include <stdio.h> #include <stdlib.h>…
-
0
votes1
answer30
viewsRevert a standard input line in C
I am trying to get the following output if the imput be: hi mom the output sera: eam io the code I made, trying to train recursion was: #include <stdio.h> void reverse(char *arr) { if (*arr !=…
-
0
votes0
answers109
viewsHow do the functions malloc( ) and calloc( ) work in C?
I know that both functions allocate a memory space in bytes and returns the address of that memory, where calloc frees this space while in malloc the release must be made by the function free. But…
-
0
votes1
answer2942
viewsProblems with GCC on Windows 10
I am facing problems when changing IDE, I was told that DEVC++ contains a lot of bugs and by option I was already in the mood to try other IDE’s, so I decided to test Code::Blocks and Visual Studio…
-
0
votes1
answer78
viewsHow to pass a matrix that has been allocated to a function in C?
Good evening, I have a question, which is the following. -Write a program that dynamically allocates an array (of integers) of dimensions defined by user. Then fill in the matrix positions and print…
casked 7 years, 5 months ago Nilzon Martins 189 -
0
votes1
answer65
viewsQuestions about storing values in a variable
I’m having trouble understanding this particular while loop: #include <stdio.h> main() { int c; c = getchar(); while (c != EOF) { putchar(c); c = getchar(); } } The result of an execution is…
-
0
votes0
answers176
viewsI am using the Opengl lib, but in the compilation gcc is returned indefinite reference, could anyone help?
#include <GL/gl.h> #include <GL/glut.h> void reshape(int w, int h) { glViewport(0, 0, w, h); /* Establish viewing area to cover entire window.…
-
0
votes1
answer219
viewsLogic error with MOD (%)
Good evening guys, I’m with a code that shows me wrong values, in my view, my logic is correct but when I request result what is shown has nothing to do with the final objective of the code. I have…
-
0
votes1
answer41
viewsProblem to enter Switch
Good afternoon, when running the program below, after typing the third note, the program ends without typing the letter needed to enter the switch. I tested with "i" getting whole number and the…
-
0
votes1
answer106
viewsDo you have a way to Implement a C Executable for Mobile?
Come on; I managed to develop a very banac executable in C that writes in File so that I store some data. But, I wanted this executable that is already running on the Desktop also run on Mobiles,…