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
answer59
viewsTrash memory output function inserts in the middle of a list
Staff developed this function: tipo_lista * insere_meio(tipo_lista *aux, tipo_lista * valor, int pos){ int cont=1; //é a posição do primeiro elemento da lista encadeada tipo_lista * p = aux;…
-
1
votes1
answer180
viewsProblems scanning strings within the switch (C) command
I’m trying to make a program that encodes and decodes strings that are given by the user by the César cipher method, using switch-case to select what should be done, but when trying to read a string…
-
1
votes2
answers177
viewsWhy subtract -48 from a char and turn it whole?
I saw on another forum that guy subtracted -48 from one char and the char became a whole, because it happened? #include<stdio.h> int main(){ char num='3'; printf("%d",num-48); return 0; }…
-
1
votes1
answer264
viewsC - Structures for point, polygonal line and polygon
Good night The exercise asks me to implement three structs: Point (coordinates X and Y), polygonal lines (sequence of 2 to 100 points that are the vertices along the line) and polygon (sequence of 3…
-
1
votes2
answers76
viewsWhat is wrong with the logic of this code that sums bands of numbers?
My algorithm needs to sum all the values between a and b, for example if I type a=3 e b=6 the program needs to speak 3 7 12 18 (3+4= 7/ 7+5=12 / 12+6=18) only he only makes the first two then starts…
-
1
votes2
answers1119
viewsHow to compare part of strings in C?
I can only compare two strings in full in C, but can I compare only part of a string? I wanted to develop a program that reads excerpts from a complaint and based on these excerpts give a response…
-
1
votes0
answers32
viewsCan I pass a string, which is not previously stored in an array, as a parameter for a function?
I wrote this function to remove the characters nay repeated from any string in c: char *repeticoes(char *s){ int i=0, j, cont=0; while(s[i]!='\0'){ for(j=0;j<strlen(s);j++) if(s[j]==s[i] &…
-
1
votes1
answer1616
viewsCircular List Double chained in C/C++
I’m having trouble removing the first and last element of this circular list. // Created by Thiago Cunha on 25/05/2017. // #include "double_linked_list_circular.h" int count = 0; List* init() {…
-
1
votes2
answers217
views -
1
votes1
answer1259
viewsStruct vector and char pointer
Why is this syntax wrong: #include <stdio.h> typedef struct { char* nome; char* numero; }Agenda; void adiciona(Agenda* reg, int i) { scanf("%s", reg[i]->nome); scanf("%s",…
-
1
votes1
answer717
viewsProblem with char returning strange characters
The intention is to replace all words toda for 0, however after X characters it starts returning strange values as can be observed in the comments. I think I’m handling the parameters wrong, but at…
-
1
votes0
answers44
viewsName of a file redirecting the default C entry
How to store a file name in a variable when redirecting to default entry without using argv. Example of execution: ./a. out < filename.txt…
-
1
votes1
answer1940
viewsDecimal to binary conversion
There would be a way to solve this problem using just repetition, div and mod, without using vector or a specific function for conversion?
casked 6 years, 6 months ago Ronaldo 64 19 -
1
votes1
answer39
viewsbuffer is not cleaned during the second execution of cilclo
During the second execution of the loop for the setbuf no Urti effect and if the 2nd 'product' has more than 14 characters assigned the other characters to the next positions. #include…
-
1
votes2
answers95
viewsFunction to read file in C
What function to use in C to read file, row by row, and in each row contains different data types?
-
1
votes1
answer100
views -
1
votes2
answers100
viewsString compilation problem in C
I’m trying to compile this code into C: #include<stdio.h> #include<string.h> #define tam 100 typedef struct TipoAluno{ char nome[50]="A"; char curso[50]="B"; char cota[50]="C"; int…
-
1
votes2
answers459
viewsSpecific libraries and standards of C compilers on Windows and Linux
I’d like to know why I know her. h and the strrev() library string.h, not on Linux. Is there any more that can only be done in Windows? And why does this happen? Is there any that can only be done…
-
1
votes1
answer165
viewsIs the <openssl/bn. h> library part of the ANSI C standard?
I was looking for how to work as big numbers on and found a blog that talks that it was possible to work using the library, I wondered if it is part of the ANSI C standard ?
casked 6 years, 5 months ago rafael marques 939 -
1
votes1
answer992
viewsInsertion at the end of a chained list C
I would like to know how to go through the list so that I can add a new No at the end of it, in the case at the position no->Prox of the last in the present in the list. Here is my code: typedef…
-
1
votes1
answer938
viewsHow to copy the contents of two files into a third file in c?
I need to create a file that is a copy of the contents of two other files (already existing), the user will type the name of these two files. In my case, the first file contains: "hi, banana,…
-
1
votes1
answer40
viewsHow do I define an element of a Struct in C?
I intend to make a program that uses structs to store data, but that there is already some data inserted in it, I will give a similar example: struct registro { char nome[30], telefone[11]; int…
-
1
votes1
answer462
viewsProblem in ordered insertion code of structs (records) in files
I am doing a work in which I have to insert structs in alphabetical order in archives, in which the structs are political and the archives (which together form a chained list) are the parties. I’m…
-
1
votes1
answer69
viewsDoubt with C function
How do I get the variable I used to store value I read in the scanf, passed to the function I created? Ex: #include <stdio.h> int main(){ int a, b; scanf("%d %d", &a, &b); } int…
-
1
votes1
answer424
viewsDiscover string inside string without string library. h?
My function needs to check if one string is contained in another and speak where the first place where the letter was equal occurred, but is always returning the size of the first string What’s…
-
1
votes1
answer1084
viewsPlace string in a character array
I am learning character matrix and wanted to make a simple program in which I create a character matrix 200x100, put a string at position 0 and printed. This is part of a larger program that I’m…
-
1
votes2
answers392
viewsArray sum storage in vector
This function I created needs to calculate the summing up of each column of the matrix and store in a vector position. However, it is not giving the desired result, I think it may be within the…
-
1
votes1
answer146
viewsHow do I recover the current date of a Mysql database in Arduino?
I’m making database connection mysql using the Arduino next to esp8266, wanted to know how to take current date store in a variable to then send to the bank. I’m in trouble just to get the current…
-
1
votes1
answer3860
viewsRecursion in C: Sum
I’m learning Recursiveness in C and need to make a recursive function that returns the sum of a number n whichever. The prototype of the function is float somatorio(int n) and the sum to be…
-
1
votes1
answer2173
viewsHow to create a C Ranking?
How can I read and sort a text file where the information is like this: carlos 5 lucas 20 josue 10 *On file it looks like this. Saved randomly but when I read the precise information it is in the…
-
1
votes3
answers5789
viewsCheck whether a date is valid in C or not?
I need to check if a date is valid or not in C, and for this I will have a function called verificarData that will be passed to it the user input and will check whether or not it is a valid date.…
-
1
votes1
answer32
viewsCan’t it be used as a function?
I’m creating a program that sorts some numbers from a vector, so it’s a bubble sort. I’m using a function called trocar to exchange seat numbers when one is larger than the other, but the compiler…
-
1
votes1
answer165
viewsWhat does "sort an array" mean, either by rows or columns?
What it means to "sort an array", whether by rows or columns?
-
1
votes1
answer71
viewsSomething simpler than that to allocate a dynamically typed text?
// FUNCAO // char *nome(char text[20]) { char *n; int n2; int n3 = 0; printf("%s\n",text); while((n2 = getchar()) != '\n' && n2 != EOF) { if(n3 < 1) { n = (char*) malloc(sizeof(char));//…
-
1
votes1
answer98
viewsFunction is zeroing last vector value
#include <stdio.h> #include <stdlib.h> /** 2. Faça um programa que, a partir de um vetor de 12 posições, crie funções para: A. Digitar valores no vetor; B. Imprimir o valor somatório de…
-
1
votes1
answer668
viewsCreate a file in another directory
I have a folder that contains my file . c, its executable and another folder called Arquivos. I need that when the function below is executed the file is created in the folder Arquivos and not in…
-
1
votes1
answer57
viewsInline in an infinite recursive function
What happens to the program if I declare an infinite recursive function inline?
-
1
votes2
answers157
viewsSum of numbers from right to left
I need to sum the digits of a number typed by the user. For example: If input equal to 20, make 2 + 0 = 2 If the input is 45, make 4 + 5 = 9 Visualg and C can be used.…
-
1
votes2
answers9247
viewsHow to check if one string is contained in another in C?
I have two variables: char s1[20]; char s2[20]; I’ll go get the input user of the two variables, and after this, I need to check whether s1 is contained in s2, even a part of it. For this I will use…
-
1
votes1
answer133
viewsDynamically allocating text, and error in free()
I’m trying to allocate dynamically, but the error is appearing: Error in . /name. c; invalid : 0x000001c18834 My code: // FUNCAO // char *nome(text[]) { int n3 = 0; int n2 = 0; char *n = NULL;…
-
1
votes1
answer131
viewsComparison in "if" does not fall where it should
What error in my code? Because regardless of the answer, the result is the else. #include <stdio.h> int main () { //variaveis char sigla[3]; //programa printf ("Entre com a sigla do seu…
-
1
votes1
answer43
viewsHow I define a unit of measure in the value of the variable
I have a question asking that I calculate the volume value of an oil can, and thinking about it I will use float. How do I place a unit of measure, for example the variable altura = 50cm.…
-
1
votes1
answer52
viewsWhy is the size of the vector being changed in the function?
Tanho comes as 2, when passed the tamVet function() #include <stdio.h> int tamVet(int *vet){ int tam; tam = sizeof(vet) / sizeof(vet[0]); return tam; } int main(void){ int vetor[10]; int tam =…
-
1
votes1
answer117
viewsHow do I output my array’s Indice in C?
I have a program that will check 9 numbers and tell which one is the biggest of all, and for this I am using vetor already filled with values, and I’m using a for to go through the whole vetor and…
-
1
votes2
answers82
viewsWhy does this code give Segmentation fault?
Whenever the first line of the map is filled in, a Segmentation fault, I wonder why. void newmap(int x, int y , int players){ int linha,coluna; char **map = (char **) malloc(sizeof(char*) * y); *map…
-
1
votes0
answers30
viewsconditional within the if?
I don’t know if I’m crazy kkkk but I think I remember seeing simple conditionals inside the printf. However, I don’t remember how it does. tipl, he does the same thing as this: if (xxx)…
-
1
votes3
answers1242
viewsPoint inside a polygon
I need to create a function that checks if a point is inside a polygon. For this, I researched on the Internet some solutions that can help me. I found one that seems to be of great help, but in one…
-
1
votes1
answer3225
viewsCount nodes in binary trees
Good evening, I’m studying binary trees and I came across an exercise that asks me to count the knots. I did it by adapting an algorithm that calculates height and works... int conta_nos (arvore *r)…
-
1
votes0
answers121
viewsHow to properly connect bluetooth server in C to Android?
I am trying to connect an application between the computer and an android app. The app will be the client and the computer will be the server. Using Bluez( C library for bluetooth on linux) for…
-
1
votes1
answer434
viewsWhat is the use of struct in c?
I’ve learned how to use the command in a code, but I still don’t understand exactly what it’s for. Could someone explain to me, with examples if possible, their usefulness?