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
votes2
answers332
viewsCalculation of the smallest divisible number giving infinite loop in C
I did a C program to solve the following exercise: Code: #include "stdio.h" #include "stdlib.h" int main(int argc, char const *argv[]) { int num = 0; int count = 20; int contaDivisores = 0; for(int…
-
0
votes1
answer2019
viewsSum the diagonals of a matrix
I need to do a program that takes out the diagonals of a matrix. As an example But I’m having a hard time. Follows code: #include <stdio.h> #include <math.h> #define M 4 #define N 3 int…
-
0
votes2
answers611
viewsDownload multiple images at once from a php site
Next, there’s a website where I need to download several images, I can access the image as follows: url.com/get_img.php?user=VARIÁVEL where variable is replaced by an integer and the same returns me…
-
0
votes1
answer91
viewsHow do I get data from a file with fscanf, in c?
Code: while(fscanf(arq,"%d %d %d\n\r",x[i],y[i],raio[i])!=EOF){ cout<<x[i]<<endl; i++; } Contents of the file: mdb236rl D CALC B 912 2247 58 mdb240rl D CALC B 1752 776 95 mdb244rm D CIRC…
-
0
votes1
answer46
viewsProblem with Segmention fault
I was studying a little bit, I’m very beginner in programming, and I came across a mistake, the segmention default, I will drop my code, and if possible, someone can figure out why I’m getting this…
-
0
votes1
answer688
viewsSwap value of two variables without using a third, using either sum or subtraction only
Using only two variables (A and B) and also using only (sum or subtraction), make the value of A turn the value of B and the value of B become the value of A.
-
0
votes1
answer108
viewsLinked list main help
I’m having trouble creating a main so test if my functions are correct. is a list program on, no need to have menu. #include <stdio.h> #include <stdlib.h> #include <stddef.h>…
-
0
votes0
answers77
viewsNumber function in the List
People have that function tem_numero_na_lista it turns out that it is printing on the screen only the last value I entered in the list. The effect I want is to print out whether or not you have…
-
0
votes1
answer170
viewsProblems with "libpq.so. 5": Wrong ELF class: ELFCLASS64 in C
I am trying to run a file compiled in c and I get the following error message: "error while loading Shared Libraries: libpq.so. 5: Wrong ELF class: ELFCLAS64" I did a search and identified that this…
-
0
votes1
answer348
viewsReading txt file in C and data interpretation
I need to read txt files in C and interpret the data from inside the files. The files contain parts in TEXT and others in DECIMAL/INTEGER numbers. What I need to do is read the whole file and pass…
-
0
votes1
answer48
viewsDoubt with excel files
I have a list of dates in a BTH.cvs excel file. I want to copy the entire file to another new.cvs, but a.exe stops working. #include <stdio.h> #include <stdlib.h> int main(int argc,char…
-
0
votes0
answers128
viewsscript to encrypt texts
I’ve been trying to create a program in c to encrypt a text, but I’m still learning many commands in c. So far I have created a string "char text[200]" to save my text. Then I created two .txt.…
-
0
votes0
answers79
views'fscanf' changing pointer to struct in C
Good night. I was writing a program to read strings from a text file, and put these on a list simply chained in case its length was equal to 5. The problem is that the program started to not work…
-
0
votes1
answer931
viewsHow to calculate the distance between two points and calculate distance ABC, CAB, BAC? in C
created in class this program that calculates the distance between two points and then gives the option of 3 different paths: ABC, BAC or CAB. I would like tips to optimize my code, ideas on how to…
-
0
votes2
answers1435
viewsC - Print the N-esimo prime number
The exercise asks the program to read an N number and print the N-esimo given prime number. Ex: I enter N = 3. The program will have to print The third prime number, which is 5. Other examples:…
-
0
votes2
answers189
viewsHow to test if a string is a number in the C language?
I’m a beginner in programming. I am performing an exercise in which I must determine whether a character string is a number, considering that the user can write anything as input. So I created the…
-
0
votes0
answers407
viewsPerform wide search
I’ve got a job to do and I’m racking my brain to figure out how I’m gonna do the same. I must perform a wide search based on a .txt. The teacher sent part of the code (I’m just doing the main), I’ve…
-
0
votes1
answer169
viewsProgram stopping responding in C - chained list
I’m doing a college job in C and I’ve pretty much finished it. However, I got caught up in a bug that I can’t get out of. My show, when I cross the line aux1=aux1->next; simply stops working. It…
-
0
votes0
answers1349
viewsHow to read a . csv file in C?
I created this code in C where I inserted the coordinates of some points and with SVG I drew those points in the space connected by lines. all saved in a. html file to be executed in the browser.…
-
0
votes0
answers73
viewsString inversion C language
I have to do a show and almost finished the same. Here’s what you ask for: Palindrome is a phrase or word that keeps the same meaning when read backwards, for example bone, he, grate, etc. Make a…
-
0
votes1
answer246
viewsThread1: EXC_BAD_ACCESS (code=1,address=0x68)
I am having this problem in ide Xcode. On line 8 the warning appears Thread1: EXC_BAD_ACCESS (code=1,address=0x68) The file . txt is in the same folder as the main. void construir1(struct elemento…
-
0
votes4
answers5419
viewsVector without repeated numbers in C
How do I load an array, let the user enter all values, which cannot have repeated numbers? For example, a vector of 20 positions that asks the user to enter each value, and, when giving a value…
casked 7 years, 11 months ago Beto Oliveira 1 -
0
votes1
answer2257
viewsPROBLEM WITH FGETS IN C
#include <stdio.h> #include <stdlib.h> /*definir operador lógico para chuva (1 para TRUE e 0 para FALSE) */ #define TRUE (1==1) #define FALSE (!TRUE) struct eventos_atm_st { float temp;…
-
0
votes2
answers83
viewsProblems with struct reading in function
For several days I’ve been trying to understand why this error occurs, but I haven’t found it anywhere. The following is, I declared a vector of the data struct and passed this vector to the…
casked 7 years, 11 months ago Italo Zuckerberg 63 -
0
votes1
answer2307
viewsHow to use atof in C
Could you help me use the atof function? My code is giving "access Violation" in the line I am using atof, already tried to change the type of the "given" array to both int and float int main() {…
casked 7 years ago Lucas Nogueira 3 -
0
votes1
answer88
viewsI cannot make a vector point correctly to a function it belongs to
I have tried several times, but the compiler does not understand the references made in the header of the function void CalculaValorparaPagar(float ValorPago[MAX], float Quant_Kwh[MAX],float…
-
0
votes2
answers160
viewsI am unable to copy characters from one string to another
I am making a program that until the user type +, the typed string will be copied to another, for example stack+, or the copied string would only stack, I tried to make the code below only that did…
casked 7 years ago rafael marques 939 -
0
votes1
answer281
viewsRead end file to start
.... fseek(arq, 0, SEEK_END); while(!feof(arq)){ //fgets(&ch,2,arq); fread(&ch, sizeof(char), 1, arq); //printf("\n%c",ch); num = atoi(&ch); vem=makenode(); vem->numero=num;…
-
0
votes1
answer1025
viewsAveraging the sequence of while
I’m solving college exercises, but I got caught up in one: The exercise asks me to calculate the even numbers between two integers, and that at the end, I do the arithmetic mean between the pairs.…
-
0
votes2
answers89
viewsDifference in calls on main
Guys, I want to know the difference between these two calls? inserir_inicio(&p, cria_no(0)); p = inserir_fim(p, cria_no(0)); When I try to switch to the style of the first call the code compiles…
-
0
votes1
answer40
viewsI’m having trouble finding the highest number
Well I’m doing a program that needs to know the indexes of the highest values in the vector, but I’m not getting the code I tried. #include <stdio.h> int main(int argc, char** argv) { double…
casked 7 years ago rafael marques 939 -
0
votes3
answers314
viewsunite 2 vectors (a[10], b[10]) into a vector c[20]
How do I join two vectors A[10] and B[10], to create a vector C with 20 elements. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> int main(){ int…
-
0
votes1
answer12103
viewsHow to make a transposed matrix of user-chosen dimensions in c?
I need to make an algorithm that transposes an array whose size should be chosen by the user. I’ve written a code, but it doesn’t work properly for matrices whose number of rows is less than the…
-
0
votes1
answer29
viewsProgressively Removing from the List
#include <stdio.h> #include <stdlib.h> typedef struct ListElmt_{ int data; struct ListElmt_ *next; } ListElmt; typedef struct List_ { int size; ListElmt *head; ListElmt *tail; } List;…
casked 7 years, 11 months ago Pedro Henrique Faria Teixeira 71 -
0
votes1
answer568
viewsMultiplication of two matrices in C. Transfer of values between functions
Recently I was given a project of`multiplication of matrices, where I have two functions: a "main", and another "product of two matrices"; a main, will read the different values of the elements of…
casked 7 years, 11 months ago Francisco Wait For-it Pinto 9 -
0
votes0
answers92
viewsHow can I read a CSV file with different line types?
I am trying to read a CSV file that has different lines. I am using fgets and Strtok to store in a list. the problem is that being different lines do not know how to stop and move to the next.…
-
0
votes1
answer193
viewsHow to transform a decimal number to binary using String
Well I managed using whole numbers, only the teacher wants code to accept very large number that do not fit in whole, he said he had to read as a string, only I do not know how this can be done My…
casked 6 years, 11 months ago rafael marques 939 -
0
votes1
answer1397
viewsUser and password validation in C
I am making a game that requires authentication to play. How do I validate user and password saved in a file .txt? The code I’ve developed so far is this: void login(){ int escolhe_dificuldade(); //…
-
0
votes4
answers158
viewsprintf function is not running after scanf method
Well my problem is this, I have a program that calculates the area of a circle, here’s the code: #include <stdio.h> #define PI 3.14 int main() { double radius; double area; printf("Program to…
casked 6 years, 11 months ago Carlos Henrique 77 -
0
votes1
answer298
viewsScanf function causing infinite loop
I have a simple code that converts a char in a int within a loop while, but when I execute and place the first char, the program goes into loop infinite, here comes the code: #include…
casked 6 years, 11 months ago Carlos Henrique 77 -
0
votes1
answer43
viewsDoubt with the %i
I know that with %i you can read numbers in decimal, hexadecimal, and octal, but when I type 0x15, the number 21 appears, being that it was fifteen that was appear or I am mistaken ? Example below…
casked 6 years, 11 months ago rafael marques 939 -
0
votes0
answers188
viewsstruct that stores the number of rows and columns of the matrix and of a vector
I used a struct to store the number of rows (m) and columns (n) of the matrix and another to store the number of columns of the vector (n). I make the product of two matrices in function prod() and…
-
0
votes0
answers343
viewsHow to read PDF files using C language?
I have to read a PDF file using linguagem C and seek a string present in the file. However when pulling the file by function fopen and display it on the screen, it appears all those encoded…
-
0
votes1
answer74
viewsif() entry but instructions are not executed
I am trying to make a chat using Pipes (chat between server and client). I made an output condition, in case the server wants to quit/turn off the chat writes "quit" on the client in the same way.…
-
0
votes1
answer763
viewsWarnings when compiling the program
In the code below, I need to create a structure for Point (Coordinate x and y) and create a function that creates these points using pointers. The structure was made as follows: typedef struct…
-
0
votes3
answers123
viewsproblem with inversion of values of a vector
Good evening, I can not find problem in a code of my, it is an exercise of the site codewars(https://www.codewars.com/kata/sorting-on-planet-twisted-3-7), for those who do not know the site,is a…
-
0
votes0
answers47
viewsProblem in method verification
I did this function for the game of old: void jogadaPC(char m[][3], char opc) { puts("\nVez do computador."); sleep(1); int linha = rand() % 2; int coluna = rand() % 2; bool vazio = localVazio(m,…
-
0
votes2
answers82
viewsWhat is the difference in the assignment of an already started matrix to an uninitiated one?
char nome[10]; nome = "w" //Aqui ocorre um warning, por quê isso ? char nome_dois[10]; nome_dois[0] = "w" // Aqui e normal, como esperado. "w" is in a static memory? nome[0] is in a dynamic or…
-
0
votes1
answer997
viewsMethod for harmonic media calculation!
Ola I need help to perform a harmonic media calculation of an "infinite" series, so to speak. Ex. I have a data capture system that is always injecting information into a BD. However there are many…
-
0
votes1
answer127
viewsDescription of a declaration by reference
I have a question in making descriptive comment related to the parameters of these 3 functions below. int proximoClientePreferencial(CLIENTE *filaPreferencial){ void mostrarFilaPreferencial(CLIENTE…