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
-
3
votes2
answers12386
viewsProblem to remove chained list element in C
My function is only removing the first element if I enter the name of that first element. I would like to know how I do for the function find the element and remove it. The insert function this…
-
3
votes1
answer294
viewsC socket for Linux (how to pass a struct?)
I have a client/server application and need to transfer a struct to the server, but this way is not working: typedef struct{ int pontos; int vidas; int flagReiniciar; int flagAcabar; int…
-
3
votes1
answer5699
viewsProblem compiling: no input files Compilation terminated
I’m starting to program in C, but ai to use GCC ta giving me the following problem when using cmd: gcc.exe: fatal error: no imput files Compilation terminated I would like to know what to do,…
-
3
votes1
answer123
viewsMethod Call with Matrix Parameters
I’ve always created vector methods using: void exemplo(int vetor[], int qtd){ // Código... // ... } And I never had problems, but I’m trying the same with matrices and I get an error void…
-
3
votes1
answer96
viewsProblem in phrase search function
I’m not figuring out the problem that’s in my job, she does the following: I get a char vector with the '\n' in the end. Then I run the vector by checking: If you find in the vector the exclamation…
casked 9 years, 5 months ago Gabriel Vinicius 95 -
3
votes3
answers3929
viewsLimit the size of a String?
I declared char pl1[10], pl2[10]; And I did this: printf("Nome do Player1: "); scanf("%10s", &pl1); printf("Nome do Player2: "); scanf("%10s", &pl2); Thinking he was only going to read the…
-
3
votes1
answer119
viewsI’m in doubt how to do
How to module into some mathematical function in C? I tried some basic things but it didn’t work.
-
3
votes2
answers1190
viewsHow to perform an algebraic expression on a string in C
My program has the following objective:: Given a function, my program replaces the function'X(s)' by any number. The code below exemplifies what was said. //funcao a ser trabalhada char funcao[150]…
-
3
votes2
answers128
viewsUse of conditions in matrices
I need to do a program that reads a 4X4 matrix and then sums the values in each row and then for each column. I’m not sure how to define my condition. #include <stdio.h> int main() { int…
-
3
votes1
answer149
viewsIncrease the reliability of random numbers
I have a function that generates pseudo-random numbers with rand who has a Seed which is a publicly known time. Change the Seed is not an option. The application needs a more accurate degree of…
-
3
votes2
answers290
viewsHow to convert string array to string?
In a program for Arduino, I have an array of strings but it seems that the function where I will use this data only accepts string. How do I convert an array to a string ? File prog =…
-
3
votes1
answer86
viewsLoading multiple libraries with loadlibrary
I have two libraries, sph.dll and mydll.dll, and I try to load them using Loadlibrary as shown below: HMODULE hlib = LoadLibrary("mydll.dll"); if(!hlib){ printf("error"); MessageBox(NULL, "Erro…
-
3
votes3
answers272
viewsProblems with "strcpy" locking program
I’m solving an exercise where I have to fill a vector like struct, and one of the values is char, for that I made a while and was using a simple assignment with "=" but it wasn’t working, so I did…
-
3
votes2
answers107
viewsHow to fix multiple errors in this code?
I’m making a code that needs to contain 3 vectors (number one. enrollment, grade 1 and grade 2), relative to 6 students, which needs to be included: the final grade of each student; class average; o…
-
3
votes1
answer9288
viewsStore data in STRUCT and print data on screen - 3 people
Can anyone tell me what I’m doing wrong? I need to store the data of 3 people on struct and then print. This error is appearing: request for Member ːname' in Something not a Structure or Union|…
-
3
votes1
answer191
viewsHow to get really random numbers with 'Rand()' in C?
For a schoolwork, I need to create a game, for which I need to generate a random number to make it fair. In one case, as I will post below, I need to assign a random number between 0 and 2 to modify…
-
3
votes2
answers1697
viewsRemove element from a chained list
I am implementing a chained list of type "with head". It follows struct referring to the list and its creation in main() struct lista{ int info; struct lista *prox; }; typedef struct lista Lista;…
-
3
votes0
answers2146
viewsC Client server application for file transfer with TCP socket and thread
I would ask for help from the forum to make secure (encrypt) the transfer of a file between two computers. Below follows the C source code of a client-server application for file transfer using…
-
3
votes1
answer128
viewsWhy can’t I modify the string this way?
When we have a declared int variable, and then a pointer to that variable: int x = 10; int *p = &x; To modify the variable x through the pointer, we have to do: *p = 20; But when I declare: char…
-
3
votes1
answer8777
viewsHow to connect one struct to the other?
I started in C programming recently and I have a question about structs, I wonder if it is possible to connect two structs to simulate a relationship between tables, for example struct categoria:…
-
3
votes1
answer877
viewsProblem creating C search function
The search function takes the address of the first element of a list (p) and a string (subname). Suppose subname Francisco of the person’s name matheus francisco will return it to me instead of…
casked 9 years, 2 months ago Matheus Francisco 650 -
3
votes1
answer1858
viewsIn C/C++, what are the build directives for? When should I use them?
I came across a C code that used a compilation directive on #ifdef and I didn’t really understand what it was for. I found an explanation, but it wasn’t clear. Here is an example of a directive and…
-
3
votes2
answers597
views -
3
votes1
answer235
viewsHow to access hardware on Linux in C?
I am aware of the existence of the Microsoft Win32 API, which allows the programmer to manipulate low-level resources such as serial ports, memories, CPU, GPU, etc. However I work with Linux…
-
3
votes3
answers492
viewsUsing an operator on a switch case
If I do, good wheel: #include <stdio.h> int op1; int main(){ scanf("%d", &op1); switch(op1) { case 1: puts("Hello World"); } } I wanted to make that by introducing a special character, for…
-
3
votes1
answer66
viewsAssign/Print values to void * in a structure
#include <stdio.h> typedef struct elem{ void * d; }Elem; main(){ Elem *p; Elem e; double pi = 3.14; e.d = π p->d = π printf("%f\n",p->d); printf("%f\n",e.d); } When I do…
-
3
votes1
answer107
views -
3
votes0
answers79
viewsPointer to function
I would like to ask a question that is best left with an example: I have the following piece of code in C: char texto[]="String"; int (*ret)() = (int(*)())texto; In this section above, I saw that a…
-
3
votes4
answers385
viewsObtaining the Rest of a Floating Point
I have a doubt about that. Let’s say I have a floating point, with the value 1.13 ( Minutes.Seconds ) How do I get the rest ( 13 ) from the floating point? Minutes . Seconds ( Rest ) 1 . 13 How do I…
-
3
votes1
answer116
viewsError "Java" and "C" integration through JNI
Personal I am not managing to consume functions of a lib in "C" using Java with JNI. Follow my artifacts and the error generated. Class CalculadoraJNI: public class CalculadoraJNI { // Declaração do…
-
3
votes2
answers65
viewsIncremental result?
I have a doubt about this expression: y-=++x I can divide this expression in two? x= x+1 and then?
-
3
votes3
answers272
viewsUse of increments in C
What is the difference in the use of increments in C language, considering an integer N? N++ ++N N-- --N
-
3
votes1
answer109
viewsMemory allocation and wiping in C - how much should I worry about?
I’m learning C from the book "Use Your Head! C" (damn me). Given a lesson, I need to create a struct calling for "island" with the following code: typedef struct island { const char *name; const…
-
3
votes3
answers41
viewsPointed from Pointed C
I have a doubt about this : **ptr I can understand everyone else (ptr++, &ptr, *ptr) I don’t know the best way to understand how it works **ptr (Pointed.) Thanks to those who can clarify me is…
casked 8 years, 8 months ago ChrisAdler 1 -
3
votes1
answer265
viewsHow to solve the recurrence function T(n)=2T (n 1/2) + logn ? Cormen Book Exercise cap 4
In Cormen’s book, Cap 4 details how to solve recurring functions (Cap 4). One of the exercises asks to solve. I tried using the tree and to induce but I could not go forward. How to reduce the…
-
3
votes1
answer546
viewsQuestions about Recursion in the Mergesort function [C]
I have a question about recursiveness. Actually, I’m not understanding how it works. Come on! I have the following function: void MergeSort (int *V, int inicio, int fim) { int meio; if (inicio <…
-
3
votes1
answer762
viewsChained list - sort by selection
I am playing a sorting algorithm by selection using chained list. I’m using two loops using a min cell, i and j, with respect to cell j, ok, but at the time of changing the min pointers and i is not…
-
3
votes3
answers1007
viewsParity test in C
I’m having trouble creating a function that returns 0 if the number of bits set in an unsigned char is even and 1 if it is odd
-
3
votes1
answer12863
viewsReturn to code start after a C if or switch case
I have a question regarding if. I’m developing a program for the end of college semester and every time I need to use one if and at the end of if, I need you to go back to the beginning of the…
-
3
votes1
answer960
viewsHow to separate global functions/variables from the program into files?
I have some files: vetores.c // função main uniao.c // função para unir vetores ordena.c // função para ordenar vetores globais.c // arquivo com variáveis globais I want to know how I reference one…
-
3
votes2
answers190
viewssimpels problem with Vector and Structs
Hi, I’d like to know why you’re not going, I’ve searched a lot of places but I can’t find in C #include <stdio.h> typedef struct ficha_pessoal{ int idade; char sexo; int CPF [11]; int CPFc…
-
3
votes1
answer169
viewsIndirect sorting using index vector
Hello, I’m having trouble solving my workout and would like a help. I thought to do with max heap but it didn’t work out. That is the statement: "Indirect sorting problem". ) Write an algorithm that…
casked 8 years, 11 months ago Matheus Francisco 650 -
3
votes1
answer139
viewsIs there a problem with pointers in this struct that works with chained lists?
Hello. I’m developing a game with C++ language and I think I’m making a mistake in using chained lists. I think I know that there are more interesting features than using chained lists in C++, but…
-
3
votes1
answer268
viewsSimplify code
I did a program, based on a study I read. The study says it takes 10,000 hours to become genius/master in any area. Can you simplify what I did? In the menu I could only do so, if you give me…
-
3
votes2
answers481
viewsDoubt of C++ loop do-while
Good people, I have the following question: Every time I run that program the do-while loop doesn’t stop at the second loop scanf in the program and ends up running twice and displaying the error…
-
3
votes1
answer118
viewsA variable without assigning value accesses the variable value in another function
I have a Programming Language activity to do, whose code is done in the C language, and in this question, the question is: What will be the return of this code and why? I didn’t understand why one…
-
3
votes2
answers1740
viewsQuery methods, classes and attributes in the C language
I wondered if in the C language and possible query libraries available their modules classes and attributes as in the Python language that exist the methods dir() and help() i am starting to learn C…
-
3
votes4
answers934
viewsHow can I decrease program processing time?
I need to show this exit: 1 2 3 PMU 5 6 7 PMU 9 10 11 PMU 13 14 15 PMU 17 18 19 PMU 21 22 23 PMU 25 26 27 PMU #include<stdio.h> #include<stdlib.h> #include<math.h>…
-
3
votes2
answers2039
viewsFunction to draw a rectangle in the Console in C
I’m trying to create a function called criar_botao() that prints a rectangle on the screen, with the library windows.h is printing the rectangle but not the size I want. I’m trying to pass the…
-
3
votes1
answer400
viewsHow to convert Ansistring to Char in C++ Builder?
I need to pick a file txt through the OpenDialog, to open through fopen. The problem I’m found is in the conversion. The function fopen has as a parameter a const char, already opendialog returns…