Questions tagged as 'c'

1
answer

Fill in a vector with random values (Language C)

In one more of my studies in Language C, I had the idea of trying to populate a dynamically allocated vector with random numbers. However, I came across the following problem: The rand function was set to randomize a number every second. As the...
asked by 21.04.2015 / 17:12
2
answers

Discover the operating system of the machine in C

I need to do a function to clear the screen in C that runs on win, mac and linux. I thought about doing a function that: If the OS were windows: system("cls"); If the OS was linux or mac: system("clear"); The problem is: H...
asked by 24.08.2017 / 16:52
2
answers

Recurring print in triangle format

I have to read an integer value and pass it as parameter to a function. This should show the number using the sample format. Ex: if the number you entered was 3, show: 1 1 2 1 2 3 I can show the format that asks the question, but not exa...
asked by 29.10.2018 / 23:51
1
answer

How to interpret this line? (struct list *) 0)

while (variavel != (struct lista*)0) { ... } How to interpret (struct lista*)0) ? What does that mean?     
asked by 18.09.2018 / 22:15
3
answers

Problem with sum in vector in C

Problem with sum of vectors, I'm trying to put the sum of the vectors directly in the loop , but it is not doing the sum of all, but duplicating the last vector, I tested the same code in Portugol and worked perfectly, what would be the problem...
asked by 03.10.2018 / 15:43
1
answer

cho-han bakuchi

I'm trying to make the game cho-han bakuchi in C. It is very simple, the Japanese game consists of throwing two 6-sided dice in a cup, before the dice are shown the player makes the bet saying cho (pairs) or han (odd). Then it shows the da...
asked by 09.07.2014 / 15:10
2
answers

Why is the value in bytes displayed as 4?

I'm using a 2x2 array with a simple pointer and I want to display the values of it. #include <stdio.h> #include <stdlib.h> typedef struct matriz mat; struct matriz { int lin; int col; int *arr; }; mat* cria(int lin,...
asked by 05.04.2017 / 04:03
1
answer

How to identify the type of the variable in C?

In languages like Nodejs , Ruby , Moon , etc. When I want to know what the type of my variable is, just use the typeof function (not necessarily in the languages mentioned) that returns a String with the type name of my variable. B...
asked by 23.02.2017 / 06:26
1
answer

Use of assert instead of if

I was reading a book on data structures implemented in C ++ and here's the author with the following code snippet: T& operator[](int i) { assert(i >= 0 && i < length); return a[i]; } This is a code to access an e...
asked by 17.02.2017 / 20:03
1
answer

Return of functions in C

A very common and practical thing in interpreted languages is the return of functions from another function. But in compiled languages as well as C , is it possible to return a function?     
asked by 17.02.2017 / 17:45