Questions tagged as 'c'

1
answer

Bubble sort in assembly (MIPS)

My teacher asked us to implement Bubble Sort in the MARS environment but I can not. There are some errors in the code. Can anyone find the error? Output should be {1, 2, 3, 4, 5, 6, 7, 8} but is {1, 8, 7, 6, 5, 4, 3, 2} Code...
asked by 04.11.2016 / 22:51
1
answer

Library similar to Boost and STL in C

Is there a library similar to Boost and STL of C ++ with data structures, etc. in C?     
asked by 07.11.2016 / 03:15
1
answer

The scanf writes string to a pointer that does not have a defined size?

I'm trying to understand how strings work in C. I noticed that even though I can not define any limit for the TextoUm[] (which follows in the code below) in any part of the code, % can write a string to that vector correctly. But the...
asked by 30.11.2016 / 23:24
1
answer

List of structs

I would like to know the benefit of using a list in this way. typedef struct Pessoas { char nome[20]; int idade; struct Pessoas *prox; }pessoas; typedef struct Funcionario { pessoas *pessoa; struct Funcionario *prox; }fun...
asked by 07.12.2016 / 03:59
3
answers

Program in C: A certain doubt

The program I did compiled, but what is requested does not appear on the screen. The question is this:    Construct an algorithm in PORTUGOL, which receives three values, A, B, and C, and   store them in three variables with the following nam...
asked by 09.10.2016 / 00:00
1
answer

Printing a vector ... Differences between C ++ and C ... Where did I go wrong?

I have problems in vector printing of structs in C, in C ++ it worked ... First I will show the C version with problems (in the execution since it compiles without errors) CACHE cache = createCache(descricao); //chamada da main printaCache...
asked by 18.11.2016 / 05:08
1
answer

Return local variables of the function

I have two methods: // Apenas define um vetor de 4 posições e retorna ele int *verticesFromFace(int v1, int v2, int v3, int v4) { int vertices[4] = {v1, v2, v3, v4}; return &(vertices); } // pega um cubo e uma face dele, retorna um ve...
asked by 10.11.2016 / 17:39
1
answer

Wrong ping response

Considering that ${parameters} is an array that can contain valid IP addresses or not, I wrote the following code: for ((i=0; i<$#; i++)); do eval "arg=\${$i}" ping ${parameters[i]} -c1 -q &>/dev/null...
asked by 19.09.2016 / 05:19
1
answer

Dynamic allocation problem

I need to make a code where the user populates a vector as many times as he wants, but the code stops rolling. If I only register 3 values, like (1) (2) (3) it works normally, but at some moments (there is no default) the program stops running....
asked by 03.06.2016 / 19:42
2
answers

How do I use free () and return the same content?

I wanted to use free() in ls_retorna in the following function, how could I do it in the best way? char* MemCpyX(char *as_origem, int an_inicio, int an_quantidade) { char *ls_retorno = (char*)malloc(an_quantidade); memcp...
asked by 27.07.2016 / 21:35