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
votes1
answer365
viewsHow to store vector values?
I’m a beginner in C and I’m 2 days into this exercise, I was able to do it so that if you increase the vector with the function realloc, it will increase everything right, but I need him to keep the…
-
3
votes2
answers2791
viewsHow to turn a character into an integer in C?
How to turn a character into an integer? #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char N[11]; int i; scanf("%s",N); int cont = strlen(N);…
-
3
votes1
answer255
viewsAllocation of operation in C
I don’t understand why in doing this operation, even though I’ve already declared r as float, if you do not place the cast whether to assign a int. #include <stdio.h> void main() { float r; r…
-
3
votes1
answer813
viewsHow does the "pop() " function work on a stack?
I’d like to understand how the pop in batteries. I just put the part that I don’t understand, I know that in function pop() there is also the empty check, but I only put the part I did not…
-
3
votes2
answers259
viewsOptimization of multiple ifs into something more practical
I have a string alphabetical: char string[] = "aouihuiahsudasduihqmdoiqjnduiamsdoqnwuidamodkjwodkaposdj"; I want to go through it all and for every character of it, say how many times it repeats in…
-
3
votes1
answer135
viewsUse of typedef for pointer
If I’ve already set a pointer to my structure why can’t I make the allocation of it. #include <stdio.h> #include <stdlib.h> struct ponto { int a, b; }; typedef struct ponto *Ponteiro; //…
-
3
votes2
answers2069
viewsDisplay the highest and lowest value between two integers when they are different from each other
I am not able to display the values of smaller and larger. Make an algorithm that reads two numbers and indicates whether they are equal or, if different, shows the largest and smallest in this…
-
3
votes1
answer59
viewsHow to interpret this line? (struct list*)0)
while (variavel != (struct lista*)0) { ... } How to interpret (struct lista*)0)? What does that mean?
-
3
votes1
answer569
viewsUninitialized variable used in this function?
After compiling the program, you receive 2 warnings of the same type: "Warning: 'phrase' is used uninitialized in this Function" and "Warning: 'word' is used uninitialized in this Function"…
-
3
votes1
answer403
viewsHow to get the same strcpy() result with strcpy_s()?
I downloaded a C++ code from the internet and when I open the solution, the following error: Error C4996 'strcpy': This Function or variable may be unsafe. Consider using strcpy_s Instead. To…
-
3
votes3
answers4140
viewsFunction that calculates the factorial of a number
int fatorial(int n, int f){ int resultado; while(n>1){ f=1; resultado=(n*f); f=f-1; } return (resultado); } int main(void){ int resultado; int n; int f; printf("Digite o numero a ser…
-
3
votes1
answer47
viewsCross-Reference with pointer array
I’m creating a cross Reset of a pointer vector that calls a simple chained list. Goal is to type a sentence and decompose your words, placing them in each vector position according to their…
-
3
votes2
answers144
viewsRecursive printing in triangle format
I have to read an integer value and pass it as a parameter to a function. It should display the number using the sample format. Ex: if the number given was 3, show: 1 1 2 1 2 3 I can show the format…
-
3
votes1
answer3131
views -
3
votes1
answer81
viewstype of incompatible pointer
Hello, programming/studying the language, C, I came across the following error warning: initialization from incompatible pointer type [-Wincompatible-pointer-types] int *ponteiro = &x; Being the…
-
3
votes1
answer60
viewsIn a chained list structure, why is a pointer to the node pointer used?
When reading my teacher’s slides I was left with a question regarding this structure: struct node { char item; struct node *next; }; typedef struct node Node; typedef node *Lista; It wasn’t clear to…
-
3
votes2
answers63
viewsRandom numbers appear later in sorting algorithm
At the end of my program the result is giving random numbers, which occurs? main(){ int i; int a[10]; int x; int aux; for (i=0; i<10; i++){ printf ("Entre com os numeros %i: ", i); scanf ("%i",…
-
3
votes2
answers1022
viewsError: incompatible type for argument 1 of 'printf'
I have this activity, exercise, where is to display the largest number, but is giving the error: "incompatible type for argument 1 of 'printf' " On the command line "printf (valor2);". Code:…
-
3
votes0
answers848
viewsCalculate the shortest possible distance
In an exercise, I need to print all possible paths between cities, and cities are represented by coordinates x and y and that the last city is the city of departure. Remembering that should be found…
-
3
votes1
answer531
viewsCycles in graphs
I am creating an algorithm that identifies whether a graph contains cycles excluded from the sources recursively, returning the graph for later verification of the edge quantity, so create the…
-
3
votes2
answers565
viewsImproper Infinite Loop no while
I made a program to calculate within a sequence the sum of the positive numbers and the sum of the negative numbers. When I use the command while, the idea is that it is within a sequence of 7…
-
3
votes2
answers447
viewsLimit, or capacity of a Vector
Imagine you ask "when the capacity reaches the limit you should warn the user" I have an integer vector with 15 positions, and the user will enter values inside, the goal is to warn when to reach…
-
3
votes0
answers203
viewsCannot find -lalleg (DEV C++ and Allegro)
People every time I try to run this code is giving this error follows the code below: #include <allegro.h> int main() { allegro_init(); install_keyboard(); set_color_depth(32);…
-
3
votes2
answers984
viewsSimulate keyboard typing programmatically in c
The problem: I need my C program to write like a keyboard. When I open google, for example, and click on the search field I would like to keep showing several 'a'. As if the key was pressed on the…
-
3
votes1
answer149
viewsWhat is the difference between memmove and memcpy?
What is the difference between the function memmove() and memcpy()?
-
3
votes1
answer50
viewsCode doesn’t do multiplication. What am I doing wrong?
I’m trying to do the multiplication, but it just doesn’t show up the result of the calculation, which is wrong? #include <stdio.h> #include <stdlib.h> #include <string.h> void…
casked 7 years ago Clarissa Galvao 43 -
3
votes3
answers607
viewsDeclaring a string in C
When setting the size of a string and not using all the space in the reserved memory, after the 0 the rest will be released? char nome[40] = "carlos"; In the above example I declare a string with…
-
3
votes3
answers69
viewsProgram does not meet expected flow by reading and printing input
#include <stdio.h> #include <stdlib.h> int main() { int num1, num2, num3; printf("Digite o numero A e numero B para saber o resto da divisao resultante da divisao entre eles:\n");…
-
3
votes1
answer98
viewsHow does malloc() organize memory?
When I allocate memory with malloc(), address equals an array? Or are spread across the PC memory? I want to create a list of structs, to do this, I have to have several structs in case, I can do…
-
3
votes1
answer48
viewsProblems with recursion in c
I’m trying to learn recursion and I’m doubtful on a question I was doing in c, I need to add up how many numbers of a vector with n elements are larger than a number x. This recursion just doesn’t…
-
3
votes1
answer67
viewsWhat kind of data entry is this? scanf("%m[ ]
I found this in a C program: int k; char* nometreino; char* nometeste; FILE* arquitreino; FILE* arquiteste; scanf("%m[^ ] %m[^ ] %d", &nometreino, &nometeste, &k); arquitreino =…
-
3
votes2
answers767
viewsCompare String Elements in C
I would like to separate a word and compare each element of the string with a letter, I tried to make this comparison using the strcmp() but when executed seems to ignore it, or does not perform.…
-
3
votes2
answers594
viewsInterest calculation
[Engelbrecht et al., 2012] Develop a program that receives from the user, the value of an application and the value of the initial interest rate. Whereas this interest rate increases 0.025% per…
-
3
votes1
answer568
viewsHow to create binary tree with iterative algorithm?
I’m making a program that allocates a dictionary in memory to check for misspelled words in text files. The function below converts dictionary words into integers and stores them in tree structures.…
-
3
votes1
answer113
viewsPointer is lost at function output
I have the following function typedef struct userDataStruct { char name [MAX_NAME_LENGTH+1]; struct userDataStruct *next; } userDataType; errorType GetUsers (userDataType **list) { FILE *file; char…
casked 6 years, 11 months ago Gabriel Távora 55 -
3
votes1
answer52
viewsWhat does this point in the structure code mean?
int main(){ char buff[129]; WSADATA wsa; WSAStartup(MAKEWORD(2, 0), &wsa); struct sockaddr_in caddr; struct sockaddr_in saddr = { .sin_family = AF_INET, …
-
3
votes2
answers69
viewsFor loop build error
I’m making a program that asks how many notes the user will type and after that, enters a 'for' loop asking what are the notes to type. Notes are stored in a array and finally the average. #include…
-
3
votes1
answer786
viewsHow to trade two non-consecutive knots on a doubly chained list?
I needed to switch two consecutive knots or not on a doubly linked list, but I can’t. Can someone help me? I’ve even done it on paper but it doesn’t perform. What’s wrong with the code? void…
casked 6 years, 11 months ago Sergio Souza Novak 513 -
3
votes1
answer239
viewsHow to create structure vector within function
Good morning! I got recovery again in the matter of algorithms, what got me most was structure and passing parameters. I decided to create an activity to train for recovery Monday. Following the…
-
3
votes2
answers54
viewsWhat does the # operator do before a parameter in the definition of a macro?
One of the possible macro definitions assert(), as I found in Mingw’s code,. #define assert(_Expression) \ (void) \ ((!!(_Expression)) || \ (_assert(#_Expression,__FILE__,__LINE__),0)) I don’t…
-
3
votes1
answer463
viewsWhat is object code?
What is object code? What is object code for? What is the process of translating object code into machine code called? I’ve seen talk until the language C uses Assembly as object code, is that…
-
3
votes1
answer307
viewsWhat is the difference between object code and intermediate code?
In this question a user answered that the object code is different from intermediate code. Since most courses say that the object code is in the middle of the process, then we could not call it…
-
3
votes2
answers242
viewsDifferent views of the same variable in C Language
I wrote the following code and, beside the line the displayed results. I’d like to understand why the different exhibitions. #include <stdio.h> int main() { int inteiro = 1; float decimal =…
-
3
votes2
answers63
viewsWhat does the %u do?
I’ve been doing a list exercise on strings and researched examples. One of the codes was this: /* strlen example */ #include <stdio.h> #include <string.h> int main () { char…
-
3
votes1
answer148
viewsSet the array pointer within a function
I am trying to write a function that assigns an integer or a list of integers to a pointer, depending on a parameter. But the assignment doesn’t work within it, just outside: void retorna_algo(int…
-
3
votes1
answer51
viewsWhat is the difference between the pre-processor directive and the if statement?
In what situation should I use the directive #if? And the reserved word if?
-
3
votes1
answer893
viewsShared memory between Linux C processes (mathematical operations)
I’m studying shared memory in C language and I need to do a simple program so that a shared variable starts with a value and then the program creates a child process where the variable will be…
-
3
votes1
answer355
viewsParsing columns of numbers from a CSV file in C
Hello, Good Night I am with a file . CSV simple, containing only two columns, separated by comma and by the new line, as an example: 0.001,-9.623 0.098,2.540 1.000,-1.002 And I need to separate them…
-
3
votes1
answer348
viewsHow to print the binary representation of a character?
I am in need of obtaining binary representation of the characters of a string. I can do the hexadecimal representation with own printf using %x. Something like: void imprime_hex(char *input) {…
-
3
votes1
answer58
viewsIs it recommended to use typedef in C++?
I know C++ is compatible with C, but C++ has its own way of programming and C as well, so there are legacy things from C that shouldn’t be used in C++, the typedef is one of them? If yes, what to…