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
-
4
votes1
answer234
viewsUse of assert instead of if
I was reading a book about data structures implemented in C++ and here the author presents the following code snippet: T& operator[](int i) { assert(i >= 0 && i < length); return…
-
4
votes4
answers2635
viewsHow to Delete File or Folder in C Language
How to delete a file or folder by code in c language, I’ve tried using the method remove(pt); but it didn’t work, I tried using dos commands and it didn’t work either.
-
4
votes1
answer2500
viewsHow to take the maximum/minimum value of an integer in the C language
Talk people! Is there a function in the C language that takes the maximum/minimum value of an integer?
-
4
votes1
answer1747
viewsFunction to sum elements of an array does not return correct value
I am making a program for a shopping list, the user passes to the program the values of each product and each one is stored in a vector. Then we added the elements of the vector to give the total…
-
4
votes1
answer240
viewsWhy are there so many parentheses in macro?
Seeing this, it intrigues because it needs those parentheses that seem unnecessary. What is their functionality? #define SUB(x, y) ((x) * (y))
-
4
votes1
answer2537
viewsWhat is the difference between pointer to vector and pointer to variable?
int A; int* pA = 1; int Vect[2] = {1,2}; int* pVect; pA = &A; *pA = 2; pVect = Vect; pVect[0] = 10; In the case I have a pointer to a variable and then to an array, and I want to change its…
-
4
votes1
answer763
viewsHow to perform operations with really large numbers in C/C++?
How to perform sum operations with really large numbers? Numbers that can reach 50 or 1000 digits. Is it necessary to install a library? How to install this library in Ubuntu? You can post some…
-
4
votes3
answers163
views"Carry" variables between functions, appears strange character in place?
In function main when I print a char, it appears a strange code like a hexa: But when I print the same char in another function it appears normal. char tempA[100] = "1111"; int main () {…
-
4
votes2
answers1567
viewsError declaration null - Unknown type name bool
The error you are making is in this function. bool tem_numero_na_lista(tipo_lista * aux, int valor) { while (aux - > prox != NULL) { if (aux - > info == valor) { return true; } aux = aux -…
-
4
votes1
answer239
viewsHow do I get rid of these warnings
I’m doing a program that hunts a word from a matrix. For this I made 8 functions that sweep in all regions, as I need to return in the output the coordinates of the first and last letter. For…
-
4
votes1
answer95
viewsHow to create C program that can use parameters?
I’m studying C, and now I’m trying to pass parameters. Well, although I think I did, it’s making a mistake when I try to use that variable... I explain, the char "argument_value" that step on the…
casked 8 years, 1 month ago Roberval Sena 山本 492 -
4
votes1
answer359
viewsOverwritten txt file in C
My doubt is very basic: How do I stop, whenever I write something in a file (txt), always start recording after the information that was already written there? I mean, how do I not overwrite the…
-
4
votes2
answers4812
viewsHow do I check if there is a special character or number in a string in C?
I am confused in logic to check if it has other characters than alphabetic ones. I thought of the following logic, but I think it is wrong: char nome[30]; scanf("%s", nome); int especial = 0;…
-
4
votes1
answer938
viewsHow to create a dynamic matrix using chained list in C language?
Please help me with whatever power on the subject, I am having difficulties with data structure in college. I thank you already. What I already have for coding! typedef struct tipoElemento { int…
casked 7 years, 2 months ago Selton Farias 53 -
4
votes1
answer86
viewsDifficulty placing non-significant zeros in a converted binary number
I found a code on the web that converts decimals to binaries (32 bits), but I needed one (256 bits) so I changed the code in the way I thought was correct, but after the given size the…
casked 8 years ago Oberdan Santos 105 -
4
votes1
answer152
views"Output" with special characters
I am using the GCC compiler version 5.3 for the following program, written in Aptana: #include <stdio.h> void main(void) { int positivo = 32767; int negativo = -32768; printf("%d +1 é %d\n",…
-
4
votes1
answer1480
viewsAfter all, why use C when programming in C++?
I’m learning C++ and I can’t understand why people think C knows C++? Or are the differences between the two despicable? I know the syntax is similar, but C++14 does things that C doesn’t, and aside…
-
4
votes1
answer2044
viewsCreating processes with Fork
I am creating a sequence of processes through the command fork, but when I went to list the processes generated by the code, I found that there was a greater amount than I had created. Because of…
-
4
votes2
answers625
viewsCalculate the factorial by reference passage
I’m studying pointers I’m trying to calculate a factorial of a number, only the result comes out a totally different value than expected. Here is my code #include<stdio.h>…
-
4
votes1
answer671
viewsI want to check if the string contains only letters?
#include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<string.h> #define tam 50 main(){ struct cadastro{ char nome[tam]; }; struct cadastro dados; printf("Nome:");…
-
4
votes1
answer197
views -
4
votes1
answer220
views -
4
votes1
answer104
viewsDifference between [i] + 1 and [i + 1]
I have doubts about [i] + 1 and [i + 1], one increases position and the other content, correct? In relation to rating (*i)++, it is similar to which of the two cited above?…
-
4
votes2
answers6881
viewsHow to find splitters of a number quickly
I have to ask a question that calculates the very large number dividers and needs in a fast way without being the conventional way, could help me My code #include<stdio.h> int main() { int…
-
4
votes1
answer435
viewsInfix function for post-fixed
I’m making a code that converts an infix function to post-fixed notation, for example: 4+2 to 42+. And I’m not being able to prioritize the elements, for example, when I do the expression 4+2*8, I…
-
4
votes1
answer383
viewsCalculate diagonals of an array using Threads
I need a lot of help. I need to make a program in C in which calculate the diagonals of an array using Threads as stated: As directed, I must pass the value of diagonal and jump (diagonal change) as…
-
4
votes2
answers267
viewsBehaviour of malloc(1) in C
If I use char *char_commandout = (char *) malloc(1);, the allocated byte will store the " 0" at position 0 of the vector or will allocate a space for the value I want to store (at position 0) and…
-
4
votes1
answer1394
viewsRemove and replace vowels in any sentence, C
Context: I’m trying to develop a code that will be able to remove all vowels aeiou of any sentence and save the position that the vowel was in the sentence, so that it is possible to reconstruct the…
casked 7 years, 5 months ago Vinicius Lara 53 -
4
votes1
answer313
viewsC/C++ standard libraries
What’s the downside of using libraries standards such as the function getch() and the library conio.h, What is the downside of using such libraries from a development point of view? More precisely…
-
4
votes2
answers1292
viewsWhat’s best to use, scanf() or get_s()?
Taking the name 'Maria da silva' as an example: scanf() just go read Maria, get_s() will read it all, correct? I’m in doubt of the best use, my college professor says we should clean the buffer to…
-
4
votes3
answers7927
viewsDoubt about Struct and Pointer for Struct
I’m having doubts in my code about structs and pointers for structs, the doubts are as follows: 1) Because I don’t need to put (->) before speed, for example ( p->attributes->speed) in…
-
4
votes2
answers767
viewsDifference between local variable VS global variable
In my micro controller classes the variables are always defined globally and very rarely locally and I would like to know why, because in my mind it makes a difference between being global or local.…
-
4
votes1
answer1925
viewsCan I apply HTML/CSS to a pure C program?
The programming club I’m attending has completed a program that works as a stock controller and shows things that are available and things borrowed. It was made in pure C, so the display is quite…
-
4
votes1
answer4254
viewsC, C++, C#? Why should a beginner start learning?
I am 17 years old and I am learning Java, when I feel that I already master the language I plan to migrate to . NET! What is recommended to start C, C++ or C#? Thanks for the help ^^
-
4
votes2
answers196
viewsDo ( Casting ) of the return of Malloc(), Calloc() and Realloc() - C
According to the discussion Do I cast the result of malloc?, in C is not recommended or correct to cast Malloc() return. This also applies to Calloc() and Realloc functions()? Taking advantage, the…
-
4
votes2
answers2210
viewsHow to concatenate a char into a string?
I’m trying to copy the char E for the component char of my struct No: void push(Pilha* p, char E) { No* novo = (No*)malloc(sizeof(No)); strcpy(novo->simbolo, E); novo->prox = p->topo;…
-
4
votes2
answers282
viewsAlmost prime numbers
I have a doubt in C, I know check if a number is prime, however, almost cousin do not know.. as I do? Follow the part of the code working! However, just checking if it is prime.. the almost prime…
-
4
votes2
answers366
viewsWhat is the typedef function in struct in C? Can I use struct without it?
I’m studying data structure in C, and every time my teacher uses the typedef us struct, but I don’t understand his function.
-
4
votes2
answers1253
viewsC program executing commands in cmd
I am wanting to create a C executable that opens the prompt and execute commands through it, the executable is a solution to the problem "ethernet does not have a valid ip configuration". I’ve even…
-
4
votes1
answer185
viewsDifference between MOV and MOV ptr
Maybe it’s not the ideal place to ask this, but I’m having a test and I don’t understand the difference between MOV and MOV ptr. for example, if we have in c language "unsigned char x,y", in…
-
4
votes2
answers1020
viewsHow to pass an integer file to a C vector?
I have a problem when passing data from my file (integer numbers) to the vector. The purpose of the program below is to check the performance of the sorting algorithms (Mergesort, Bubble Sort,…
-
4
votes1
answer1667
viewsCreate strstr / Pointer return function in C
I am trying to redo the strstr function (look for a value passed by parameter in a text, find shows the rest) by account. This is my current code, it has already worked but I gave some miss click…
-
4
votes1
answer213
viewsDouble type variable precision problem
I’m solving the 1021 issue of the Judge URI, but I have a problem with the accuracy of my input value. Follow the base code: #include <iostream.h> int main(){ double a; cin >> a; } The…
-
4
votes2
answers234
viewsVariable declaration assignment in C
Is it necessary to assign a value to a variable in C once we declare it? I ask because an old programmer told me that it is necessary, because, if we do not declare at first, the compiler could…
-
4
votes3
answers450
viewsComparison of Vector regardless of position
#include<stdio.h> main(){ int vetoresIguais= 0; int vetor[3] = {10,20,5}; int vetor1[3]= {20,50,15}; int i; int j; for(i = 0; i < 3; i++){ for(j = i; j < 3;j++){ if(vetor[i] ==…
casked 5 years, 3 months ago Daniel Soares 73 -
4
votes1
answer298
viewsReading file in C
I use the following structure to read each line of a file: fclose(arq); // fecha o arquivo para em seguida abri-lo em modo leitura apenas arq = fopen(url, "r"); if(arq == NULL) { printf("Erro, nao…
-
4
votes1
answer58
viewsString concatenation behavior in C
Why the following C code works? char *str = "A""B"; /* str = "AB" */ However I noticed that it is only in string statements, for example the following would not work: char *a = "A"; char *ab = a…
-
4
votes2
answers1297
viewsProblem with gets and fgets
I’m having problems with the gets function and fgets... Always when I use them, the program skips the input, ie the user can not type the string, but it only works with scanf, just that I need to…
casked 6 years, 12 months ago System_4n4n 57 -
4
votes1
answer821
viewsOptimize factorial calculation using vector
Statement of the question: Read an array A of vector type with 5 integer numerical elements. Construct a matrix B of the same type, each element of the matrix B being the factorial of the…
casked 6 years, 11 months ago rafael marques 939 -
4
votes1
answer708
viewsWhat does Nodo mean?
I am studying stacks and queues, below I was given a code to analyze. The code first creates queue then queues the values. After this, it removes each of the values from the queue and warns whether…