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
-
5
votes3
answers167
viewsDoubt about C pointers
So guys, I got a question here. What does each of these statements mean below? *ponteiro = Valor do ponteiro ponteiro = (?) &ponteiro = Endereço de memória do ponteiro I would like someone to…
-
5
votes1
answer483
viewsHow to correctly divide a number to only one digit in C?
I have the following function : divisibilidade11(int num); And the following variables: : int dividendo; int divisor; When the user enters with the type 11 for the variable divisor the function…
-
5
votes3
answers104
viewsWhy do you use a vector with a name on it?
would like to know the function of using a name within a vector? char chave[NUM_LETRAS + 1]; int frequencias[NUM_LETRAS]; int frequencias2[NUM_LETRAS]; char codificado[MAX_STR]; char…
-
5
votes4
answers224
viewsCode Optimization / Image Processing
I’m doing a C-level college paper on image processing. And I need to find an alternative to optimize a particular piece of code. Here: /* Backward Rotina */ /*…
casked 7 years, 5 months ago AComerlatto 341 -
5
votes1
answer1457
viewsError while creating Makefile
When I am trying to use Makefile with the following content: all: teste teste: arp_discover.o arp_poisoning.o gcc -o teste arp_discover.o arp_poisoning.o arp_discover.o: arp_discover.c…
-
5
votes1
answer72
viewsAtomic Types in C language
What is the difference between primitive and atomic type ? What are atomic types for ? In which situations they are applied ?
-
5
votes1
answer616
views.txt with C password?
I’m dealing with file manipulation . txt and I wanted to know how to create a file . txt with a C password, so that this file cannot be opened by the notepad or other program without the password.…
-
5
votes1
answer732
viewsPointer pointer to change my battery. Why should I use them?
I am making a code that consists of analyzing an arithmetic expression, and checking if when I open a '(', then I must close a ')'. That is, check whether the expression is valid or not. For this I…
-
5
votes1
answer123
viewsWhy is it possible to store a string on a char pointer?
Why char stores a single character and the pointer points to its value in memory, so it shouldn’t have just one character? Example: char *str = "Ola"; Why str does not store only one character?…
-
5
votes2
answers71
viewsWhen to use these commands?
What are the criteria I use to apply the commands getch(); , the return0; and the system("pause") at the end of a programme?
casked 6 years ago Benedito Póvoa 57 -
5
votes3
answers300
viewsCode for reversing sequence of non-vowels ending with zero status
I’m implementing the function decodificar, which aims to call auxiliary functions to reverse all non-vowel sequences. For example, if the word is "cool monsters," it will go to "mortsnol segais".…
-
5
votes1
answer98
viewsCan Union and struct be considered operators?
One union or a struct can be considered operators? As well as return, goto and sizeof?…
-
5
votes2
answers90
viewsWhat are these complex members within a struct?
I have a question in a struct on the last lines with uchar and void which is quite different from what I know. Why many programmers use underline in the names of structs, variables etc... struct…
-
5
votes1
answer400
viewsTimer break - PIC18F4550
Hello, I am a student of the Technical course in Mechatronics. My teacher passed a project to show the speed of a reduced CC motor, in RPM, in the Hyper Terminal. He said we need to use the timer…
-
5
votes1
answer210
viewsWhat is the difference between %p and %d in C language?
Which means the memory address that appears with %p and the %d exactly? What’s the difference? int main() { int teste = 10; int *ptr = &teste; printf("%p\n%d",ptr, ptr); return 0; }…
-
5
votes5
answers391
viewsConcatenation in C
I’m doing a C algorithm to shut down some machines. This is my algorithm: #include <stdio.h> #include <stdlib.h> #include <conio.h> main() { char vetor[2][15] = {"192.168.2.200",…
-
5
votes2
answers140
viewsI cannot use the value passed in argv in the program call
When I type b in the call of the program he does not return me the Bom dia. I would like to understand what is wrong in my code. Follow the program below. #include <stdio.h> int main (int…
-
5
votes1
answer56
viewsCan LLVM be used with the C language?
I’m studying compilers and I’m using the C language and learning about LLVM but all examples are in C++ language. The question is whether I can use the LLVM with the C language and how can I start a…
-
5
votes1
answer209
viewsIf C/C++ are native languages then why do they need runtimes?
Usually the first thing that came to my mind when I heard the term native language, was a program that ran independent of operating system, communicating directly with hardware, I always developed…
-
5
votes1
answer219
viewsIs it incorrect (or problematic) to create a string array struct?
I’m not sure what’s the ideal way to create a structure (struct) that contains a array of string, in case I have a structure like this: #include <stdio.h> #include <stdlib.h> typedef…
-
5
votes1
answer70
viewsInversion of each line of a C file
I am trying to make a program that basically indents each line of a text file in reverse order, that is, the line is shown from the end to the beginning. For example, the line 'hello world! ' is…
-
5
votes1
answer1694
viewsTorque calculator in C
I have this function that converts decimal to binary, but then how do I sum the bits, or use the & (and), etc. ? Use the operator & do we have to count to 2 decimal places? Ex: 25 & 25…
-
5
votes1
answer2507
viewsFind and show the way - maze in C
Guys, someone can help me. I need to implement a recursive function that gets a maze and a current position. The labyrinth is given by an array of characters ("char") where ːX' represents a wall,…
-
5
votes1
answer105
viewsAverage is not calculated
I need to write a code that reads only 20 integer values, at the end add the positive numbers and average the negative numbers. It normally adds up the positives but when it arrives at the time of…
-
5
votes2
answers1821
viewsHow to implement a queue using two stacks
Hello, I need to implement a queue using two stacks, IE, I need to insert an integer on stack 1, and when removing an element all items on stack 1 should be transferred to stack 2, making it look…
-
5
votes1
answer1146
viewsDynamic stack - C
I’m studying dynamic stack from the code below: #include <stdio.h> #include <stdlib.h> #define tam 50 // ---- Estruturas para os tipos…
-
5
votes2
answers97
viewsWhy can’t I access the array of integers in the main() function?
I cannot access the positions of the vector of integers that I loaded in the function loads. In that function I can correctly access the data with: printf("%d\n", n[i]); But in function main(),…
-
5
votes3
answers97
viewsWhy does the first element of the vector come out as zero without having stored this value there?
Why the following code prints a 0 at the beginning of the output? #include <stdio.h> #include <limits.h> // Escreva um programa que leia do teclado 8 valores, e em seguida os // imprima…
-
5
votes0
answers422
viewsProtocol NBR 14522
I am developing software for communication with meter via serial port, and I am able to send the commands via serial, follow the codes: int serial_open(const char *device, int baud) { struct termios…
-
5
votes1
answer112
viewsProblems comparing two Ipv6 addresses
Lately I’ve been working on several "test codes" to exercise the "head", specifically codes involving the API of sockets of Unix. The most recent code I wrote was a simple server that receives a new…
-
5
votes3
answers1148
viewsDynamic allocation in C - allocating without knowing the total amount of elements
I have a question about the dynamic allocation in c, as to the use of the function malloc(). If we take, for example, a case of registration of a full name, as we have no way of knowing the amount…
-
5
votes1
answer239
viewsProblem with file reading . WAV
Hi, I’m trying to read a file. 5s wav filled with "silence" to test the code in C. I was able to read the header but while trying to extract the date field where it contains the content itself (…
-
5
votes3
answers182
views -
5
votes2
answers139
viewsSend message confirmation received UDP
Good afternoon, I have the code for Udplisten, which causes PC1 to send a message to PC3 via an interlocutor (PC2), however, after the message reaches PC3, it has to send to PC1 to confirm that it…
-
4
votes2
answers334
viewsLoop to perform calculation in C Pagerank
Using the starting notes 0.15 for all and then add note as explained in the article http://cmup.fc.up.pt/cmup/mecs/googlePR.pdf If we consider pages 1, 2 and 3 to be: 1: link1 2: link2 3: link3…
-
4
votes1
answer398
viewsWhat is the difference between these ways of indexing a pointer to an array of structs in c?
Is there any difference in the use of these 3 statements? void addCliente(struct cliente *dadosCliente){ dadosCliente[k].nome="oi"; (*(dadosCliente+k)).nome="oi"; (dadosCliente+k)->nome="oi"; }…
-
4
votes4
answers8769
viewsHow to calculate the product of the elements of an array in C
How do I multiply values of an integer vector by each other in C. I have values within an array for example [1,2,3,4], I want to multiply one by the other, resulting in 24.
casked 10 years, 9 months ago fabaoanalista 189 -
4
votes1
answer134
viewsHow to center one window on the other in GTK?
I have a main window and I want to display small text in a small window, open in the center of the main window. I still can’t get the small window to open in the center of the main. I tried to use…
-
4
votes2
answers5586
viewsHow to move, rotate or scale an Object on its local axis in Opengl?
Hello, I have a class HTransform which stores a matrix, position, orientation and scale of each object, this class is the base class of each Object or entity. I made one function to move the Object…
-
4
votes1
answer69
viewsHow is an integer pointer variable stored?
When we declare : int* x; How the compiler compiles this and how the computer (it would be better to say operating system because it manages memory) performs this ? I mean, the O.R. reserves a space…
casked 10 years, 2 months ago ViniciusArruda 549 -
4
votes4
answers15159
viewsC language - Prime numbers in vectors
I am solving exercises, in C language, on vectors. The exercise is as follows: Make a program that loads an array of 10 integers, show only the primes and their respective positions. Okay I solved…
-
4
votes2
answers3308
viewsProject C in Visual Studio
I’m learning C in college and will have to program in C. I tested with Visual Studio 2013 and 2019 Community Edition I can create projects in C++, but I couldn’t find anything like a "Visual C". Is…
-
4
votes1
answer329
viewsPointer of struct in C
What happens is this, within the function ins_ult() I can change the value of root->data, but outside the function the value remains NULL. I’m passing the parameter the wrong way or using the…
-
4
votes2
answers3962
viewsTaking System Time in C
I want to take the time of beginning and end of a for. Ex.: #include <stdio.h> #include <time.h> int main () { time_t rawtime; struct tm * timeinfo; int i, j; time ( &rawtime );…
-
4
votes1
answer1832
viewsHow to Make a Simple Assembly Assembler
I’m learning about processor architecture and I intend to assemble an Assembler. What is the procedure and steps for writing a program that transforms written code into machine code? The assembler…
-
4
votes3
answers269
viewsSolve logic error
I’m doing some college exercises, but I’m having a logic error in this exercise: #include <stdio.h> #include <stdlib.h> /*usuario entra com um numero, o programa devera imprimir o maior…
casked 9 years, 9 months ago Leonardo V. De Gasperin 713 -
4
votes1
answer69
viewsHow to see the value of a define or macro in gdb?
I have the following line of code: int a = MAX(b,c); How to verify macro definition MAX(b,c)? Sometimes, the same macro is defined in several different ways in a code (for example, depending on the…
-
4
votes1
answer1582
viewsWork with C interruptions by compiling for pc
While trying to answer a question from the site I started a dense survey of how to work with C interruptions. Interruptions for those who did not understand it works as follows: Tstou running my…
-
4
votes3
answers729
viewsPrint vector data in a struct
I want to do a birth-date registration system. The final question is: as I print the birthday: 1/12/1990, 12/2/1977, 13/09/1999 and 19/04/1987. Would be the examples of the printing of dates, but I…
-
4
votes2
answers236
viewsHow to receive an X number ranging from 0 to 10 100 in C?
I have a question that can have as input a number X that can be from 0 until 10 100. I am receiving the input values/number as char to make it easier. But you can’t create a static string/array of…