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
-
-1
votes1
answer450
viewsHow to do a pointer struct for a function that prints the struct itself in C
I have a structure: struct conteudo{ tipo valor; //valor qualquer void (func*)(void*); //ponteiro para função que imprime a propria estrutura }; I would like to know how to call this function to the…
-
-1
votes3
answers1056
viewsHow to convert an integer vector to an integer-only variable?
I need to convert an integer vector to a single variable, example: int teste[] = {2, 3, 5, 6}; for int result = 2356; how to do this? NOTE: I don’t have the vector size (+ - dynamic)…
-
-1
votes3
answers1163
viewsError using Else: "'Else' without a Previous 'if'"
I’m trying to make a basic program, but I stopped in half because it was wrong: error:'Else' without a Previous 'if' #include<stdio.h> int main() { int med1, med2, med3; printf("\nDigite a…
-
-1
votes1
answer91
viewsBeginner in C! Doubt!
Hello! Someone could help me in this question here! (C Language) "Write an algorithm that reads 15 numbers and writes how many numbers larger than 30 were typed." What would the C algorithm be like…
casked 5 years, 10 months ago Dexter Mayhew 27 -
-1
votes1
answer193
viewsThe function should calculate the size of a string, passing a string as a parameter
#include<stdio.h> #include<string.h> /*Função que verifica tamanho da string*/ int conta_str(char x){ int i, tamanho = 0; char str[40]; do{ gets(str); for(i = 0, tamanho = 0 ; i < 30…
casked 5 years, 10 months ago Paulo Maciel 3 -
-1
votes1
answer50
viewsI have a question about this code snippet - Scanf
Hello, would you like a help with this code snippet, could someone explain to me what it does exactly ? (Especially the part %*1[ n]) scanf(%[^\n]%*1[\n], string);
-
-1
votes2
answers174
viewsProgramming exercise C
I made a structure in c that receives : code, age and marital status... How to make him count the number of singles, married and divorced.... # include<stdio.h> struct basededasos{ Int código;…
casked 5 years, 9 months ago DrunkMaster 1 -
-1
votes1
answer285
viewsProblem with switch inside the While loop
I would like a help to solve the problem I’m having with the switch inside the loop, it never finalza, stays in an eternal loop. What should I do to solve ? #include <stdio.h> #include…
-
-1
votes1
answer64
viewsBubble Sort in C inconsistent
I’m trying to create the basic structure for a program that uses Bubble Sort. However, when testing its basic structure, I see that the final vector is not being returned correctly. #include…
-
-1
votes1
answer115
viewsEnter lower case/upper case in C
How do I independent of the user typing the letter in lower or upper case read by scanf_s? printf("\nVocê gostou do nosso produto?\n" "\n[S] - Sim" "\n[N] - Não\n\n" "RESPOSTA:\t\n"); scanf_s(" %c",…
casked 5 years, 8 months ago Any2Just4u 19 -
-1
votes2
answers538
viewsCodeblocks compiles (linux operating system Mint) but does not show on screen
People installed Codeblocks on Linux Mint and so it opens perfectly you make the program it compiles beauty (If you have errors it shows), however, it does not open the interactive screen (sorry for…
-
-1
votes1
answer27
viewshow to read operating greater than 9
How to read an operand composed of 2 or more characters, in the code I created I go through all the string in order to identify each type of operation and number, only that I am traversing this…
-
-1
votes1
answer142
viewsEven using fflush, the fscanf function is not working
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <locale.h> struct cadastro{ char nome[30]; float notas[1][4]; int…
casked 7 years, 4 months ago Braian Freitas 159 -
-1
votes2
answers92
viewsZeroes only appear in the division
The result of division is only zero, which is wrong? #include <stdio.h> void main() { double Nota1, Nota2, MediaPond; printf("Escreva a nota 1: "); scanf("%f", &Nota1); printf("\nEscreva a…
-
-1
votes1
answer28
viewsWhy am I making a mistake adding two numbers using pointers?
#include <stdio.h> int* adicionar(int *a,int *b) { int c = *a + *b; return &c; } int main() { int primeiro, segundo; int* temp; scanf("%d%d",&primeiro, &segundo); temp =…
-
-1
votes2
answers57
viewsStructs not fed
Dear Programmers(s) in C, good night, I ask for help for the following case: I want to feed an array of structs to each interaction in a line of a file, the problem is that, although I can read the…
-
-1
votes1
answer21
viewsWhat is the error in my pointer passing to the read_vector() function?
void read_vetor(int *vet, int n) { for (int i=0;i<n;i++) { scanf_s(" %d", *(vet+i)); } } void write_vetor(int* vet, int n) { for (int i=0;i<n;i++) { printf("%d", *(vet+i)); } } void main() {…
-
-1
votes1
answer269
viewsC - Exception thrown to scanf_s ler string
I’m doing a lot of my college activities that should be done using C, I’m struggling because I’m used to using only C++, I was first using scanf but the visual studio did not compile indicating…
casked 5 years, 1 month ago Samuel Ives 1,676 -
-1
votes2
answers398
viewsMultiple of a number in C
i am making an algorithm that finds the first multiple of 11, 13 or 17, but I don’t know how I show only the first multiple within a loop of repetition. int numero; printf("Digite um numero : ");…
casked 5 years ago Matheus Santos 41 -
-1
votes1
answer453
viewsWarning error: format specifies type 'double' but the argument has type 'float *', C language
Hello, I made this program to show the average between 2 numbers and show if the student was approved or not, however the result is not working. #include <stdio.h> int main(void) { float…
casked 5 years ago Luis Artur 13 -
-1
votes1
answer40
viewsAlgorithm problem in C
Good afternoon, I’m trying to make a program to estimate the contagion from some parameters, but the program is not working properly, it does not create file, and has not printed any of the prints I…
-
-1
votes1
answer1242
viewsSmallest value typed in a vector
I wonder why my code is returning the wrong value of the smallest variable : int i, numero[10], menor; menor = numero[0]; for (i = 1; i <= 5; i++){ printf("Entre com o %d numero : \n",i);…
casked 5 years ago Matheus Santos 41 -
-1
votes1
answer55
viewsError reading string in C
Good afternoon people! In my program I use for reading some strings that fill a struct vector. The first reading usually occurs, but in the second reading the program skips the reading of a string,…
-
-1
votes1
answer47
viewsSum function returns zero
By the time the input is all ok with the information, but in the output only gives the result 0 and do not know what else to do, already I moved and I reworked the whole code. The idea is that in a…
-
-1
votes1
answer92
viewsI’m a beginner in C, I need help on a task!
The statement says: 1. Knowing that a company has 20 employees, make a program that reads the salary and sex of each employee and report how many employees earn more than R $ 1.000,00 and how many…
casked 7 years, 3 months ago Anderson Jesus 1 -
-1
votes2
answers861
viewsProgram in C, how to print the word without the character?
I can’t print the word without the character and I have no idea how to execute the ending. if anyone can help follow what I’ve done: #include <stdio.h> #include <string.h> int main() {…
-
-1
votes1
answer109
viewsVector of large size in C
I’m studying the data types of the C language. And today I decided to create a vector of very large size, in this case, 10 8. So, I made a small code in which I declare this large vector (being that…
-
-1
votes2
answers71
viewsThis code is leading me to an infinite cycle and I can’t figure out why
This code is leading me to an infinite cycle and I can’t figure out why. #include <stdio.h> #include <stdlib.h> #include <time.h> void troca (double *n1, double *n2) { double n; n…
-
-1
votes1
answer72
viewsProgram in C closes after execution of procedure
Boas, The thing is, I’m developing a program that is for evaluation, which is to do a drug management...the goal is to have the features to add and remove medicines, as well as their listing... I am…
casked 7 years, 3 months ago Marcelo Cruz 1 -
-1
votes1
answer35
viewsProblem with C program
I am solving an exercise that asks to read a vector of 20 positions and print on the screen excluding repeated values, I was able to solve however, it is showing the values on the screen several…
casked 4 years, 9 months ago vitor sousa 1 -
-1
votes1
answer40
viewsHow can I find out, using the C language, which graphical environment is installed on Linux?
How can I find out which graphical environment is installed? Example: KDE, GNOME, XFCE or LXDE?
-
-1
votes1
answer37
viewsHELP WITH CODE IN C, STRINGS
// what changes I have to make to make each character repeat once more than the previous one? for example: input: Roberto exit: Roobbbeeeerrrttttooooooooooo #include <stdio. h> #include…
-
-1
votes1
answer110
viewswhether the number is even or odd in a single array
float vet[10]; //processamento for(x=0;x<=9;x++) { printf("\n informe o %d° número:",x+1); scanf("%f",&vet[x]); //saída de dados if (vet[x] % 2 == 0) { printf("\n O número %2.f é…
-
-1
votes2
answers161
viewsTerminate program with enter/ EOF
I need the code to end after an empty enter, with no input or the 'EOF', but I don’t know how to apply it and I didn’t understand very well the examples I saw. The program is almost complete, it…
-
-1
votes1
answer133
viewsHow to make a macro that clicks in several places?
Hi, I’d like to know how to make one. exe that acts as a macro, whenever I press the ALT key it will perform mouse clicks at a certain position with shift pressed at the same time. It can be in any…
-
-1
votes1
answer40
viewsError finding equal numbers
I’m trying to ask a question that if the same values are going to be counted with a single one, only I’m not getting to score as a single value. question link #include <stdio.h> int main(int…
casked 7 years, 2 months ago rafael marques 939 -
-1
votes1
answer48
viewsscanf reading the variable twice!
#include <stdio.h> #include <stdlib.h> /*Faça um programa onde o usuário digita um valor, e imprima na tela todos os valores entre 0 e o valor digitado. */ int…
-
-1
votes1
answer71
viewsWhere to use the n in the printf?
Hi, my question is where to put the \n. I see several situations where the \n is used at the end of printf: int x = 2, y = 3; printf("X = %d\n",x); printf("Y = %d",y); But also, I see it being used…
-
-1
votes1
answer197
viewsProgram Received Signal SIGSEGV, Segmentation fault
When I call this function happens this error "Program Received Signal SIGSEGV, Segmentation fault." void cria_agenda(Agenda *agenda_prof, int Id_prof, char *nome, int ano){…
-
-1
votes1
answer99
viewsHow to store arrays in vectors in C?
I need to create a vector that stores matrices and print these matrices. What would be the correct way to do the assignment and print the matrices through the vet? int main() { int *vet; int **mat;…
-
-1
votes1
answer31
viewsthis algorithm is to verify divisor
this algorithm is to check if the first is splitter of the second and at the end show whether it is splitter or not splitter, no error, but do not know how to continue #include <stdio. h>…
-
-1
votes1
answer88
viewsargc argv with file
Someone can help me, I need to open a read-only txt file informed by the user with argc and argv but the file does not open, is giving error in opening the file here my . c #include <stdio.h>…
-
-1
votes2
answers40
viewsCan anyone tell me how to do this program in C to display the vector in which I typed the one number that was stored in it?
#include <stdio.h> int main() { float vet[6]; int i, x; for (i=0;i<6;i++){ scanf("%f", &vet[i]); } …
casked 4 years, 3 months ago Lucivaldo Rodrigues 11 -
-1
votes1
answer286
viewsC/C++ libraries and preprocessing
I’ve always wondered the syntax of #include and of #define, as they differ greatly from the syntax of the rest of the language. I found that this is because these commands are intended for the…
-
-1
votes1
answer77
viewsWhen to use a Thread or Process?
I am preparing for a proof of Operating Systems and I would like to know what are the best situations to use a thread or create another process.
-
-1
votes2
answers44
viewsError in a simple program
#include <stdio.h> int main() { float aguagasta, price, total; printf("Digite o valor de agua [em metros cubicos] gasta em sua casa:\n"); scanf("%f", &aguagasta); if (aguagasta < '20'…
casked 4 years, 2 months ago Arthur Ribeiro Dantas 11 -
-1
votes2
answers73
viewsDynamic lease in C++
Good afternoon. I would like to know how to allocate a string dynamically in C without asking the user the size of the string. Just putting it to write the string.
-
-1
votes1
answer21
viewsSeparate string and numbers (Ex.: 00oy285dase556 - num1=00, num2=285, num3=556)
I need to create a reading module, the variable rate, of numerical values in the port Serial, receiving an integer string, interspersed with letters and using the letters as separator to obtain only…
casked 4 years, 2 months ago Sabrina Inez 1 -
-1
votes2
answers64
viewsIncrement does not work as expected
I took this exercise and put it to compile, but it’s going wrong I think because the values I see would be 5 and 9, but it’s going 6 and 8, I believe the IDE is not reading correctly. #include…
-
-1
votes1
answer28
viewsprintf printing strange numbers
#include <stdio.h> #include <locale.h> void main() { int i, n; setlocale(LC_ALL, "Portuguese"); printf("Digite um número: "); scanf("%d", &n); printf("\nSequência decrescente de %d…