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
-
7
votes1
answer3034
viewsHow to email in C?
I searched several sites and google, but there’s always something with PHP or HTML. How to send an email using only C?
-
7
votes4
answers1099
viewsWhen to implement header functions?
I usually divide the program into small modules, each with its own header and implementation. In general, the abstraction level used allows the implementation to be completely changed without…
-
7
votes2
answers3467
viewsHow to add two arrays of integers with pointer arithmetic?
I am doing an exercise where I pass by parameter two integer arrays already defined by the user. I need now, in a third array, to store the sum of the two received arrays, at the same positions,…
-
7
votes3
answers5189
viewsHow to convert a string to const char *?
I’m trying to make an audio player (an mp3 player) using the library SDL_mixer. The problem is that I have a function that returns a string (a music directory) that I need to pass this string as an…
-
7
votes2
answers315
viewsWhy are you giving Segmentation fault in my Assembly inline?
I’m trying to call the job execve("bin/sh"...) using Assembly, but in instruction: mov %rsi,0x8(%rsi) i carry a segmentation error. This is the 64bit version of the article code "Smash the stack for…
-
7
votes1
answer898
viewsWhat is the difference between puts() and fputs()?
I know both functions are for display strings on screen. But what’s the difference between them? Which one is better to use?
-
7
votes1
answer16087
viewsHow to return vector size with sizeof()?
This is the code I’m using, but the return of the tamVet function is not the vector size, but the pointer size on itself. #include <stdio.h> int tamVet(int *vet){ int tam; tam = sizeof(vet) /…
-
7
votes4
answers9003
viewsInvert a 3-digit number in C
I need to make a program that the user type a three digit number and the program reverses that number for example 123 -> 321, I’d like to know the logic to do that, because I can’t think of…
-
7
votes3
answers2508
viewsHow to work with OCR to recognize photographs
I am currently working on my Course Completion Work and the theme involves OCR. I did some research and found the Tesseract, I also found libraries in Nuget for him (I’m using C#). The problem is…
-
7
votes1
answer767
viewsChange of char variable content
I’m having trouble working with files and handling char. CODE char *fileTipoDespesaDefault; char *fileTipoPagamentoDefault; FILE *fileTipoDespesa; FILE *fileTipoPagamento; /** * tipos : 1 =>…
-
7
votes2
answers1444
viewsHow to organize code without losing performance?
Using functions instead of putting code directly influences a program’s performance ? For example: void minhafuncao(){ printf("Funcao"); } main(){ minhafuncao(); } in place of main(){…
-
7
votes3
answers1181
viewsPassing vector to functions
How do I pass a vector to a function? Something that, on the Moon, would be like this: vector = {"V", "e", "t", "o", "r"} function getVector(vector, pos) return vector[pos] end…
-
7
votes1
answer2796
viewsWhat are Macros and how to use them?
So far during my C programming course, the only contact I had with macros came from standard libraries and not really knowing what was going on when calling these macros. I would like to know…
-
7
votes2
answers111
viewsAccess to specific memory points
How do I access an exact address in memory on Windows? unsigned char * mem = {??};
-
7
votes1
answer598
viewsIs it correct to return a memory address in function?
I was asked to design a function that was called, open a file. txt and return the pointer of this file, ie return a memory address. However as I know memory is only temporarily allocated for…
-
7
votes4
answers658
viewsHow to test the condition on a vector?
I have to make a program that reads a text, where each first letter of each word in the text is replaced by a character (*). I cannot compile correctly, I believe the problem is in my condition…
-
7
votes1
answer702
viewsUse a void function as a parameter of another
Let’s assume that I need one function to perform to a certain point, call another, do some action, call another function, do one more action and finish executing. Whereas the called functions…
-
7
votes2
answers1118
viewsTesting primes in C
I am trying to develop in C a program in which the user puts a sequence of numbers and the same should determine whether the numbers are primes or not. Just follow my code: #include <stdio.h>…
-
7
votes1
answer2455
viewsWhat is the correct way to declare a main() function?
In some of the research I’ve done, I’ve noticed that there are some different ways to do it, like the examples below: int main() int main(void) void main() // entre outros... I know that statements…
-
7
votes2
answers12821
viewsWhat it means *(int *)
I’m reading a code that has things like. *(int *)ptrArray = intN; *(float *)ptrArray= floatN; It is clear that different types are being assigned to the same type vector void*. The question is, what…
-
7
votes3
answers1492
viewsWhile repeating structure to recalculate in C
I solved this exercise below and thought about putting a structure while repeat, for the person to calculate again. But when I put’s' to return and calculate again, the exercise sums up the values…
-
7
votes2
answers330
viewsDynamic allocation and runtime of functions
When we use any of the dynamic allocation functions in C (malloc, calloc, realloc, etc.), within a function that is called by main, will the memory remain allocated at the end of the execution of…
-
7
votes3
answers972
views -
7
votes1
answer521
viewsWhat are the advantages of using directives and macros?
Directives and macros influence program performance?
-
7
votes2
answers1045
viewsInsertion Sorting and Recursive Insertion
I would like to change the function to a recursive function, I’m error tried so 1 se n > 1 então 2 Inserção-Rec (A, n−1) 3 x ← A[n] 4 i ← n−1 5 enquanto i > 0 e A[i] > x faça 6 A[i+1] ←…
casked 9 years ago Matheus Francisco 650 -
7
votes1
answer1284
viewsCin vs scanf, which is faster?
In competitive programming it is common for several programmers to use scanf() and printf() in C++ code instead of using cin and cout. And I’ve even seen problems that result in a Time Limit…
-
7
votes1
answer3570
viewsWhat is the purpose of using inline functions in the C language?
I would like to know what is the purpose of functions inline in the language C? Is there any difference in performance or other characteristics that should be taken into account in comparison to…
-
7
votes1
answer1322
viewsRemoval of random numbers in AVL tree
I have to implement an avl that gets 10,000 random numbers from 1 to 1000,000, right after that, I have to remove 1,000 random numbers, both taken from files. txt, I can enter normally, but when it…
-
7
votes2
answers616
viewsHow do I make my C++ programs multi-architecture (32 and 64 bit)?
Developing a native C++ application using Devcpp and the Mingw compiler, when running the application on another machine I noticed an error regarding the architecture, because my program only runs…
-
7
votes2
answers2251
viewsSizeof() or strlen()?
sizeof() or strlen()? What’s the difference in their use on char hands? which is more appropriate?
-
7
votes1
answer566
viewsDynamic Memory Allocation X vector
I was studying this subject in C, and in most of the places I look for, one of the examples of using this resource is when you’re going to create a vector whose size you don’t know. Example: int…
-
7
votes1
answer219
viewsStart structure pointer with an address?
I wonder if it is possible to start this structure type pointer with an address, without needing to point to another variable, or allocate memory. typedef struct{ char nome[20]; int idade; }pessoa;…
-
7
votes3
answers23806
viewsSize of a String
A char in the C language occupies 1 byte in memory. Ex: char ch;//a variável ch esta ocupando 1 byte na memória And a vector of char best known for string, its size in bytes will be counted…
-
7
votes2
answers174
viewsDoubt in recursive function
When I put: return n * fatqua(n-1) the program returns the expected result that is 24. But when I put: return n * fatqua(--1) the result of the program is 0. I’m not getting the logic of this…
-
7
votes1
answer131
viewsHow to dynamically insert into an Std::array?
I’m migrating from C to C++ language, and I want to stop using traditional C language means, like the C vector. It is possible using the std::array insert elements dynamically as in std::vector?…
-
7
votes2
answers225
viewsProblems with sizeof
I’m trying to get back the size of array, but it’s making a mistake. What to do? #include <stdio.h> char *palavra[] = {"casa", "carro"}; int main(){ int i; for(i = 0;i <…
-
7
votes2
answers362
viewsHow to pass an array as argument of a function per copy?
Like we know a array is used as a pointer in various situations. A parameter that waits for a array is actually a pointer, so what you copy is the memory address and not the data from array, is a…
-
7
votes1
answer355
viewsHamiltonian cycle taking too long
I have to find out if there is Hamiltonian cycle in a giant graph (1000 vertices in the smallest instance and 5000 vertices in the largest). My initial idea was to backtrack, and in small instances,…
-
7
votes2
answers1882
viewsHow to convert a text to number?
How should I convert a text that I know is an entire number coming externally? It would be something like a ToInt() or something like that.
-
7
votes2
answers10403
viewsHow to separate a string into pieces?
In other languages there is split, explode or something like that string in pieces according to some separator. There is something ready in C or I have to do in hand?…
-
7
votes1
answer3111
viewsWhat good is an Inker?
Some languages use a Linker or likeditor as it is also called. What is its function and its relation to the compiler? Why some languages do not have a Linker?…
-
7
votes2
answers157
viewsWhat does the expression "a+t" mean in the second parameter of fopen in C?
I was coming across a code here and I was curious about this excerpt: FILE *fp = fopen("Agenda.txt","a+t"); What’s the point of "a+t"?
-
7
votes1
answer275
viewsWhat is the purpose of while(*variable) and if(!*variable) in the statements "while" and "if"?
In Code Review there is a implementation of a simply chained list that I am using. However, in the reply of one of the users, he made some modifications to the list, and had a particular…
-
7
votes1
answer7242
viewsString matrix
How a matrix of strings? I tried it in several ways and still did not succeed, I thought it would work but it did not work. #include <stdio.h> #include <stdlib.h> int main(void){ char…
-
7
votes2
answers1249
viewsReturning function string directly and with array
What works: void *teste(); int main () { printf("\nRESULTADO: %s\n", teste()); return 0; } void *teste(){ return "Ponteiro"; } What goes wrong: void *teste(); int main () { printf("\nRESULTADO:…
-
7
votes1
answer5112
viewsHow to detect what are the common points between two circles?
I need assistance for the following program: Receive from the keyboard the equations of two circles: c1= X^2+y^2+ax+by+c=0 c2= X^2+y^2+a2=x+by+c=0 and show if the circles have points in common,…
-
7
votes3
answers145
viewsHow to embed one library into the other?
I have created a C++ game development library. Only my library needs another to display the images on the screen, the SDL2. So every time someone wants to use my library, they would have to link to…
-
7
votes3
answers4835
viewsIt is possible to concatenate numbers of type int
For example 10 and 12, concatenated would be 1012, this without being string, it would have to be the whole kind, you can do it?
-
7
votes4
answers4690
viewsCaesar cipher - problem with letters and spaces
I’m doing an exercise on the figure of the table below: #include <stdio.h> #include <string.h> main(){ char frase[200]; printf("String: "); gets(frase); for(int i=0; i <…
-
7
votes2
answers3921
viewsputs() and printf(), when and which to use?
Data input requests are usually preceded by text indicative of what you wish to receive and usually do not have data to be formatted. If variable data are not being presented in the request text,…