Questions tagged as 'c'

3
answers

How does the Include directive work?

Does "include" of C ++ do exactly what? I know it "imports" a header / library. But if I have a Header.h with: #include <string> using namespace std; string a() { return "PTSO"; } and in Main.cpp: #include <string> #include "H...
asked by 24.12.2014 / 11:31
2
answers

What are pointers?

I've come across this in several languages, especially C and C ++, but I've never understood what it is, how it's used, and why it exists. I discovered unintentionally that it also exists in C # and is an unsecured practice. What are pointer...
asked by 03.01.2018 / 21:47
2
answers

What is the difference between assigning and comparing string variables with function or with assignment and comparison operator?

I came across the following questions: What is the difference between the expressions strcpy (s, t) e s = t ? What is the difference between the expressions if (strcmp (s, t) < 0) e if (s < t)  ? I tried to compile...
asked by 11.08.2015 / 00:44
1
answer

How does "free ()" know how much memory it has to release?

When we use malloc() we say how many bytes we need. But in free() we do not say. How does he know how much needs to be released?     
asked by 18.01.2017 / 11:48
1
answer

How does the switch work under the rags?

Viewing these comments about using switch is in doubt as to how it works even and why it is different from if when only buying by equality of a single variable against a sequence of values. p> How is this compiled? Should it...
asked by 11.01.2017 / 12:20
2
answers

Binary Search Tree vs Ordered List

Consider an unbalanced binary search tree and an ordered vector list. Which of the two structures is best suited to search for any element.     
asked by 14.12.2016 / 03:24
3
answers

Problems with "or" in C ++

I need to make an algorithm that gets 3 different numbers, and if it receives repeated numbers, it informs an error message. My program is all working properly, but when I put the line to warn of the error I try to use Or and it does n...
asked by 06.03.2015 / 01:12
3
answers

Can a program in C know which OS it is compiling?

I'm developing a multi-platform API in C and need to know if there is any way to know which OS is being compiled. For example, it could be a precompilation directive #ifdef LINUX #include<linuxlib.h> #elif OSX #include<osxlib.h>...
asked by 16.02.2014 / 01:13
2
answers

#pragma once or #ifndef?

I know there are two ways to prevent a header file from being duplicated in C \ C ++: #ifndef FOO_H_INCLUDED #define FOO_H_INCLUDED class Foo { // código }; #endif E #pragma once class Foo { // código }; Being the first I...
asked by 17.03.2014 / 20:22
1
answer

Difficulty in Syntax

I would like you to explain this function to me, I do not understand this syntax: double sum_arithmetic(double x0, double r, int n) { return n == 0 ? 0 : x0 + sum_arithmetic(x0 + r, r, n-1); }     
asked by 29.09.2014 / 00:52