Questions tagged as 'c++'

1
answer

Analyze whether a number is even or odd

The program should do: Digite um Número: 12345 1 e ímpar 2 e par 3 e ímpar 4 e pra 5 e ímpar So far I've made the following code: void parImpar (int num) { int resto; while (num > 0) { resto = num%10;...
asked by 31.08.2018 / 05:03
1
answer

Exceptions cause performance problem?

When working on an application whose performance is important, we recommend NOT USE exceptions . With this comes the question " what makes exceptions so much for performance? " In practical terms what is the need to use noexcept in...
asked by 03.10.2018 / 14:33
1
answer

Should I avoid operations between constants in a loop?

In C ++ is there any sort of optimization or caching that prevents the same mathematical operation between constants from being repeated, especially in loops , thus decreasing application performance? For example: for (int i=0; i<=100;...
asked by 23.04.2018 / 00:56
2
answers

Recursive C ++ code

I have the following iterative function: int getNumPastasColididas(int i){ int c = 0; for(int i = 0; i < size; i++) c += table[i].hasColided; return c; // c = 89832 } I tried to reproduce the operation using a recursi...
asked by 03.07.2016 / 05:30
1
answer

What are Macros and how to use them?

So far during my C programming course, the only contact I had with macros came from standard libraries and I did not know very well what happened when I called these macros. I would like to know what exactly macros are, how to create one in C /...
asked by 09.06.2015 / 00:06
2
answers

How to check the existence of a folder?

How to check for a folder with a C / C ++ program, it looks for the directory, if it does not find the directory specified, it will make the decision to create it.     
asked by 14.12.2016 / 00:54
1
answer

How to use a Lua variable in C ++?

I can not get value from an array in Lua to use in C ++. So I get the value of the variable M : //No LUA M = 85 //No C++ L = lua_open(); luaL_loadfile(L, "teste.lua"); lua_pcall(L, 0, 0, 0); int m; lua_getglobal(L, "M");...
asked by 14.08.2014 / 01:52
1
answer

Data initialization of a class

Is there any class initialization function for C ++? In Lua, using the classlib library there is the __init function, and in Python as well. EX: require "classlib" Human = class(); function Human:__init(name, age) self.nam...
asked by 20.12.2014 / 01:26
1
answer

Capture position of joints on X, Y, Z axes with Kinect V2

I need to extract the position of the joints from a recording and / or in real time, and convert to database format and / or file (txt). Similar to what is done in this video , but instead of displaying need to save the X, Y, Z for each of the...
asked by 13.04.2015 / 23:59
2
answers

How to identify a USB device?

I have two types of devices (A and B) that communicate serially via USB and can be connected to the PC using linux. Is there a way to identify which device is connected without having to talk to it? Since each would be handled by a very diffe...
asked by 25.02.2016 / 14:19