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
-
1
votes1
answer211
viewsHow to reference mat[x][y] in pointer notation
I’m working with programming in c, with pointers and dynamic allocation, need to respond to an exercise that asks for the following: How to reference mat[x][y] in pointer notation.…
-
1
votes1
answer90
viewsProblem with switch C
I have a C code, and without the switch, it works right, but with switch, when entering name in the list, replace all the name of the list by the same. void insChild(LIST* l, char name[]) { NO* new;…
-
1
votes2
answers287
viewsInt, unsigned and Signed modifiers in C language
Algorithm "takes age": // idade deve sempre ser positiva, por isso vou usar unsigned unsigned int t1; printf("Digite sua idade:"); scanf("%d", &t1); printf("Idade: %d", t1); Doubt: Even if I…
-
1
votes3
answers71
viewsCompiler accusing error I don’t know
#include<stdio.h> int sumofDie(int value1, int value2); int main( void ){ int die1[7]; int die2[7]; int i; srand(time(NULL)); printf("Rolling die 1 ..........\n"); for( i = 0; i < 6; i++){…
-
1
votes1
answer41
viewsEncapsulating instance structure
Given the following code, implement a small library that makes it possible. #include <stdio.h> #include "object.h" int main() { obj_instance *oi1; obj_instance *oi2; object_init(); oi1 =…
-
1
votes0
answers370
viewsHow to write and read a table hash in/from a file (FILE) in C?
I am using fread and fwrite but there is an error of execution. #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct pessoa{ char nome[20]; char cpf[10];…
-
1
votes1
answer96
viewsProblem in assembling a C matrix
I have a problem with a matrix that I set up to be typed letters and these transformed into ascii table numbers, but it doesn’t print Where am I wrong? Someone can help me? #include <stdio.h>…
-
1
votes0
answers28
viewsHow to place website online?
I’m studying c and php - Is there any line of code that puts a website online? Or else, how does it really work?
-
1
votes1
answer677
viewsProblem to insert a graph
I’m trying to insert vertices and links into a graph, but it only works when the graph has an even number of edges. The source code below has the TAD and the functions of inserting and creating…
-
1
votes0
answers350
viewssetlocale in codeblock windows without working right
I have a programming project that was to develop a replica of the naval battle game. however I did all the program on Linux(Ubuntu 16.04) however my teacher uses windows (using codeblocks) and to…
-
1
votes2
answers451
viewsSemantic difference of "Malloc" and Calloc"
I was in programming class with C and I got the doubt about the difference between Malloc and Calloc, but not in what each one does, but in the meaning of "M" and "C". I know that Malloc comes from…
-
1
votes1
answer101
viewsWhat is the point of calling conventions and which one to use?
What is the purpose of calling conventions __fastcall, __stdcall, __thiscall, __cdecl, __fastcall and how to know which one to use? For example, in some function that needs to be called faster (I…
-
1
votes1
answer663
viewsCan you capture events like this when pressing a C++ key? [Codeblocks]
Good morning, I am making an Autoclick bot for personal use and I would like to add the function of pausing clicks when pressing a specific key but I do not know if it is possible to do this in…
-
1
votes1
answer62
viewsError in the average calculation of a student record
printf("Nota 1: "); scanf("%.1f", &alu[n].not1); printf("Nota 2: "); scanf("%.1f", &alu[n].not2); alu[n].media = (alu[n].not1+alu[n].not2)/2; // o erro acontece NESSA LINHA invalid operands…
-
1
votes1
answer760
viewsArrays and Pointers
Hello, how do I point to a multidimensional matrix? I know that to do this with a vector (one-dimensional matrix), it’s like this: int v[5]; int *ptr = v; I understand that very well, but with a…
-
1
votes3
answers196
viewsIs it possible to store values without using static vectors?
I need to create a sparse matrix of the cross-dynamic list type and my cells are the type: typedef struct CELULA{ int linha; int coluna; double valor; }CELULA; But every time I create a new cell in…
-
1
votes1
answer49
viewsChar* value is shown even where it was not called using Arduino
This is exactly what I’m wearing: #include <SPI.h> #include <Ethernet.h> byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // Tentativa frustada, possui o mesmo problema: //uint32_t…
-
1
votes1
answer924
viewsHow to make one matrix run inside another using functions?
I have two functions, one belongs to a 10x10 matrix and the other to a 3x3 matrix. I need to make the 3x3 matrix run inside the 10x10 matrix. How do I do that? From now on I thank anyone who can…
-
1
votes0
answers55
viewsHow to round float in C without using printf()
I’m not getting round the float to the first two decimal places. I wrote my program like this: float valor; scanf("%f", &valor); printf("valor = %f\n", valor); Once compiled, I typed 573.93 to…
-
1
votes0
answers46
viewsSyntax Error/Possibly Logical in a Recursive Function
Statement of the question: Consider the following functions: int suc(int n) { return n+1; } int pred(int n) { return n-1; } Using these functions (and no arithmetic operator), create recursive…
casked 7 years ago Gustavo Pacheco 71 -
1
votes1
answer51
viewsError collecting dynamic typing value
I’m having trouble collecting the values in a dynamic C typing. The inserted values as char, const char *, int, void * and long int work perfectly when placed in the printf (prints the value without…
-
1
votes0
answers55
viewsRecover chained list of.bin file
I am programming in C and I have a code that uses a sequential list of 50 positions to store in each of its spaces the first address of several chained lists, so far so good, the problem is when I…
-
1
votes1
answer692
views -
1
votes1
answer223
viewsProgram does not wait to read the received content
I’m creating a program that reads the student’s name, number of fouls, 3 grades and returns if the student has passed, flunked for foul or flunked for average, knowing that the foul limit is 15, the…
-
1
votes1
answer35
viewsProgram does not run without reading the contents of the variable
I am creating a simple program for a college job, which reads 2 numbers, an arithmetic operator and returns the result of that operation. But it turns out that after printing on the screen "type the…
casked 7 years, 9 months ago Cauã Vilte 25 -
1
votes1
answer93
viewsWhy use a pointer to that algorithm?
When I withdraw the code does not work. Why? And why the algorithm of Insertion Sort is only suitable for list of small entries, type array and list (little)? void insert_sort(int *vetor, int TAM){…
-
1
votes1
answer783
viewsExit a c program via CMD
In the following code, when I press 9 the program must close: case 9: exit(0); After pressing 9 the screen below in cmd is displayed, but after pressing 9 is displayed the message: Press to close…
-
1
votes1
answer790
viewsError: incompatible types when assigning to type 'char[200]' from > type 'char'
When I try to insert the char motorista an error appears: [Error] incompatible types when assigning to type 'char[200]' from type 'char' Code: #include <stdio.h> #include <stdlib.h>…
-
1
votes1
answer195
viewsScanning an entry by scanf does not walk in the string beyond the white space
I’m trying to make a program that reads a sentence and then capitalizes every initial of every word, if not already. The problem is that I type in a sentence but it only returns the first word,…
-
1
votes1
answer401
viewsArray storage
I have a question about storing information in array, I thought, when inside a loop, an array of size 200, for example char nome[200] it would be populated continuously until there is no more space…
-
1
votes1
answer1990
viewsHow to limit decimal place?
printf("%.3f", &resp); I am using the following line, however, when comparing to a number, it requires that you have the same decimal place number as the original, for example: 2.963258741 !=…
-
1
votes1
answer3323
viewsCode stack and pop a stack
People I’m testing this code in codeblocks and it’s giving a very weird result, saying that the stack is empty and I can’t see where the error is. void empilha (int *p[], int *topo, int valor){ if…
-
1
votes1
answer126
viewsPassing value from a label to Arduino via serial
I have developed a Windowsform that contains a label that checks CPU usage and displays its variations, and a button that connects the software to the Arduino in the available serial port. I also…
-
1
votes2
answers538
viewsHow do you test a number and tell if it’s prime or not?
I have a small problem, after the first time the code runs it only shows "NOT PRIME" and no longer shows "PRIME", where "NOT PRIME", would be for non-prime numbers, and "PRIME" for prime numbers.…
-
1
votes1
answer168
viewsStack does not work properly in Codeblocks
This code below compiles both in Codeblocks and Visual Studio, but the output is different in Codeblocks. By VS I do not delete anything from the code below, just run and ready, now in Codeblocks I…
-
1
votes2
answers7869
viewsIndentation of code C
Two other people and I are developing a C code, and each made their own part of the code, but it got very "messy", is there a command for the codeblocks, the IDE we’re using, or some site that…
-
1
votes0
answers492
viewsStore contents of file . txt for a vector and vice versa
Good evening. I need to read a text file and store each book (Struct book) in an array of books. The code has functions to add, edit, delete and view in the array each book. I cannot properly save…
-
1
votes1
answer154
viewsInsert node into binary tree
How to insert a node into a binary tree? It always gives segmentation error when the code enters if (arv == NULL) struct no { int info; struct no *esq; struct no *dir; }; typedef struct no node;…
-
1
votes1
answer196
viewsDoubt with the ternary operator
Which means the following expression: struct Node *temp = root->left ? root->left : root->right; I’m wondering if he’s checking the existence of the pointer root->left or comparing *temp…
-
1
votes2
answers25163
viewsNumbers in Ascending Order C
I am trying to make a code to show 3 random numbers in ascending order typed by the user however I do not understand why my code is not working #include <stdio.h> main(){ int…
casked 7 years, 8 months ago Daniel Duplat 31 -
1
votes1
answer2063
viewsHow to find higher value Chained List C?
I’m having a hard time solving an exercise in C, I never programmed it and I got C in the first semester, you can help? I need to draw 3 integer values between 0 and 200 in the main function. If the…
-
1
votes0
answers453
viewsRow function in C
Guys, I have to do a de-rank function. Receive from the user: -1 to un-row an element or 2 to queue an element That is to say the user to queue has to type option 2 and then enter the values and go…
-
1
votes1
answer125
viewsThe matrix is printing the same values for all indexes, why?
Create an algorithm that loads a 12 x 4 matrix with the sales values of a store, in which each row represents one month of the year, and each column, one week of the month. For simplification…
casked 7 years, 8 months ago Italo Zuckerberg 63 -
1
votes2
answers130
viewsWhy the program is terminated before the scanf
I have the following code: #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { float a, b, c, delt, c0, c1, c2; char s; int op = 1; printf("Welcome.\n\n"); while…
-
1
votes1
answer63
viewsError in string inversion
I’m trying to reverse one string through a function only that it is giving error, however I do not know where it is wrong. Right below is my code. #include<stdio.h> #include<stdlib.h>…
-
1
votes3
answers2111
viewsComparing C string contents to find palindrome
I need to check whether a string The, for example, is equal to string B to determine if the word inserted is a palindrome, the problem is that a string B is the reverse of A, I’m not able to…
-
1
votes2
answers7908
viewsHow Binary Tree Removal Works in C
I have several doubts about the operation of binary tree in C. I have a code and I’m having second thoughts about how the tree removal works. Could someone explain to me better what is happening in…
-
1
votes2
answers91
viewsDoubts cast in c
If I give a printf thus: int x=5, *px = &x; printf("%d %ld\n", x, (long)px); So far without Warning none, but if I change the printf: int x=5, *px = &x; printf("%d %d\n", x, (int)px); I get…
-
1
votes1
answer2251
viewsC pointers treated in python
#include <stdio.h> #include <stdlib.h> #include <locale.h> int main() { setlocale(LC_ALL,""); int *x,valor,y; valor = 35; x = &valor; y = *x; printf("o endereço da variavel…
-
1
votes1
answer131
viewsHow do I create a somaCum() function for Adian? C
Angles ang = {0.0,46.0,91.2,134.7,179.2}, the unit is deg (steps). I have to implement code that initializes the values as a global array, and then defines the void somaCum(float arr[]){} function…