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
votes2
answers82
viewsConversion of byte array to string when compiling revealing the string in C compiled code
I am using the function below to make the conversion of byte array for a string, but when analyzing the compiled code I note that the string is clearly shown (using an Hex editor), what I do not…
-
3
votes1
answer164
viewsDoubt about simple chaining in c
I wanted to know why removal processes in threads have two pointers set to next like this given example void remove (celula *p) { celula *lixo; lixo = p->prox; p->prox = lixo->prox; free…
-
3
votes1
answer5279
viewsDelete line from a C file
I’m doing a grocery project. Products are stored in a row-to-row file like this: codigo(int)$name(string)$quantity(int)$price(int)$. How can I delete a product( ie a specific line)?
casked 7 years, 7 months ago Tiago Santos 39 -
3
votes1
answer70
viewsUse of % in variables
I can not understand what this symbol serves in a variable, I see its use in some points in codes in SQL, Shell Script, C. For what it serves? For example a use of this symbol in Shel Script:…
-
3
votes1
answer514
viewsHow do I eleminate repeated numbers in c
My problem is that I can’t eliminate repeat numbers. First thing my algorithm does is organize the elements, then in the eleminar_numeros_repeated copy method to second vector which is vec1.Only…
casked 8 years, 1 month ago Programador 135 -
3
votes1
answer2112
views2019 LNK ERROR - How to resolve?
I’m having trouble with Visual Studio 2017. This comes up when I compile: LNK2019 undefined external symbol _Winmain@16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)…
casked 7 years, 6 months ago Gabriel Romão 128 -
3
votes3
answers5096
viewsCentralize printf
Personal how do I center messages, simple texts? printf("CLÍNICA DE ANÁLISES LABORATORIAIS\n\n"); printf("TRIAGEM ADMINISTRATIVA\n\n"); These two lines above are within the main. I’d like to center…
-
3
votes1
answer96
viewsHow to convert a normal integer name to its bibliographic format in c?
I want to know how to convert, for example, the following string: "Barack Obama" to "OBAMA, Barack". That is, pro bibliographic format, type when citing authors of books/articles. But I want to know…
-
3
votes2
answers240
viewsString pointer does not work as expected
I’m trying to print the pointer of string below, and put yourself " %s " + char* t[]; makes mistake, already put %c he prints the letter " i " I don’t know why. I want to learn and not Ctrl + c and…
-
3
votes1
answer875
viewsCreating a Makefile
I’m needing to write a Makefile, I was able to configure something by searching, but I tried to improve more for what I need, and I’m not getting it. What I’m trying to do: 1 - Check all files . c…
-
3
votes1
answer657
viewsCurrent position in the file - C
Hello, I’m having a question about C file manipulation and I’m not getting the answer to that. I am recording an "a" record of type "Student" in a binary file "archiving": fwrite(&a,…
-
3
votes3
answers1548
viewsFind pair and odd in variable float language C
Is there a bug in my program when I try to find the odd and odd pair of a float variable. #include<stdio.h> #include<string.h> void exe7(float vet[]){ int i; for(i=0;i<5;i++){…
casked 7 years, 4 months ago Vitória Poncio 101 -
3
votes2
answers714
views -
3
votes1
answer601
viewsReturn local function variables
I have two methods: // Apenas define um vetor de 4 posições e retorna ele int *verticesFromFace(int v1, int v2, int v3, int v4) { int vertices[4] = {v1, v2, v3, v4}; return &(vertices); } //…
-
3
votes1
answer634
viewsHow do I let the string size be set by scanf()?
My question is about the theory. I know it’s possible to make a string without limiting the size of the: char teste[] = "Teste"; however, I would like to know if it has how to do the same thing, ie…
-
3
votes1
answer1049
viewsHow do I write a loop to read a file to a C struct array?
Hello. I have a question how to read numbers from a given file in c to put inside the loop The file . txt will have the following data: 3 Joao Maria branco p Marcio Guess vermelho p Maria Jose…
-
3
votes1
answer540
viewsPrintf running twice during a loop
I’m creating a prototype hangman game. I don’t know much about programming and I have a problem with what is returned. The part of the code that is giving problem and below returns me twice the…
-
3
votes3
answers2365
viewsHow to receive C input data until no more input?
So here’s the deal: How to receive C entries (integers) until "ENTER" is pressed? In my program, the user must enter a chained list in the following format: num0 num1 num2 num3 num4 num5 num6 num7…
-
3
votes1
answer2210
viewsHow to make my code read in UTF-8 in C?
When I spin that code: #include <stdio.h> int main(void) { int teste[10]; printf("Imprimindo o vetor 'teste': %d\n", teste); printf("O endereço do primeiro elemento é: %d\n", teste[0]); return…
casked 7 years, 1 month ago Kenneth Anderson 313 -
3
votes2
answers307
viewsC Cast vs C++ Cast
What’s the difference between using the C cast: float t = 5.0f; int v = (int)t; For the cast of C++: float t = 5.0f; int v = static_cast<int>(t);…
-
3
votes3
answers309
viewsFibonacci sequence does not work
I’m having trouble exiting the Fibonacci sequence and I can’t identify where the bug is. Here’s the code: #include <stdio.h> #include <stdlib.h> int main(){ int i, Fib[100], n;…
-
3
votes1
answer182
viewsOnly 2 houses after the comma
I need the final result to show the whole number and two boxes after the comma. It has how to filter, let’s say, this not to show all the decimal places? #include <stdio.h> #include…
-
3
votes0
answers202
viewsHow to open CD-ROM in C?
I want to create an algorithm in C to open and close the CD-ROM drive, I took a look at some tutorials but they ended up not working. I would like to know which libraries you should use.
-
3
votes3
answers962
viewsPrinting a character in place of a number
#include<stdio.h> #include<string.h> int main() { char str[50]; int i, l = 0; printf(" We will count the number of letters\n"); printf("-------------------------------------\n");…
-
3
votes1
answer1207
viewsHow to calculate the n-th root of a number in C?
I tried to figure it out, only pow returns only the number 1 to me : int funcao1(int y,int z){ int k; k = pow(y,1/z); return(k); }
casked 7 years, 1 month ago Lucas Gonçalves 63 -
3
votes1
answer153
viewsHow to relate two list-type data structures
I am developing a project to better understand data structure, the project is being used list type data structure and I must register students and after registering, I can choose any student who is…
-
3
votes2
answers830
viewsReturn and pass structure through a function in C
Good evening, I am with a work of completion of discipline in which I have to register N employees, in my code I put 5 to get faster the tests. This information would be saved in a structure and how…
-
3
votes1
answer193
viewsHow to measure times in multi-threaded C programs
I’m doing a multi-thread work in c, and I need to calculate the time of a certain part of the program, does anyone have any idea how I can do this?
-
3
votes2
answers503
viewsHow to write numbers between 0 and 10 to a file
I would like to understand how to write to a file, numbers from 0 to 10, from this code: main(){ setlocale(LC_ALL,"Portuguese"); int num[10],i; FILE *arquivo; arquivo =…
casked 7 years, 1 month ago Allan Vinícius 33 -
3
votes1
answer3361
viewsLoop for inside loop for
for(pass = 0; pass < size - 1; pass++){ for(j = 0; j < size - 1; j++){ if(array[j] > array[j + 1]){ swap( &array[j], &array[j + 1]); } } } I put only a piece of code where I have…
-
3
votes2
answers797
viewsWhy can you pass a char vector to the scanf as the direct address or variable?
If the name of the vector or matrix is already the address of the first element, why scanf(), using the primitive types (int, char, float, double) I need to pass the address, being that when we want…
-
3
votes1
answer2472
viewsUndefined error Reference to Std
#include <iostream> using namespace std; int main() { int nombre, carre ; cout << "Introduza un numero : " ; cin >> nombre ; carre = nombre * nombre ; cout << "A raiz…
-
3
votes1
answer751
viewsReturn of Struct in C
Hello, I’m trying to return a struct from a function when it’s called on main. I did the whole function and set in the end two elements which are calculated in function: int mult[100]; char**…
-
3
votes1
answer469
viewsChained list, union of structures
I have some difficulty in uniting two structures in the same chained list, I have never worked with generic lists or even associated in one activity two structures, I have the following structures:…
-
3
votes2
answers159
viewsWhy is the value in bytes displayed as 4?
I am using a 2x2 matrix with a simple pointer and want to display the values of it. #include <stdio.h> #include <stdlib.h> typedef struct matriz mat; struct matriz { int lin; int col;…
-
3
votes2
answers224
viewsWhy do you use extern?
According to what I researched, the reserved word extern in C is used to inform that the declared variable is somewhere else in the program. A variable extern is useful for saving memory, because…
-
3
votes1
answer1694
viewsHow to determine intercession between polygons?
How to determine a C polygon that is intersection of A and B in C ? #include "TPoligono.h" #include <stdlib.h> #include <stdio.h> TPoligono *criaPoligono() { int i; TPoligono *pol =…
casked 7 years, 7 months ago Carolina A. 31 -
3
votes1
answer66
viewsStoring a character in the vector
For some reason, the program is not keeping the character in the vector, as it should be stored, it is skipping the first character. For example: // Declarando o vetor char novosValores[4] = {0};…
-
3
votes1
answer607
viewsHow many elements does an array have?
I have a array of 10 positions which is filled through a function, ARMultiEachMarkerInfoT marcadoresVisiveis[10]; always before adding elements to the array, the function clears all elements and…
-
3
votes2
answers205
viewsWhy do some functions that work with C strings start with *?
In one of our classes we were taught that when a function receives as a parameter an array it is actually receiving the memory position in which it is allocated so it is not necessary to return any…
-
3
votes1
answer1970
viewsProblem with Pow() function
Would someone tell me why the following code does not compile? #include <math.h> double f(double x){ return (x - (pow(2,x))); }
-
3
votes1
answer110
viewsDoubt with C Pointers
I have a chained list, with a single variable that is the date(int). I did this function to delete by value. lista *head = NULL; void deletar(int valor) { lista *prev, *temp = head; if(temp->data…
-
3
votes2
answers5978
viewsHow to print binary/generic trees using C?
I am suffering with the following problem: I want to print in the terminal the "drawing" of a tree. The algorithm I’m working on is based on a stack. In this stack, I insert values(string or…
-
3
votes1
answer107
viewsWhy can’t I store the value '4294967295' in a 4-byte integer?
I wonder why I can’t store the value '4294967295' in one int of 4 bytes and the quoted value converted to binary gives exactly 4 bytes (or 32 bits)?
-
3
votes1
answer62
viewsHow do I publish my library to a linux repository?
I have developed a C library and I want to make it available to other developers. I wish this library could be installed using the command apt-get, for example: sudo apt-get install minhalib and in…
-
3
votes3
answers1906
viewsDecimal to octal conversion
I need to create an algorithm that converts decimal to octal, but my ta converting wrong, someone can help me as it would be right? #include <stdio.h> int decim(int n) { int i,a; int octal;…
-
3
votes1
answer10220
viewsGenerate random numbers in C?
I need to generate 5 random numbers in a range between -10 and +10. How could I do this ? I’ve seen that one can use shuffle, malloc or even realloc, but being new in C, I don’t quite understand how…
-
3
votes1
answer1364
viewsHow to check if two vectors have equal values quickly
The element number reaches 100000 and I have to compare with another vector of 100000, as I can do it with a very high unemployment gain How I’m comparing the vectors for(i = 0; i < teste; i++) {…
-
3
votes2
answers2577
viewsFind amount of times a character appears in a word using recursiveness
Develop an algorithm that reads a word (string) a character and return the number of times this character appears in the word. The algorithm must be recursive. Examples of Input and Output: Entree:…
-
3
votes3
answers138
viewsIs it possible to use for loop to reduce C code?
I have the following function:To. It is possible to use for loop B to generate the declarations as in the function To? What to wear instead of printf to become a declaration?…