stdout: channel 1stderr: channel 2
to stdoutis:
command 1> out.txtor
command >> out.txt
to stderr is:
command 2> out.text
to both:
program > out.txt 2>&1or in different files usingprogram 1>stdout.txt 2>stderr.txt
cmd1; cmd2- call 1 after anothercmd1 && cmd2- the same as before but fails if some returns non-zero codecmd1 | cmd2- piping stdout of cmd1 to stdin cmd2
find smith : ls | grep smth
std::cin- stdinstd::cout- stdoutstd::cerr- stderr
Note
>>in
<<out
#include <string>to usestd::string- concatenate with
+ - check if empty using
str.empty()
examples:
std::string hello = "Hello";
std::cout << hello + "Bruno" << std:endl;#include <array>to usestd::array- store collections of items of same type and fixed size:
array<float3> arr = {1.0f,2.0f,3.0f} arr.size();arr.clear();arr.front();arr.back()
#include <vector>to use std::vector- use the same methods as array
vec.emplace_back(value)can be more efficient thanvec.push_back(value)- to optimize vector resizing use
reserve(n) vec.insert(,)is also available such theiterator()
- similar to
foreach()in Java, here we havefor(float num: vector)
string Fun(int n){return "int";}
string Fun(const string& str){return "string";} - easy example:
float some_float=13.3f;
{ // New inner scope
auto another_float = some_float; // copy
}//another_float dies- Use & to state that a variable is a reference
float& ref = original_variable;ref has type float&- use
constreferences as a funtion argument type for non fundamental variables types
-
create folders
buildandsrcand aCMakeLists.txtfile at the parent folder; -
to execute CMAKE you need to give the
CMakeLists.txtpath, for examplebuild/$~ cmake ... Follow the typical set of instructions for the project. -
To all subdirectories that we added, another CMakeLists need to exists there and they can be empty!
${PROJECT_SOURCE_DIR}/is a system variable that is usefull to set a full path; -
At the end, we need to add a executable in the CMakeLists at
srcfolder :add_executable(main_bin main.cpp); Then we can use onlymakeat build folder unless if we added new files after making cmake. A newsrcfolder will appear insidebuildfolder with the executable file
from this issue :
- Tested working hotfix would be adding following lines somewhere in the head of CMakeLists.txt:
IF(APPLE)
LINK_DIRECTORIES(/usr/local/lib)
ENDIF()Look for libraries
arc dynamic/static libraries
use
#pragama onceat header files