Questions tagged as 'c'

2
answers

Correct handling of pointers

I'm having problems performing implementations of some of the shell commands in C. From my point of view it seems that it is due to an incorrect handling of pointers in C (I have not learned this language for a short time). At the moment I am tr...
asked by 28.11.2016 / 00:10
2
answers

Where do the constants stay?

Well, as I read the compiler could place them on the stack or in a memory area only read, the standard does not guarantee that it is the first or the second. According to the standard any attempt to modify a constant type variable is indefini...
asked by 12.06.2017 / 18:31
1
answer

What is the most efficient matrix or vector in C?

I would like to know which of the two is more efficient in terms of execution time (it does not matter if it consumes more resources than others). This comparison is based on the following: Acceder de forma matriz[fila][columna]; Acceder de f...
asked by 12.01.2017 / 06:24
1
answer

Problem with processes and memory reserve

I have the following exercise: Perform a program that expands N child processes. Each child must share a variable called counter, which must be initialized to zero. This variable must be incremented by each thread 100 times. Print the variabl...
asked by 18.12.2018 / 21:25
2
answers

strcmp gives unexpected results

I was practicing a bit of c to refresh my memory and there are some lines that are not working for me: int main(){ char nombre[20]; int cont = 3; printf("Ingresa tu nombre de usuario\n"); fgets(nombre,20,stdin); fflush(st...
asked by 09.10.2018 / 17:57
3
answers

Delete an item from a "list"

Good morning, I am learning to work with C pointers and I have a question about an algorithm that I am implementing that makes extensive use of malloc , realloc and free , this is the code: List.h #ifndef _LIST_H_ #d...
asked by 11.10.2016 / 20:50
2
answers

Data passing from one pointer to another

In my program you have to create a duplicate function that receives a string and returns a pointer to a new string that is the copy of the previous one. My program "works" the problem is that if the initial string passed as an argument to my dup...
asked by 04.09.2016 / 07:26
1
answer

can someone explain me getchar ()! = EOF?

I do not understand very well how getchar and putchar works, for example: main() { double nc; for (nc=0; getchar() != EOF; ++nc) ; printf("%.0f\n", nc); }     
asked by 03.10.2016 / 07:09
1
answer

Release dynamic array memory from pointers in non-binary tree

I have this structure: typedef struct Nodo { int valor; int numSubNodos; struct Nodo *padre; struct Nodo **hijo; } Nodo; To fill it as a non-binary unbalanced tree, or rather a node can have several children and not all th...
asked by 05.04.2017 / 16:29
1
answer

segmentation fault

I have a problem when I try to assign a character to my 'next' pointer, it throws me a segmentation error. With the debugger I've seen that next points to a character, the only thing I want to do is step on that character with a blank space ('')...
asked by 11.09.2016 / 15:43