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
-
0
votes1
answer121
viewsEdit C. csv files
I need to make a programming code in C, in which I ask the user the name of a city, present in the first file (cities.csv), and I have to remove the id of the city inserted. Then this id has to…
-
0
votes0
answers32
viewsHow can I shuffle a vector with structures? C
I need to shuffle domino pieces on a function, and I’m having trouble. void baralhar(int domino[]) { srand(time(NULL)); for (int i=1;i<=29;i++) { int r = rand() % 28; int aux = domino[i];…
-
0
votes0
answers25
viewsmatrices without size in C
I have a doubt that came to me while learning about matrices of a dimension (no size). Follow an example: #include <stdio.h> int main(){ int matriz[] = {1,2,3}; } My question is: and if I then…
-
0
votes0
answers30
viewsWhy does this appear when compiling? "Segmentation fault (core dumped)"
#include <stdlib.h> int funcao(int **piParametro) { …
-
0
votes2
answers49
viewsProblem with floating point comparison
Hello! I’m doing a job for college and one of the parts I have to do is take the value of h and see if it’s positive and between 0.8 and 1.2. It’s very simple, but when I type 0.8, it accepts!!…
casked 4 years, 3 months ago VictorHugo22 13 -
0
votes0
answers534
viewsStructure and Pointers in C: Binary Tree
Hello, I’m trying to create a mathematical expression tree with the following logic: my expression is a string, and I have 4 character options: ( : When finding this character, my code should create…
-
0
votes3
answers79
viewsDecrease the code
I’m new at programming, I’m doing a project, but it’s getting really big, I was wondering if someone could help me narrow it down. Goes below: #include <iostream> #include <locale.h> /*…
casked 4 years, 3 months ago Joao Lochini 9 -
0
votes1
answer32
viewsString for Vector(Array) in C
I am doing a code task and need to convert a string, for example: 123+* In an`(array) vector of type: 1 2 3 + * Does anyone know how I could do this in C? I’m a beginner and would like to learn.…
-
0
votes1
answer213
viewsCould C-structs have builders?
I have the following structure within a program: struct STR00034ST{ char C_O010XC14B, C_O020XC14B; short S_0010XI15C; float F_0010XI1D; STR00034ST (char _C_O010XC14B, char _C_O020XC14B, short…
-
0
votes0
answers125
viewsC/C++ How to declare a type for event handler in a class?
I need help in C/C++ to know how to define a type for event handler that will be used as a class member. This is an example that works with simple variables and functions: #include "cstdlib"…
-
0
votes1
answer28
viewsCan I centralize all my project Header’s into one? C/C++ Language
Good afternoon. I have a problem with my C project. I have made some libraries and would like to centralize their imports in just one header so that when calling all, give a #include only in the…
c software-engineering software-project project-managementasked 4 years, 3 months ago Felipe.ferreira 11 -
0
votes2
answers183
viewsremove the first and last character of a string in C
I need to make a code where I need to transform a string into an int, but the user can type the number like this: [1234], then I need to remove the first and last character so that it is possible to…
casked 4 years, 2 months ago user220443 -
0
votes3
answers50
viewsDoes anyone have any idea why the if not be executed?
if (strcmp(letra4, "[") == 0) { char string_sem_colchete[10]; for(i=1; i<strlen(comando4)-1; i++) { string_sem_colchete[i-1] = comando4[i]; } string_sem_colchete[i-1] = '\0'; numero4 =…
-
0
votes1
answer36
viewsWhat are the functions of these backslashes in this sentence? http.POST("{ "hello ": "world "}");
// start connection and send HTTP header and body int httpCode = http.POST("{\"hello\":\"world\"}");
-
0
votes0
answers110
viewsAbout Snippets in VS Code
hello, I use Visual Studio Code, I’m a beginner in programming and I wanted a help to assemble snippets in VS Code, I wanted to create snippets for basic functions of C language, like printf and…
-
0
votes1
answer297
viewsString check inside a C function
Greetings! I’m creating a C program where the user can change the state of some sensor by typing the sensor name and 1 or 0 to change the state of the sensor, being 1 for on and 0 for off. However,…
-
0
votes1
answer353
viewsUse of Printf and Scanf in Eclipse and Netbeans - C Language
Good night. I have the program below that asks the user to enter 2 numbers and then present them. Code Blocks is working correctly, but when running in Eclipse or Netbeans, the system is waiting for…
-
0
votes1
answer42
viewsError in vector calculation in C
I’m refactoring my code to make it more dynamic, but by including the line int n = sizeof(vetor)/sizeof(int); within the function bubble it has failed to function properly. Where am I missing?…
casked 7 years, 1 month ago Kelly Soares 1,181 -
0
votes2
answers3022
viewsRepeat number check on matrix in C
I am not able to find the error of this code. I did it to check if in a 4x4 matrix the number being inserted already exists. For some reason that I do not know he accepts the times repeated values…
-
0
votes1
answer49
viewsShow Values greater than an X value in a C list
Suppose I declare a chained list in C and that list contains 7 integers, and I declare a value X = 20. List values: 3,9,11,18,20,22,25 Knowing that my X is equal to 20 which command I would use to…
-
0
votes1
answer60
viewsVariable in loops and function in C
The variables in function and loops do not keep? Because I thought it remained in the loop, different from the function that is forgotten #include<stdio.h> int x = 0; int main(){ int i, x = 1;…
-
0
votes1
answer255
viewsSomething equivalent to the sstream library from C++ to C
I need something similar to the stringstream you have in the C++ connection for the C language, I need it a lot because I want to make querys in a database using C (C mysql Connector). Since I had…
-
0
votes1
answer151
viewsHow can I open a file in a void function?
I am trying to open a text file in a function int abreArquivoEntrada, and for this I am sending as parameter the type pointer FILE and the one vector of char containing the file name, within the…
-
0
votes1
answer18
viewsSave specific values from a file
Contents of the file: df:bd:89:F1:D4:53 50 20.0 76:1f:02:8f:7d:C8 75 15.0 37:77:ac:10:4e:from 90 -10.5 21:33:ac:63:F7:cd 60 30.0 79:fa:3d:ca:4b:3a 65 25.5 bb:7c:72:ab:ad:ce 35 -5.5 22:db:ed:73:A7:4c…
-
0
votes0
answers56
viewsHow to count occurrences of a substring in a string in c?
That was the code I made but it’s not giving #include <stdio.h> int main() { char tamanholetra[51], letra; int a, num; int end; int num2; //escaneia palavra scanf("%s", tamanholetra);…
casked 4 years, 1 month ago lenny45155 17 -
0
votes1
answer42
viewsMenu with pushbutton Arduino (esp32)
I have a question about building a menu with buttons. Initially, I have to wait for a button to be pressed. When someone leaves, I have to open the button option pressed. I tried the following, but…
-
0
votes0
answers1444
viewsWrite.txt file content to C/ C++ array
How do I take the values of a.txt file and place them in a name, phone and email array and sort them by name. I can’t use struct. #include <stdio.h> #include <string.h> #include…
-
0
votes2
answers59
viewsProgram prints the next letter of the alphabet instead of the next char on the pointer
My program is printing the letter P instead of i, I would like to understand the problem behind this and what is wrong in my code. If I put the letter A instead of O, the program would print the…
-
0
votes1
answer373
viewsASCII characters and table
I am trying to perform a URI exercise ,and in the 1 part it asks the following: In the first step, only characters that are lower case letters and capital letters shall be moved 3 positions to the…
-
0
votes1
answer163
viewshow do I save a dynamically allocated vector and return as a pointer in the function?
#include<stdio.h> #include<stdlib.h> void soma(float *vimp,float *vr ,int qnt, float *med, int a); void maiorvalor(float *vimp, float mval, int qnt ); main(){ float med, vimp, mval,vr;…
casked 7 years, 1 month ago Leonardo Henrique 3 -
0
votes1
answer68
viewsWorking with C socket received data
I have a script that receives data via socket done in C, and I’m having difficulty working with this data. Data received from customer: "Imei:123123,23123,tracker,0.0......". I need to receive this…
-
0
votes1
answer421
viewsHow to dynamically allocate an array using a pointer pointer in a void function
I’m trying to allocate from were dynamic a matrix into a function void, this by sending a pointer pointer as parameter int **sigma, as follows lerArquivo(char *alfabeto, int *Q, int *Q0, int *F, int…
-
0
votes0
answers32
viewsBucket Sort C help me
Good afternoon everyone, I would like to thank you first because you have already helped me a lot, but I need your strength again. I have a work in which I must use the ordering method Bucket Sort…
-
0
votes0
answers11
viewsWhy is the null operator not printed in C?
In a string or array of characters why is the "/0" operator not printed if you have the string printed by character or even don’t count towards the Len of the string? It is something that is part of…
casked 4 years ago Guilherme Marques dos Santos 155 -
0
votes1
answer245
viewsC separate string with commas in vectors
I want to separate each line of a file into 2 vectors: v[i]. date and v[i].value. However, when I run the code no value I print is correct, and the outputs are random values. There’s something I…
-
0
votes1
answer624
viewsProblem with printf and scanf - My code does not print the correct information
I have this code here that is not reading the characters correctly when printing the data filled by the user on the screen. Can you help me?? //Question 1) Make an algorithm that reads a user’s…
-
0
votes1
answer40
viewsWhy is a vector in C passed as a parameter by reference?
Why all other types of variables passed as a parameter to a function are passed by value and the vector does not?
-
0
votes0
answers11
viewsDifference between #include and #define pre-processor directives
What is the difference between programming the line of code: #include "filename.h" or #define FILENAME_H What makes the second line of code concrete?…
-
0
votes1
answer1647
viewsHow to Insert a string into the data stack
I need to make a stack that does a push, pop and print. So I created the functions and this works. But I wanted to add a String to my stack. Possibly a number and time or just a string. But I can’t…
-
0
votes1
answer68
viewsClose file in C
How do I close a C file? int main() { abrirArquivo(); fecharArquivo(); system("pause"); return 0; } void abrirArquivo(){ FILE *arquivo = fopen("pub.in", "r");// testa se o arquivo foi aberto com…
casked 3 years, 12 months ago Rafa Sousa 17 -
0
votes1
answer97
viewsError in my data structure [STACK]
My code is presenting two errors. As I am learning, I have tried several ways to fix it. Please someone can help me ? I need to insert a number and a string into my stack. But it’s giving error in…
-
0
votes2
answers59
viewserror: expected Expression before struct
Why are you making a mistake? Why? Error = |21|error: expected Expression before 'Simple list'| #define MAX 25 typedef struct Rota Rota; typedef struct ListaRota ListaRota; typedef struct…
-
0
votes0
answers72
viewsI read 576.73 but it is displayed as 576.729980!
Problem The source code is only to return the amount of banknotes and coins based on an input value. However, I am having trouble manipulating the value of the variable aux. In the demonstrated…
casked 7 years ago Eduardo Assis 11 -
0
votes2
answers1857
viewsVariable percentage in c
I have a problem with a simple code, I want to know how to calculate the percentage of a value. EX: 1500 + 15% (in this case I know it is value = value*0.15) However, the percentage value must be a…
-
0
votes0
answers23
viewsUse char[] or char* to initialize a string?
It would be more correct to use like this: char[] nome = "Fulano"; Or so: char* nome = "Fulano"; I’ve even seen cases of starting a string like this: char nome[256]; strcpy(&nome, "Fulano"); Or…
-
0
votes3
answers82
viewsProblems with if doing 2 functions
I have to make a code where I calculate the BMI, but if the person is 15 years or less is not calculated, but is still calculating #include <stdio.h> void main() { float peso, altura, imc,…
-
0
votes1
answer107
viewsHow to concatenate two strings into C without using <string library. h>?
#include<stdio.h> #include<stdlib.h> int main(){ char vet1[20] = "Bom "; char vet2[20] = "dia"; for(int i=0; vet1[i]!='\0'; i++){ for(int j=0; vet2[j]!='\0'; j++){ vet1[i]=vet2[j];…
-
0
votes1
answer93
viewsHow to pass the registration code as a function parameter?
I have to sort down the salaries of employees of a company. Entree: Tuition, salary, if you wish to continue Exit: Wages in descending order. The error that is appearing is the following: [Warning]…
-
0
votes0
answers12
viewsHow the operating system or firmware knows the end of memory
My doubt is until simple: One thing I don’t know yet is as the operating system or firmware knows the end of memory, kind of a free() in C, you know where the memory allocated ends. Does anyone…
-
0
votes0
answers17
viewsWhat this symbol means in C (->) language
Hello I’ve been coming across a lot with this symbol in C "->" language, without the quotation marks someone knows what it means ?