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
answer1566
viewsSwap rows from an array
Below is my code. I need to exchange line 1 with line 3 and line 2 with line 4. The problem is that the third line is not changing and I don’t find the problem. int matriz[TAM][TAM], n = 0, x = 0, y…
-
1
votes1
answer323
viewsHow to use free in a structure variable (chained list)?
I can’t use the free() in "struct Lista *proximo". Follows my code: #include "stdafx.h" #include <stdlib.h> #include <conio.h> #include <locale.h> struct Lista { int num; struct…
-
1
votes2
answers64
viewsHow to copy a string in C?
The following method I found on the internet, serves to create a string copy.: char* bin_copy_string(const char* begin, const char* end) { char* result; result = malloc(end - begin); if (result) {…
-
1
votes4
answers9882
viewsProgram to discover repeated characters in strings and print backwards
I need to find out how many and which repeat characters are in a string (after you inform it). And also print this string backwards. I’m having great difficulties. Here is part of the code I’ve made…
-
1
votes1
answer154
viewsPrint the letters in front of the alphabet
The idea of the code was to enter a letter, for example 'a' and return a letter in front of the alphabet, in this case the letter 'b', but the program does not return anything and I can not find the…
-
1
votes1
answer248
viewsWhy do I get this error on locale. h? [Error] expected declaration specifiers or '...' before Numeric Constant
The error ( [Error] expected declaration specifiers or '...' before Numeric Constant ) is pointed out in the setlocale(LC_ALL, "English"); However, the locale. h library and comma are present and…
-
1
votes0
answers37
viewsExercicio de matriz da faculdade
Speak up, people. It’s my first post here so it’s bad if there’s a mistake. I started doing ADS facul a short time and with a lot of difficulty in a Matrix exercise in C language. The Exercise is as…
casked 4 years ago Eric De Souza Serra 11 -
1
votes1
answer50
viewsReading txt file for memory
I’m trying to read the file that contains only 3 elements. Username: User X Sex of user: Male or female User age: X age The code I have at the moment is as follows:: FILE* fp; char linha[500]; fp =…
-
1
votes1
answer821
viewsinvalid Digit "9" in octal Constant Arduino
I have a problem with my temperature measurement function. #include "max6675.h" int ktcSO = 8; int ktcCS = 9; int ktcCLK = 10; MAX6675 ktc(ktcCLK, ktcCS, ktcSO); void setup() { Serial.begin(9600);…
-
1
votes0
answers45
viewsVscode terminal with improper encoding
I’m using Visual Studio Code for my C classes, but I’m really bothering myself with the terminal. He’s using some encoding that doesn’t admit accents and it’s compromising the visualization of my…
-
1
votes1
answer665
viewsDifference in char* and const char* at the beginning of a function in C
const char* lerArquivo(FILE *file, int tam, char *path){ file = fopen(path, "r"); int cont; char *palavra; for(cont = 0; cont < tam; cont++){ fscanf(file, "%c", &palavra[cont]); palavra[cont…
-
1
votes0
answers36
viewsArray of pointers that point Functions
Good afternoon. I wonder if the code below is correct. I have a little bit of pointer difficulty and I entered this area of pointers to functions and I would like to understand more about this…
-
1
votes0
answers18
viewsHow do I do a C function that removes a character typed by the user from the phrase he typed? Unable to do the function
//Ex: if the user type 'hello world' and type 'o' then the program must return the Mund, removing the letter the user typed. #include <stdio.h> #include <string.h> int main(){ char…
casked 3 years, 11 months ago Emily Glory 19 -
1
votes0
answers34
viewsC Code Compilation Problem in VS Code
I did all the necessary steps to compile C in VS Code, from the necessary extensions to Mingw, system variables, I did everything right, but whenever I try to compile it happens: Could someone help…
-
1
votes1
answer62
viewsAssign string value with pre-defined size inside the pointer
You need help with dynamic memory, I can’t understand why I can’t access nome of ptr in the method adicionarSocio? How can I change this field? I have to do malloc of the name before assigning even…
-
1
votes1
answer186
viewsError showing results - URI 1566
I made as a request URI problem 1566, only it’s giving presentation error, and I don’t know how to fix. Just follow my code: #include <stdio.h> #include <stdlib.h> int ordena(const void…
casked 6 years, 9 months ago rafael marques 939 -
1
votes0
answers42
viewsString characters disappear
Good morning I’m doing the Problem 1234 from Uri, only that I made the code and saw that some characters disappear for some reason I don’t know, when I type a phrase that the site shows, some…
casked 6 years, 9 months ago rafael marques 939 -
1
votes1
answer49
viewsValgrind does not show which line the error occurred
I’m trying to use Valgrind for Linux in order to check for memory loss, however the error shown in the terminal does not show on which specific line it is. ==4873== Address 0x4a4e047 is 0 bytes…
-
1
votes1
answer54
viewsFunction does not respond correctly
Trying to calculate the volume of the sphere returns a strange number like -1.#QNAN0. #include<stdio.h> #include<stdlib.h> #include <math.h> float pi = 3.14; float param(int x){…
-
1
votes1
answer450
viewsSplit string with comma as delimiting in Arduino’s Serial.read()
I’m developing an application in C# with Visual Studio that sends a character to the Arduino only now I want to send a string with this structure character, number as in the example below: A,0 or…
-
1
votes3
answers737
viewsTemperature converter
When I type the temperature in Fahrenheint the program returns 0 as a result, where is the error? #include <cstdlib> #include <iostream> #include <conio.h> #include…
-
1
votes2
answers3307
viewsConcatenating two linked lists into C
I’m starting my studies on dynamic structures in C and I’m having trouble making a code to concatenate two lists. The paint part on the screen the contents of the lists is working, but when…
-
1
votes1
answer1916
viewsWarning: initialization makes integer from Pointer without a cast [-Wint-Conversion]
I have the following C code that connects to a mysql database and performs a query: #include <mysql.h> #include <stdio.h> int main(void){ MYSQL Connection; MYSQL_RES *res; MYSQL_ROW row;…
-
1
votes0
answers19
viewsHow can I change the version of C in Mingw?
I started studying C recently, and when trying to "dynamically" set the size of a Vector through a variable I get the following error: error: ISO C90 forbids variable length array 'vector' [-Wvla]…
casked 3 years, 9 months ago André Marks 11 -
1
votes1
answer167
viewsParallelizing n queens problem with Openmp
I’m having trouble parallelizing my C code with Openmp and getting good performance on the n queens problem. The results are always considerably slower with parallelization enabled and I do not know…
-
1
votes2
answers138
viewsAre variables declared within blocks or subprograms dynamically allocated?
I’m reading the book "Algorithms and Programming with Examples in Pascal and C" and in it there are two paragraphs that left me in doubt, are they: Two alternative forms are offered by some…
-
1
votes1
answer169
viewsDifferent behaviors between Linux and Windows using threads(pthreads)
I’m using the Linux pthreads library to try out the functionality of threads, the code below prints 5 messages on the screen for each thread, each thread waits its turn to display the message…
-
1
votes0
answers28
viewsC structure to be dynamically allocated
I’m needing it to be dynamically allocated but I’m not finding the problem. #include <stdio.h> #include <stdlib.h> #define tam 10 typedef struct pilha{ char dado[tam]; int pos; }Pilha;…
-
1
votes0
answers46
viewsGet the Start Address from a process thread and finish it individually
What I want to do is open up to check if a process is open, see the thread list, identify it by Start Address, and finish a process-specific thread. I can do it manually by the processhacker, but I…
-
1
votes1
answer45
viewsPerform music in the program in C 2
I got good lighting with that answer: Perform music in the program in C But when executed the command, it is not very interesting as the image below shows: (even using system(clear) does not solve)…
casked 3 years, 8 months ago user191477 -
1
votes0
answers108
viewsWhat is the difference between printf and fprintf in C?
My question is as simple as this: What is the difference between printf and fprintf in C? I saw answers for Java, but since I don’t know anything about Java I don’t know if it has to do with. For…
-
1
votes1
answer1212
viewsDynamic matrix as parameter in C or C++?
After hours of searching, I didn’t find anything that would answer my question, or I couldn’t understand the answer. I want to create a matrix NxN variable size. I made with pointers,but I want to…
-
1
votes0
answers241
views -
1
votes1
answer78
viewsHow to assign a treated value in the function to my vector?
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define TAM_Min 1 #define TAM_Max 500 /* Sintese Objetivo: Classificar animais de um zoologico…
-
1
votes1
answer68
viewsError in the conversion of numerical bases
Well I’m asking the question 1199 Conversion of Uri bases however in some cases my test passed, only when I put a number that the staff put in the forum gave error, the number was 0x80000000 the…
-
1
votes1
answer545
viewsHelp in C algorithmic activity
Can anyone tell what I’m doing wrong in my code? 1) Make a program that determines the chronologically larger date between two dates provided by the user. Each date shall be composed of three…
casked 6 years, 8 months ago Thiago Henrique Domingues 167 -
1
votes1
answer118
viewsPointer problem - remove element in a binary search tree
Having some problem passing the root pointer per parameter to the function remove_node. This function is iterative, it has only one recursive call in the latter case. Therefore, it is necessary to…
-
1
votes1
answer99
viewsMemory pointer and allocation
I know which pointer stores memory address. And a variable stores a value. But taking into account that I have a class class player {} and create a variable player p; and an instance of a pointer…
-
1
votes1
answer1407
viewsRemove the first element from a double chained list - C
I’m having trouble removing the first node from my double-stranded list. I created a function that returns the list type (Value) to perform the operation, by showing the list elements within the…
-
1
votes0
answers91
viewsWhat is the Bubble short error in this code?
I tried to solve this problem of URI Online Judge and I came to this code, and it works for test cases smaller than the problem, and I’ve already looked for the bug, only I can’t find it. Code:…
-
1
votes1
answer232
viewsSpecifying students height and sex with a "while"
The exercise asks me to read 20 students and their respective heights and gender, and then show the average height and how many men and women we have. What I did was this: int main() { float altura,…
-
1
votes1
answer924
viewsHow to print a list in C?
/* define a struct TAD lista */ struct lista { float info; /* dado */ struct lista *prox; /* ponteiro para o proximo elemento */ }; typedef struct lista Lista; I have the struct above and the…
-
1
votes1
answer180
viewsHow to pass a double pointer as argument and return it from C++ function
I have a function I need her to be void and that a Double Pole be returned from her by the argument. void cracking::decompose(char input[][100], int size_S, double* &Atm, int* &ID, int…
-
1
votes1
answer677
viewsCreate Chained Dynamic List
I am learning how to work with chained lists. In one of the videos classes I attended, the teacher suggests the following code: struct celula { int info; struct celula *prox; }; typedef celula Elem;…
-
1
votes2
answers17219
viewsFunction that returns vector
How to return a vector within a function? And how do I call it in main? This Return in the case: (vector Return;) #include <conio.h> #include <stdio.h> #include <stdlib.h> float UK…
-
1
votes1
answer174
viewsSubstitution in c
Write an algorithm that deciphers a given text based on frequency analysis of the Portuguese language. Example: The above example uses substitution key. The technique that should be used to decipher…
casked 6 years, 7 months ago Henrique M 87 -
1
votes1
answer40
viewsError counting repeated values in an array
I’m trying to ask a question that counts the number of times each value appears on the array, which I tried, only counts a repeated number, someone could help me with logic, Example of input 8 10 8…
-
1
votes0
answers436
viewsClion - Error executing or debugging code
EXPLANATION I am studying about dynamic memory allocation and have made a simple program to solve the following situation: The client wants to register a certain number of employees and, want to do…
casked 6 years, 7 months ago Eduardo Assis 11 -
1
votes0
answers39
viewsWhy isn’t the instruction being executed?
I am creating a program that sorts a Matrix of structures, first sorts the rows and goes to each row and organizes it by columns. In the matrix I am using after two cycles the value of (i+1 = 4),…
-
1
votes1
answer163
viewsI cannot make the "putchxy" function of <conio2.h> work
Hi. I started the computer science course this year and had never been able to study any programming until then, so maybe that’s why I’m having such basic mistakes. My problem right now is with the…
casked 6 years, 7 months ago LucasCardoso910 31