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
answers105
viewsError trying to imprint the return of a two-dimensional matrix
I’m trying to print a two-dimensional matrix through a loop for only that the matrix it is returned through a function that I created. I’m suspecting that the mistake must be found in it but I’m not…
-
2
votes2
answers88
viewsincrementation table test
I didn’t understand at all and I’ve been trying for hours to understand these two functions. Why do these results come out? I’ve done dozens of table tests and no hits. #include <stdio.h> int…
casked 5 years, 8 months ago Guilherme Ioshua Belmont 19 -
2
votes1
answer372
viewsHow to mirror an image?
I’d like to know how to mirror an image. I got an algorithm, but it only reverses images with 60x60 resolution and bpp=1. I have the following image model to test: unsigned char icon[] ={ //HEADER…
-
2
votes2
answers103
viewsProblems in Reading File
Last week I had a question on how to read a string "giant". Thanks to the help of the staff here I managed to implement the function. Now I have reached a new problem. Reading the file is not…
-
2
votes1
answer499
viewsHow do I resolve struct statement Warning?
I’ll send the code and the warnings that GCC is reporting. I must ignore warnings? The warnings are related as the passage of struct for the job Inserir();: #include <stdio.h> #include…
-
2
votes1
answer3275
viewsCheck if the input is an integer
I need a function that reads a keyboard input and validates whether it is an integer (negative or positive). If it is, it should return the value. Otherwise, it should report that the entry is…
-
2
votes2
answers169
viewsHow to read data from a file in c and treat as a string?
how to read data from a file in c and assign it to a string? file. c #include <stdio.h> #include <stdlib.h> #include <string.h> #define CONFIG "config.ini" void main() { char…
-
2
votes1
answer73
viewsSegmentation fault, Stack in c
I don’t know what might be giving this error in my code, please if anyone knows what is happening. Here’s the code. #include <stdio.h> #include <stdlib.h> struct no { int dado; struct no…
casked 7 years, 2 months ago Lucas Katayama 101 -
2
votes1
answer84
viewsStack in C, problem with exit
I am making a stack, the data entered by the user has to allocate in descending order from the top, but whenever I have print the first at the top comes out as 0, that would be the highest value.…
casked 7 years, 2 months ago Lucas Katayama 101 -
2
votes1
answer256
viewsError in running order of pthreads
My job main was like this (fnThread was set further back): int main() { int i; int *result; pthread_t tid[N]; for (i=0; i<N; i++) { if (pthread_create (&tid[i], 0 ,fnThread, (void*)(&i))…
-
2
votes0
answers60
viewsSend indeterminate amount of JSON strings via socket
have an application cliente/servidor where the client makes a request to the server and the server makes a query to a banco de dados and then returns this data to the client in the format JSON, as I…
-
2
votes1
answer245
viewsWhat is the purpose of using pointers and allocation in c/c++
I would like to understand what pointers are in a generic way and their use, I see simpler codes as registration that I myself do in codeblocks run smoothly without them. Similarly I’m doubtful…
-
2
votes1
answer5984
viewsConvert C code to Assembly MIPS?
How can I generate the assembly code corresponding to the code below: #include <stdio.h> #define LINHA 4 #define COLUNA 5 int tab [LINHA][COLUNA] = { 2016,2012,2008,2004,2000,…
-
2
votes2
answers255
viewsPossibility challenge in c,c++ or Matlab
I’m in need of a program that gives me the possibilities of the following equation: x*y = 1700/57 Whereas x and y are positive reals resulting from two integers ("a" and "b") different from 1 to…
-
2
votes2
answers2032
views -
2
votes1
answer176
viewsSplitting string in C
I am very beginner in C yet, but I have a lot of experience with python, I have a project that I need to receive from the user 3 numbers in the same line and make a vector with these 3 numbers in…
-
2
votes1
answer63
viewsDifference of calling a function in Dllmain by Createthread or calling directly
What is the difference of calling a function in the following ways: The first way creating a thread. Example: DWORD WINAPI Metodo1(LPVOID) { // Meu código aqui... return NULL; } int WINAPI…
-
2
votes0
answers5015
viewsUndefined Reference to
I have a program that’s divided into your main, city.c and city.h. Main: #include "city.h" int main() { FILE *entrada; FILE *saida; Cidade *cidades; entrada = fopen("entrada.c", "r"); int…
-
2
votes2
answers1132
viewsChange compiler settings in Codeblocks
I will participate in a clear programming and need to configure the compiler, in the case of Codeblocks, in the following ways: C: GCC compiler version 8.2 or higher - Command line: gcc -lm -O2…
-
2
votes1
answer3943
viewsHow to compare vectors in C
Hi, I’d like to understand why my code doesn’t work. I’m trying to develop a forcible application and I can’t get the typed letter to be compared to the letter that’s in the vector, which I’m doing…
-
2
votes3
answers1916
viewsFind WHOLE word in a C string
Hello. I need to search a word in a text. #include <stdio.h> #include <string.h> int main(void) { char *word = "dado"; // palavra a ser encontrada char *pageContent = "Ola tudo bem,…
-
2
votes1
answer59
viewsPointers in college
I’m studying pointers and this is a code used as an example that’s in the material given by the college. I went to replicate this code on my machine and the output is different from the material.…
-
2
votes1
answer89
viewsWhat do the following lines of code do?
I have this code: Arvore* arv_insere (Arvore* arvore, Registro* registro){ if (arvore == NULL){ printf(COLOR_RED "ERROR: Arvore não inicializada" COLOR_RESET "\n"); exit(1); } float direction =…
casked 7 years, 1 month ago Pablo Borsone 25 -
2
votes1
answer147
viewsDetect and change System() error message
I have a question about the use of function system. For example, if we execute the following command: (system""); If the example command is not found on the system the function prints the following…
-
2
votes2
answers495
viewsProblems with fwrite in binary file
I am trying to write and read an integer in binary file with the following code: #include<stdio.h> #include<stdlib.h> #include<string.h> typedef struct{ int free_slot; }header;…
-
2
votes1
answer569
viewsWhat’s wrong with my code? (URI problem 1805)
I’m trying to solve the 1805 URI issue: A natural number is a non-negative integer (0, 1, 2, 3, 4, 5,...). Your task in this problem is to calculate the sum of the natural numbers that are present…
casked 7 years ago diogo.alves 203 -
2
votes2
answers772
viewsHow to use a dynamically allocated vector returned from a function in C?
I have a dynamic size vector that was created in a function and need to return it to the main function. The function that returns is the following: int* uniao(int *v1, int n1, int *v2, int n2){ int…
casked 7 years ago iojoaomarcos 43 -
2
votes1
answer737
views -
2
votes1
answer660
viewsProblems with Gaussian filter application
The function should only apply the Gaussian filter to a PPM image, but the result is several overlaid filtered images. Any suggestions ? [Edit] image before filter | image after filter | expected…
-
2
votes2
answers353
viewsProblem to print on screen a string with accent
I would like a help, because when the user type his name with accent, when printing on the screen the name, appears disfigured. #include <stdio.h> #include <stdlib.h> #include…
-
2
votes1
answer37
viewsFailed to read formatted file via incoming redirect
I am trying to read the following file via input redirect, but the program is going into infinite loop and with totally wrong readings. When I manually enter the data the program executes as…
-
2
votes1
answer55
viewsWhen to use "rsize_t" instead of "size_t"?
What’s the difference between rsize_t and size_t, looking in the draft I found in the item K.3.6 General Utilities : rsize_t which is the type size_t; which means they’re the same type, but I…
-
2
votes2
answers167
viewsThe whole name doesn’t appear
In C language as I can show the whole name when asked to enter the user name, I think it is not correct the definition of the char, my code is this: int main(int argc, char** argv) { char nome[100];…
-
2
votes1
answer401
viewsIs it possible to access the address of a C function?
It is possible to access the address, literally, of some function and C and also store in some variable of the main(), etc..? int f1() { }; int main() { int *ponteiro; ponteiro = &f1;…
-
2
votes1
answer328
viewsProblems Reading C File - Comma Delimiter
aid of kindness. I have the following file line structure: 99933311133,UM NOME QUALQUER,8485885855,UM ENDERECO QUALQUER,84 9992212,S,S The default is:…
-
2
votes2
answers164
viewsIs it worth using Assembly, C and C++ in the same program?
To optimize and make the program faster, it would be useful or necessary for me to do everything I can in Assembly, what I can not do Assembly, I do in C, and what I can not do in C++? References:…
-
2
votes1
answer300
viewsBreak text and vector store
I want the program to be able to store only one sentence per line. Each sentence is possible to be completed according to the signals I show in my code example. It does this but when printing on the…
-
2
votes3
answers548
viewsError using scanf("%[ n]") in sequence
#include <stdio.h> typedef struct person{ char name[100]; char address[100]; int age; } Person; int main() { Person pessoa; printf("Digite seu nome:\n"); scanf("%99[^\n]", pessoa.name);…
-
2
votes3
answers447
viewsProblem in the use of malloc and realloc
int main() { int **matriz; f(matriz); return 0; } void f(int **matriz) { int x, l=1,c=3; matriz = (int **) malloc(sizeof (int)); *matriz = (int *) malloc(3 * sizeof (int)); printf("Insira o valor de…
-
2
votes1
answer166
viewsint variable changes value when reading a char variable
I’m doing a simple hangman game. However, when I do the reading of the letter (be it with gets or with scanf), the amount of lives drops to 0. I am using Dev-C++, as it is the program the teacher…
casked 7 years ago Luis Felipe Machado 25 -
2
votes1
answer76
viewsWhy is the result of this mini program 2?
Why the result of this mini program is 2? #include <stdio.h> #include <stdlib.h> int main() { int *P = (int *)malloc(10*sizeof(int)); for(int i = 0; i < 10; i++) { P[i] = i*10; } int…
-
2
votes0
answers51
viewsIs it possible to call a python function via a DLL in C?
I have a commercial program that makes a calculations and allows me to calculate something to feedback the simulation every time step through a DLL code in C. I need to do mathematical optimizations…
-
2
votes1
answer760
viewsHow to remove non-numeric characters?
I want to remove all non-numeric characters from a string. I found the function isdigit that could help me. With it, I’ve gone through all the characters of a string and those that are numeric, I…
-
2
votes2
answers59
viewsReturn the typed name
The program only returns the first letter of the typed name. I think it has something to do with the "%c", but I still don’t understand how this formatting works or maybe the data types in C.…
-
2
votes1
answer516
viewsDifference between using struct and class to create an object
He had already "learned" object orientation in college, right on top of it. Now that I’ve started to revise I realize that no matter how much they say structs do not form objects, I really see no…
-
2
votes1
answer2607
viewsHow to remove duplicate elements from a C list?
I have a contact list and need to be removed duplicates, I was trying to solve using the code below: Elemento* remove_duplicados(Elemento* agenda) { Elemento* a = NULL; //POnteiro do Elemento…
-
2
votes2
answers257
viewsRange of variables in C
I could never understand the question of the range of variables, I know that each one occupies a certain space in memory, but what does the interval mean? When I say a variable char assumes values…
-
2
votes2
answers739
viewsHow to read line break into C file?
Hello! My question is the following, there is a file in which I own the following content: \nteste\n, but when I read it with the following code: int main(){ FILE* file; file = fopen("text.txt",…
-
2
votes1
answer117
viewsBit-by-bit operations (XOR)
#include <stdio.h> void main(){ int a = 356, b = 3; printf("%d\n", a ^ b); /* system("pause"); } Somebody explain to me why this xor does 359? The conversion to binary gets: 101100100 -->…
-
2
votes2
answers78
viewsInvert a string correctly
I cannot print the vector backwards, in this case, the word typed has to have exactly 6 letters. It follows the code: #include <stdio.h> #include <stdlib.h> int main() { char…