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
-
9
votes1
answer450
viewsWhat’s the comma for?
The comma is what? Just a language construct? An operator? Because it exists? This question is based on what was seen in How to return or extract more than one value from a function?. return base2,…
-
9
votes1
answer542
viewsWhy do we use parentheses in a pointer statement?
What is the difference between these two statements? int* array1[10]; int (*array2)[10]; Why are there parentheses in the second?
-
9
votes1
answer256
viewsWhat is an unrolling?
In this question I asked about optimization and performance that the compiler performs. Among the highlighted items, users commented that the compiler makes an optimization called loop unwinding or…
-
9
votes1
answer90
viewsWhy are there two const in the variable statement?
I can do it: const int* const objeto = &x; Why are there two const? What is the function of each?
-
9
votes2
answers11213
viewsIs it possible to create a C/C++ app for Android?
I want to create an application for Android using the C or C++ language. What are the advantages and disadvantages of this?
-
9
votes7
answers65838
viewsHow to run a C program in Visual Studio Code
I’m trying to run a code (program) in C in Visual Studio Code, but I can’t find the necessary settings. I installed the C/C++ extension (Microsoft) Project structure: .vscode - c_cpp_properties.json…
-
9
votes1
answer63630
viewsWhat is the function of getch(); and conio. h library?
What is the function for getch();? What’s the library for conio.h; what is the use? For example in a code like this: #include <stdio.h> #include <conio.h> int main() { printf("Hello…
casked 7 years ago Tiago Gonçalves 141 -
9
votes2
answers1582
viewsWhat is the difference in the syntax ptr = (int*) malloc (sizeof(int)) and ptr = malloc (sizeof(int))?
I have a question about dynamic allocation in C. At the time of allocating memory I have seen these two types of syntax: ptr = (int*) malloc (sizeof(int)); ptr = malloc (sizeof(int)); But I don’t…
-
9
votes2
answers562
viewsWhy assign NULL on a pointer after a free?
I see in many codes assign NULL on a pointer just after a free, guy: free(p); p = NULL; What good would that do?
-
9
votes2
answers1223
viewsWhy don’t you need the `&`in the `scanf();`?
I learned that the variable always has to have &, but in this example you don’t need and still show the result. Why you didn’t need the & in the scanf();? #include <stdio.h> int…
-
8
votes3
answers1531
viewsHow to identify heat regions in thermal images?
I’m developing a project where I need to process photos taken from a thermal camera. The idea is to try to identify fires in these images. I would like to know what techniques I can use for such a…
-
8
votes3
answers9428
viewsHow does serial communication work and how do I use C/C++?
I use the Debian 7.1 and need to make serial communication between a computer and a microcontroller using C/C++. I’ve done a lot of research on the subject, but the articles and examples I found are…
-
8
votes3
answers21946
viewsHow to exchange the value between two variables without using auxiliary variable?
I learned to code in C, but recently I have studied RUBY. Ruby allows us to exchange the value between two variables easily and without using an auxiliary variable, thus: a, b = b, a Without using…
-
8
votes1
answer702
viewsMeaning of (void *)
What is the meaning of calling a function with one that was int and is passed as (void *)? If variable was declared as int because it is passed as a parameter to a function *(void *)variavel* ?…
-
8
votes2
answers9026
viewsAlgorithm in C to convert Arabic number to Roman number
How to make this conversion? It doesn’t need to be the algorithm ready, wanted a help at least in logic.
-
8
votes3
answers2685
viewsAlgorithm C language - Multiplication
Translate to the language C: take a number on the keyboard and repeat the operation of multiplying it by three (printing the new value) until it is greater than 100. Ex.: if the user type 5, we…
-
8
votes1
answer7678
viewsHow to make a function within a function return a vector?
I have a job for my course, and it is necessary to make a program similar to the game of megasena. It’s almost done, but I’m finding a small problem and I need help. Job dice: maximum 10 players can…
-
8
votes5
answers7954
viewsRemoving the " n" from a string read using fgets()
Usually when using the fgets() function it reads the string but is sensitive to Enter, like reading the string to be adding to it the " n"??
-
8
votes1
answer410
viewsMatrix parameter passing error
I am trying to understand the function of pointers for an array. For this, I have elaborated the small program below. I made some mistake, because, in the indicated line, error is occurring…
-
8
votes1
answer5423
viewsHow do I program for Avrs in C/C++? And using Arduino?
I’d like to know: How to start microcontroller programming ATMEL AVR in C/C++? What software can I use to compile my program? What software can I use to upload my program? Where I find the official…
-
8
votes1
answer2785
viewsHow to run Assembly inline in a code with variables in C?
From an example book, I was able to run the following Assembly (AT&T) code with gas, which returns a message with the processor name: .section .data output: .asciz "The processor Vendor ID is…
-
8
votes1
answer574
viewsWhy does a char array support a character like ç and a char variable not?
Even though the char variable only supports ASCII characters, why in the following code it has the normal output when a value is inserted with characters that are not part of ASCII as accented…
-
8
votes2
answers1700
viewsSeparating integer by character
I have a vector of integers: int nums[10] = { 1234, 4761814, 9161451, 14357 }; I want to know how to separate these numbers, for example, the first element to turn an array like this: {1, 2, 3, 4}…
-
8
votes2
answers193
viewsHow does a variable point to a pointer?
Reading this answer on pointers and arrays in C, there is the example below where the variable ptr points to the first element of this array. int array[42] = {42}; int *ptr = a; How this pointer…
-
8
votes2
answers2568
viewsWhat is the purpose of the size_t and ssize_t commands in C?
What is the purpose of commands size_t and ssize_t? What kind of data they represent? size_t minhavariavel1; ssize_t minhavariavel2;
-
8
votes1
answer2417
viewsSimulate boolean type in C
What is the most appropriate way to simulate the type bool in C? My teacher did it in a very simple way. #define bool int But I also found an excellent answer here (follows a copy of the code). //…
-
8
votes1
answer460
viewsHow to allocate a member of a struct to C?
I wonder if it is possible to allocate a atributo of a struct, follows my struct example: struct MinhaStructExemplo { int * atributo_quantidade; /*Atributo que eu gostaria de alocar na memoria*/ };…
-
8
votes1
answer147
viewsGCC compiler command to display #ifdef
What compiler command do I use to display this line at runtime? #ifdef DEBUG double tInicio_=clock() ; #endif
-
8
votes1
answer1466
viewsDifference between GCC Clang
The systems based on Unix (a large majority), usually use the GCC, to compile the files in C, but I also possessed the Clang for the same purpose. There is difference when compiling some project…
-
8
votes3
answers747
viewsIs malloc typecast recommended?
I have read that it is not advisable to do the Typecast of malloc when we are allocating memory to a new pointer variable, and many websites and books teach this practice in memory allocation, it…
-
8
votes1
answer1772
views -
8
votes3
answers1883
viewsHow to Create and read ". conf" files in C, for linux environment?
I’m studying C in linux environment. I have a problem in how to create a configuration file for my program to know what to do when running. Question Does anyone know how to store and read variables…
-
8
votes2
answers1802
views -
8
votes2
answers271
views -
8
votes2
answers156
viewsHow to Ensure Writing File on a Single Disk Block?
Performing several searches in a few days I found nothing that guarantees that my file will be written in a single block of the disk (I know that block is only a metaphor for sectors of the disk…
-
8
votes3
answers3514
viewsHow to store any string in C?
How do I store a string (input) without knowing the size of this string, for example: #include<stdio.h> int main (){ char nome[]; /* a array não tem tamanho determinado porque o input ainda…
-
8
votes1
answer1179
views -
8
votes2
answers1159
viewsIs there a C interpreter?
Everyone knows that C is a compiled language. Some know that in theory any language can be interpreted, unless it has some specification that prevents it. Are there C interpreters? They’re good for…
-
8
votes1
answer635
viewsIs there a difference between a compiler and an interpreter?
What’s the big difference between a compiler and an interpreter? In languages like C, Java is used a compiler, for example in Javascript an interpreter is used, but I was confronted with the term…
-
8
votes1
answer80
viewsCan you initialize only a few members of a C array already in your definition?
I know you can do this: int a[5] = { 0, 3, 8, 0, 5 }; or int a[5]; a[1] = 3; a[2] = 8; a[4] = 5; Can you do the same in just one line, already in the definition? IE, you can initialize only a few…
-
8
votes3
answers1323
viewsWhy do pointers have a fixed size independent of the pointed type?
The space occupied by normal variables (int, float, double, char) obeys the type rule: int occupies 4 bytes, float occupies 4 bytes, double occupies 8 bytes etc. Why pointers of different types have…
casked 7 years, 4 months ago Natã Marques 81 -
8
votes1
answer67
views -
8
votes1
answer162
viewsWhat is the need to use the suffix "f" in a numerical constant in C?
It is necessary to add f at a value float within the parameters of a if? Example: if (a == 2.5f && a > 2.0f) {}…
-
8
votes1
answer280
views"#define" defines a global variable?
I’ve always used a few definebut now this doubt has arisen, when I use a #define am I creating a global variable? Is there any harm in this use? Example: make program to read 10 numbers: I put in…
casked 5 years, 11 months ago Vitor Gonçalves 552 -
8
votes2
answers118
viewsWhat’s the difference between executing code inside or outside the "for" keys?
In Javascript or C, there is some difference between using for in the normal way: for(var i = 0; i < 10; i++){ console.log(i); } or execute the codes within the parentheses? Example: for(var i =…
-
8
votes3
answers223
viewsHow to simplify a problem to get the names of the months of the year?
I am beginning to program in C and I realized this problem whose statement is the following: Write an exercise that asks the user for a one-month number and prints the name of the month on the…
-
8
votes1
answer140
viewsFunction to void pointer conversion*
Recently, I was trying to solve a problem in a program of mine in C and, by chance, I came across some answers from Stack Overflow in English which stated that converting a pointer to a function to…
-
8
votes2
answers105
viewsHow does an array of functions recognize the position of the next element?
Why do you ask: The question may seem strange, but is that I am a beginner in programming and at this moment I am studying pointers to function and in an example in the book by which study is…
-
8
votes2
answers332
viewsHow does the computer "know" the alphabetical order when comparing two chars?
I have a question about Caesar’s cipher program: #include<iostream> #include<string.h> using namespace std; int main() { cout<<"Enter the message:\n"; char msg[100];…
-
8
votes1
answer110
viewsWhy, in C, is a statically declared array name not an lvalue?
Why, in C, the name of a statically declared array is not a lvalue? A lvalue is an expression that can appear on the left side of an assignment statement. It is an expression that represents a…