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
-
2
votes2
answers183
viewsHow do I insert complex numbers into C++?
I know I’ve asked a question like this before. It was about Python. But in C++, how to insert a complex number?
-
2
votes1
answer183
viewsLearn ABC in C language?
As I do in this code, when he type a letter read by the keyboard with the type scanf (char) it repeats until the Z? #include <stdio.h> #include <stdlib.h> int main() { char c; /*for (c=…
-
2
votes1
answer126
viewsStoring SOCKET in a vector
I am working on a project developed in c/c++ where a server handles several connections, I do not have much experience in this language, I would like to know how I should proceed to add a SOCKET in…
-
2
votes1
answer3712
viewsHow to scroll through a 2-dimensional matrix in C and display?
In this code, I have a two-dimensional array(array), I started and I want to print with the printf, but I don’t know how: #include <stdio.h> #include <stdlib.h> int main() { int i; int…
-
2
votes2
answers193
viewsSegmentation fault in C: Adjacency structure representing graph
I need to create a program to read a graph and represent in an adjacency structure, however, my compiler is accusing Segmentation fault and I can’t figure out what might be causing it. It might help…
-
2
votes2
answers67
viewsError displaying the sum of three arrays read
#include <stdio.h> #include <stdlib.h> int main() { int i, notas[5]; int soma = 0; for(i=0; i<3; i++) { printf("Digite os tres numeros:\n"); scanf("%d", ¬as[i]); } for(i=0;…
-
2
votes2
answers774
viewsGenerating random number in C language
Let’s assume I have an empty array of size 8. int A[8]; And then I intend to fill it with random values whose I would have a function similar to the rand(); However, I call on rand() for each…
-
2
votes3
answers678
viewsdata structure problem
Hello, I am doing a simple program of data structure it, have to organize some flights as for example register airports and flights of these airports, each flight line can only have one plane going…
casked 9 years, 6 months ago Leonardo V. De Gasperin 713 -
2
votes2
answers358
viewsDoubt about compilation in C/C++
I started studying the compilation of multiple files and I had a question. When we create a new header, we have to create another file with the implementation of the prototypes contained in the…
-
2
votes2
answers1206
views". exe has stopped working"
I have the following code: typedef struct { unsigned int ordem; int *elementos; }MAT_DIAG; void criar_matriz (MAT_DIAG *m, int d); void inicializar_matriz (MAT_DIAG *m); void imprimir_matriz…
-
2
votes2
answers2082
viewsGenerate random numbers from a predefined set
How to generate a random number in a range of non-sequential numbers. For example, a function that randomly chooses between the values, 3, 10, 20 and 2334 in the language C
-
2
votes1
answer768
viewsUnexpected value is being displayed
Do a program that receives the number of hours worked, the value of the minimum wage and the number of overtime worked, calculate and show the salary you receive, following the rules below: a. The…
-
2
votes2
answers362
viewsIs it necessary to invoke the functions "Showwindow" and "Updatewindow"?
I recently made an introduction to Windows API and I’m already in the window-making part. In one of the first applications I created I had to use ShowWindow and UpdateWindow after creating a window,…
-
2
votes2
answers1768
viewsAlgorithm in C - Primes
The program has to do a check of prime numbers, where the user type a number and the program finds the largest prime number before it. the problem with my program is that it doesn’t check until the…
-
2
votes0
answers33
viewsWhat is the possible cost of using blocks for exception treatment in too ?
As exceptions are interruptions caused most of the time by the operating system, I wonder if there is any cost of memory (stack/heap) since, existing exception treatment the program continues to run…
-
2
votes1
answer1494
viewsRemove odd numbers from a stack
In C how is it done to remove only odd numbers from a stack? I was thinking of removing item by item and moving to an array, but the stack size is not given.
-
2
votes1
answer137
viewsAllegro Debug -Abort() Has Been Called
I tried to make an animation and Visual Studio gives the error Debug -Abort() Has Been Called. Code: #include <allegro5\allegro.h> #include <allegro5\allegro_native_dialog.h> #include…
-
2
votes1
answer610
viewsSequential Static List
Guys look at this following code : lista is a struct lista * crialista() { lista *li; li = (lista *) malloc(sizeof(struct lista)); if(li !=NULL) { li->qtd = 0 ; } } because it was allocated lista…
-
2
votes2
answers937
viewsBowling score in C;
I’m a beginner in C And I’m having problems in an exercise, I can’t see a way to solve it. Following: In each stage the player has 2 balls with which to knock down 10 pins. The stage ends when: the…
-
2
votes1
answer81
viewsHow to use different heights for BMI in C?
In my BMI calculation program (in C), you must type the mass first and then the height (of n people). I wonder why he is considering the masses correctly but is always using the first height to…
-
2
votes1
answer709
viewsAdd typed values without using array
Prepare a program that asks the user to enter 10 values, add this results and present on the screen. I could only do it with one array whole. #include <stdio.h> #include <stdlib.h> int…
-
2
votes1
answer556
viewsOpen application in the background in C - Linux
I am programming a watchdog for my system, at the beginning of the code I need to run the application in the background, for this I use the command: system(". /meuprogram&"); But the program…
-
2
votes1
answer132
viewsChar count in C
I have a C function that should take a string, and pointers that have the amount of numbers and vowels that are present in the string, but the function is not adding up each time it finds a number…
-
2
votes2
answers2111
viewsUse of pthread library in windows environment
Is it possible to work with the pthread library normally in a windows environment? Or should it only be in linux?
-
2
votes2
answers72
viewsCode compilation
Guys help me, I can’t compile this code: Until starts the command screen no more runs #include <stdio.h> int main() { int x,y,z; int a=0; for (x=0;x<=1;x=x+1) for(y=x;y<=1;y=y+1)…
-
2
votes2
answers199
viewsHow to monitor a C code on Linux
I was trying to use top to monitor the performance of my codes in c, but when I run the program does not appear. Is it just not visible, or can’t monitor code in c using the top? What should I use…
-
2
votes1
answer408
viewsQuery vector from one table to update another in C
Hello. I’m new here and I’m not even sure I was objective in the title. But come on. I’m almost done with my final C Algorithms project, and I’m unable to update one item from one table with…
-
2
votes1
answer3569
viewsPassing information from a file to an array
I have a problem, I want to receive a file and copy the information from that file to an array allocated by me: Content that exists inside the file: 2..E.5..A......D ....1E....7B80..…
casked 9 years, 5 months ago Gabriel Vinicius 95 -
2
votes2
answers7781
viewsGenerate random number without repetition in C
Hello, I am making a memory game in c, and would like to know how to generate a random number without repetition. I will post what in the function so far. I will need to do another function only to…
-
2
votes1
answer122
viewsTie problem for
I’m having a problem and I can’t identify it in my code, I have a for with 60 iterations, and it’s falling in if’s when I identify it (i in this case) is divisible by 5 or 3 only in the first…
-
2
votes4
answers29520
viewsPrint strings in alphabetical order
I’m trying to do here because the user provides 3 name at least so I have to sort these names in alphabetical order, had tried with strcmp, but I didn’t really understand the concept of this…
-
2
votes2
answers189
viewsPassing by reference in C
In the case of language C, when we want to pass a variable by reference we need to pass its address to the function, I have a question in this case. Take the example: int main(){ int *a; *a = 5;…
-
2
votes2
answers2037
viewsInsert widget into binary search tree
I’m having a hard time adding an element to a binary search tree. The function returns 1 if the element to be inserted is already in the tree and 0 otherwise. The function return works well but when…
casked 9 years, 4 months ago José Cunha 411 -
2
votes1
answer114
viewsI’m creating a queue, and I can’t develop function logic for the previous object to assume the new position released - C#
I’m using unity3D, so my queue consists of Gameobjects, are 7 Gameobjects lined up next to each other and my purpose with this code is that every click of the user - "Simplemove function" - the…
-
2
votes1
answer2024
viewsProblem using getch() in C
I’m writing a simple game that relies on crossing a number in the first element of the matrix to the last element. However, I’m willing to use the function getch() so that the element moves through…
-
2
votes1
answer58
viewsTake element size from a vector?
I have a vector like this: int nums[10] + {1235, 14627, 1625161, 54437}; Always the element will be greater than or equal to 1000, that is, with length equal to 4, and can extend up to 10 digits. I…
-
2
votes1
answer2462
viewsGet size from a character array?
Vector example: char nome[10] = {'b', 'r', 'a', 's', 'i','l'}; First of all, although my vector has 10 position I’m only using six, and I want to know how exactly I picked up this length, which in…
-
2
votes1
answer79
viewsDoubt with sockets(Winsocks)
Good, I am learning how to work with sockets (never worked) and decided to start with winsocks. I am currently using winsock2.h and in the tutorial I’m following I came to a part that I can’t…
-
2
votes1
answer298
viewsCopying from a file to an array
Good evening, I’m having a problem, I’m wanting to copy information from a file to an array that allocates dynamically, the text file contains this: ....* *.... ..... .*... ..... (5 rows and 5…
casked 9 years, 3 months ago Gabriel Vinicius 45 -
2
votes1
answer97
viewsProblem in condition to handle string
It was only supposed to work with lower-case letters and when it arrived at symbols it did not change, but they are being changed. What’s the problem? #include <stdio.h> int main() { char…
-
2
votes2
answers1348
viewsHow to show the largest number typed, using functions?
#include <iostream> using namespace std; void maior(int a, int b); int main() { int cont, maior1; do { cout << "digite um valor: "; cin…
-
2
votes2
answers126
viewswhile code does not make the correct condition
I need to create a code that reads only one double and register in two variables the "smallest so far" and the "biggest so far", I can even complete a cycle successfully but after that it prints out…
-
2
votes2
answers295
viewsProblem with malloc
People, doing a small program that given any number, enter a function that divides the number into a vector and returns the number of decimal places (number of positions) that the vector has. In all…
-
2
votes1
answer260
viewsUnion and type conversion
Searching about Unions I found the following information: Unions are usually used for type conversions. For example, we can use a Union to write the binary representation of an integer in a disk…
-
2
votes1
answer841
viewsVector union, adding the vectors?
I created the following function to join two vectors (not being able to repeat an equal number), follows the function and the comments showing what I did and the error it is giving: void uniao(int…
-
2
votes2
answers6996
viewsProgram that sums/multiplies 2 numbers and what’s between them and prints
I believe the logic of this programme is right, but the result is wrong. Make a program that receives two X and Y numbers, being X < Y. Calculate and show: the sum of the even numbers in that…
-
2
votes3
answers1286
viewswhile for number other than 0 in C
I need the program to stop when the consumer number is 0. So I put one of the while saying that as long as the consumer number is different from 0 he continues the program and when the consumer…
-
2
votes2
answers339
viewsString reading and input buffer
I always used the fgets() function to read keyboard strings, because it (at least I thought so) always clears the input buffer. However, I am finding some errors with the execution of the function…
-
2
votes3
answers1025
viewsproblem in C with rest of the division
Develop a program that scans ten elements of an A-matrix vector type. Construct a matrix B of the same type, observing the following law of formation: if the value of the index is even, the value…
-
2
votes1
answer77
viewsExtract data with bitshift and bitwise operators
Good, I’m having some trouble separating the date parts through bitwise operations. date format: yyyy-dd-mm int menor_data(int date1, int date2) { int day1 = (date1 >> 8) & 0xff; int…