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
answer319
viewsStore stack in txt file
I am starting in C and I have the following problem. I need to save strings in a txt file sorted in stack, so far so good, but I need that when I open the program again, it keeps stacking always at…
-
0
votes1
answer358
viewsprintf %s integer in C
I’m trying to make appear on the screen all characters of the string typePersonagem[0], but only the last letter of the string is coming out, someone helps me in what I’m missing? #include…
-
0
votes1
answer233
viewsCompress array with equal values C
The problem is the following: Make an algorithm that reads an array A[10]. Then remove the duplicate elements by compressing vector A. Finally insert the value zero in the last elements. Show the…
-
0
votes1
answer1139
viewsPrinting of predefined phrases at random in C
Hello, I’m a beginner in programming and I’m learning to code in C. I want to do a show that has some sentences already defined. Ex c/ vectors: char vet1[100] = {"Hello World!"}; char vet2[100] =…
-
0
votes1
answer4711
viewsGiving Segmentation Failure error (recorded core image)
Exercise = Perform a procedure that receives, per parameter, 2 vectors of 10 elements integers and that calculates and returns, also by parameter, the intersection vector of the two first. My code:…
casked 7 years, 4 months ago Bruno Esteves 31 -
0
votes2
answers104
viewsHow to pass structure data to a text file?
I have this structure: struct televisao { int id_guit; int precodia; int preco; int estado; char nome[20]; }; I wanted to ask the user to insert data from this structure and store it in a . txt…
-
0
votes1
answer136
viewsHow to pass this parameter to a void function?
Having two roles being the first : void print_bytes (const void * end_byte, int n){ int k; k = end_byte; converte_binario(k); } Already the binary convert is a little big so I’ll explain, basically…
-
0
votes1
answer2314
viewsCreate a recursive function in C that returns the largest and smallest value of a vector
Guys, how can I solve this exercise? 1-on the first line the user has to type the vector size 2- in the second line, the user fills in integers 3- make a recursive function that receives by…
-
0
votes1
answer189
viewsAdministrator of Parking in C
How do I calculate the totals of car parking values as stated below: Do a C program to assist in the administration of a parking lot For this procedure the following has been informed: for each car…
casked 7 years, 4 months ago Fernando Fefu 301 -
0
votes1
answer2487
viewsReading a bitmap image
Hello, I am with a work of the faculty on steganography and one of the requirements is to read an image in the format bitmap (bmp), however, I have already searched a lot in the internet and the…
casked 7 years, 4 months ago Italo Zuckerberg 63 -
0
votes0
answers131
viewsTwo-dimensional Matrix in C
I have a record of products in C. Products can have up to 30 characters (columns), but can be infinite in quantity (rows). In the variable declaration, I used: char products[][30]; but when…
-
0
votes1
answer152
viewsVectors or Matrices in C/C++
follows below a problem can use vectors or matrices, I have a question on how to do item 1 of the menu, if anyone can explain me, I would appreciate it very much :) College X thought about adopting…
-
0
votes2
answers51
viewsHow do I point (with pointer, of course) to a string, so I can then print it?
I’ll give you an example of how I’m doing but it’s wrong and I’d like someone to help me fix that mistake. #include <stdio.h> void main() { char *p; char nome[21], outronome[21]; scanf("%s",…
-
0
votes1
answer71
views -
0
votes1
answer99
viewsHow to make variable receive function argument value?
Next: I have a code for how to create a point structure on an Rxr plan. In this case, I would like to access the "x" value of a point. Follow the codes: File point. h: //Arquivo Ponto.h typedef…
-
0
votes2
answers102
viewsFix error game
I think with this game that when I make a mistake at the beginning of the game it tells me that a letter was wrong, but if you hit a letter and then make a mistake it doesn’t count. Help me. Error:…
-
0
votes1
answer51
viewsNeeding Help in Vector C Exercises
Why aren’t you showing the 15 numbers? And how to include 3 numbers at the beginning of this vector? int main() { int v[30]; int i,x; for(i=0; i < 15; i++) { printf("Digite 15 numeros");…
-
0
votes3
answers69
viewsAdd items to the beginning of a vector without affecting existing values
How to include 3 numbers at the beginning of this vector without affecting the previous numbers? I’m trying to do it this way: int main() { int v[30]; int i,x; for(i=0; i < 15; i++) {…
-
0
votes1
answer51
viewsCompile and Run GUI on Android
I use c4droid to compile C code using gcc, in my studies I want to enter the graphical interface, but as I am without computer I thought to use the android itself. Well, I installed the GNU Root…
-
0
votes1
answer66
viewsHow do I use a "or" no while in C
I’m trying to make a naval battle application with the while stop with 2 conditions, which are the player’s mistakes or hits, where he can miss 5 times and have to hit all points, which in this case…
-
0
votes2
answers199
viewscode implementation
I and a colleague are beginners in programming and we are building a game in which we need to use chained list. He was responsible for creating a game menu using chained list and I for creating the…
-
0
votes1
answer36
viewsVariable returning 0 in file
Hello, I’m learning files I’m having difficulty using fwrite and fread, so the num1 variable is returning me 0 in the repeat structure and I think I did everything right =( #include<stdio.h>…
-
0
votes1
answer52
viewsStruct ! Error on line 47 at the moment it compiles, Follow the program in c
#define MAX 50 struct{ int ra; char nome[MAX]; float prova; }aluno[5]; int main(){ struct aluno; int i; int j; printf("Determine o Nome do…
-
0
votes1
answer235
viewsCode problems from a C priority list
I am creating a priority list in C (topological ordering) using vectors and within these vectors a chained list pointing out who has to come before whom. It’s just that there’s a glitch in the…
-
0
votes1
answer555
viewsError >> TESTE500K.c:(.text+0x8f): Undefined Reference to `INSERT' <<
Guys, I’m trying to create a list but it’s making these mistakes TESTE500K.c:(.text+0x8f): Undefined Reference to `INSERT' TESTE500K.c:(.text+0xa5): Undefined Reference to `IMPRIME' [Error] Ld…
-
0
votes3
answers281
viewsProblem with pointer and recursive function
The code is this : Node * search ( Node ** root, int mats ) { if ( ! ( * root ) ) { return NULL; } else { search ( & ( * root ) -> esq, mats ); if ( ( * root ) -> person.mat == mats ) {…
-
0
votes1
answer1079
viewsCompare integer and pointer
Well, I have a question, I’m trying to copy a line to a file but there’s an error that says I can’t compare an integer to a Pointer, can anyone help me? The error is on the line ch = getc(file1);…
-
0
votes2
answers4985
viewsHow to read string with space in a repeat structure?
I have to make a program to read the name, the author and the price of an n quantity of books (from structures). I made a struct for the books that way : typedef struct{ char nome[100]; char…
-
0
votes1
answer303
viewsTic-tac-toe in C. The program ends before
I am trying to make an old game in C language but in player 1’s first move depending on where to put the 'X' the program is already ending declaring the player a winner. Following this my code:…
-
0
votes1
answer123
viewsAllegro 5 C/C++: Color problem
I am using Allegro 5, and read that to create colors just use al_map_rgb or al_color_html, then I made a map to easily access various colors: #include "allegro5\allegro.h" #include…
-
0
votes0
answers1473
viewsRemove even elements from a simply chained list
I am doing a function to remove ALL even elements from a simply chained list, but when I run the system, only one even element is removed each time I call the function. Ex: Elements={2, 4, 5, 3}, if…
-
0
votes1
answer96
viewsMemory Allocation - Infinite loop when using the free() function
I’m doing a code in C to test concepts of data structure that are passed through my university. But I came across an error when using the function free, that generates an infinite loop in my code.…
casked 7 years, 3 months ago Leonardo Furtado 144 -
0
votes1
answer96
viewsPointers with argc and argv
I have the following code to run on the terminal. It checks if the first argument is a '+' and then sums up the following numbers. int main(int argc, char *argv[]) { int i, soma; char oper; oper =…
-
0
votes1
answer125
viewsRead text file and store fields in variables
I need help on the following: I will do a b-tree to present a work at the college, which consists of reading the data from a text file and passing them to the B Tree. I will do as follows: I created…
-
0
votes2
answers109
viewsHow to average N numbers greater than 6
I have to make a program in C that shows at the end the average of N numbers greater than 6, but I’ve exhausted my ideas on how to solve this. What I’ve been able to do so far is this: #include…
casked 6 years, 3 months ago Augusto Dalponte 11 -
0
votes1
answer76
viewsCounter adding an extra value to the vector with pointer
I’m trying to finish an exercise that asks for 4 ages and the output tells how many of the inserted ages are greater than or equal to 18 but the counter always adds a value greater than 18 at the…
-
0
votes2
answers57
viewsProblem in a function parameter
#include <stdio.h> #include <stdlib.h> int pos_setinha(int x); void menu(int x); int main() {int x=0; do { menu(pos_setinha(x)); } while(1); } int pos_setinha(int x) { x=0; char C;…
-
0
votes1
answer572
viewsDecrease, increment and sum of pointers in C
Why when I try to add the last pointer to another 15 it repeats the second to last pointer and does not add the pointer *ptr_xi with 15 others? int xi; int *ptr_xi; void imprimir() printf("valor de…
-
0
votes2
answers900
viewsHow can I export output to a C text file?
I want to pass the program output to a . txt file, as I would?
-
0
votes1
answer93
viewsWhy can’t I print it?
It’s a simple code (I’m practicing pointers) It is not printing the result, the program closes... because? ;-; #include <stdio.h> #include <math.h> #define PI 3.1416 void…
-
0
votes1
answer120
viewsUsing a pointer can make my code faster?
I was told that if I work using pointers the program will be faster. If instead of using index to traverse a vector I use the pointer, it looks better?
-
0
votes1
answer181
viewsSOCKETS IN C - TCP Sequence Number
I could use a little help with sockets in C. My teacher passed a job in which I must perform communication TCP between client and server where I must execute some rules.. 1 - The Client sends a…
-
0
votes1
answer2102
viewsC ordering using recursion
I need to make a vector ordering code using recursion. I looked into the sorting methods and found two that would be interesting: Lection Sort and Quicksort. However, I tried to use Selection Sort…
-
0
votes2
answers3199
viewsHow to return a char vector to a function in C? type as a pointer
Hello, I’m trying to return a vector that receives the content of a matrix in a function, but it’s not working, I appreciate if someone can help me, I’m in doubt Function call on main: char…
casked 7 years, 3 months ago Italo Zuckerberg 63 -
0
votes2
answers5464
viewsSegmentation failure: Recorded core image
I made a code in C to find the smallest value and position of it in a vector x[N]. Every time I compile the program by terminal (Linux), it accuses the following message: Segmentation failure…
-
0
votes4
answers7433
viewsReverse vector position/value
I need to reverse one vector and store in another one this way: vector[5] = [1,2,3,4,5] < I will pass the values like this inverse[5] = [5,4,3,2,1] < And accurate to invert values and…
-
0
votes1
answer81
viewsWhat’s going on here on this C show?
I’m making a program where the user enters with 10 values, and at the end of this, presents a message saying the total value. My code : int rep,valor,soma; while(rep < 10) { printf("Digite um…
-
0
votes2
answers183
viewsValue Assignment Doubt in c
Here’s my code, why is there a change in the other variables, I’m not just changing the line line to variable value? why the others change? int a = 1, b = 2, c = 3, valor = 0; valor = a;…
-
0
votes2
answers1337
viewsWhat is the best way to clean the keyboard buffer
I have seen in several forums that you should use setbuf(stdin(NULL), or getchar I am new in C language and I am doubtful on this subject
casked 6 years, 1 month ago toper main 23 -
0
votes1
answer317
viewsprinting memory junk
This program must load words from a file txt to a vector, Draw 10 words, put them in vector and then print on screen. The problem is that it is printing memory junk and do not know how to solve this…