Zeus
.. okay got it
Zeus
Long long int
Zeus
Thanx I'll look into it
Dima
long long = long long int
Dima
oh really
Mat
long long unsigned int
olli
N1570 7.21.5.2 states flushing an Inputstream is undefined behavior
olli
Someone should really write a compiler generating code that terminates once undefined behavior is invoked
olli
It throws a warning
But most will argue "it still works". With such a compiler you could proof it not working
Alignant
But most will argue "it still works". With such a compiler you could proof it not working
Lol, what you as is to make a "treat warnings as mistakes" flag by default :D
olli
Lol, what you as is to make a "treat warnings as mistakes" flag by default :D
No, not being C++98 compatible may warn as well, nothing wrong with it. I want your executable to terminated once undefined behavior is invoked. The compiler is perfectly allowed to do this.
olli
Parameter passed to main, parameters you start your executable with
Alignant
What must work at runtime?
You want to monitor your executable during it's runtime.
Alignant
By the way, clang specifically writes it if you have a UB
Alignant
#include <iostream> int main() { int a = 5; a = a++; std::cout << a << std::endl; return 0; } Well, GCC writes: source_file.cpp:8:12: warning: operation on ‘a’ may be undefined [-Wsequence-point] a = a++;
Alignant
No
If you find a UB at compile time, you don't even have to generate an executable~
olli
It is always undefined
Alignant
I also think anyone should work with a treat warnings as error flags. If you have to compile with a warning, you have to disable it
Alignant
Why do you start each line with an uppercase?
Mat
That code will not compile otherwise
olli
fflush makes no difference on my system
olli
Since undefined behavior
olli
No my compiler can do what it wants in this case. Your code is not valid c.
olli
Use a space before %c, this will discard whitespace characters
Alignant
Printf("dya wanna try again (y/n); You have to close a quote make, btw~
Alignant
I know I'm annoying
Alignant
From w-what? :c
Alignant
I see it's no Java, what do you mean by mother array?
Alignant
Well, cout does'nt print arrays. You can do it in a loop
Alignant
#include <iostream> int main() { long array[2][2] = {{2, 3}, {4, 6}}; for(int i : array[1]) std::cout << i << " "; std::cout << std::endl; return 0; } Only like this~
olli
Prefer std::array over c style arrays in c++
olli
The parenthesis are optional And no it's a range for loop
Alignant
Isn't it great? :D
Alignant
You know, there is a fun way to print an array otherwhise
Alignant
But don't laugh 😂
Ибраги́м
https://lemire.me/blog/2018/09/07/avx-512-when-and-how-to-use-these-new-instructions/
Alignant
#include <iostream> #include <iterator> int main() { int lol[] {2, 3, 5, 7, 8}; std::copy(std::begin(lol), std::end(lol), std::ostream_iterator<int>(std::cout, " ")); return 0; }
Alignant
Ah, it's not that hard
Alignant
It'll work #include <iostream> #include <iterator> int main() { int lol[2][3] {{2, 3, 5}, {7, 8, 5}}; std::copy(std::begin(lol[1]), std::end(lol[1]), std::ostream_iterator<int>(std::cout, " ")); return 0; }
Alignant
prints 7 8 5, lol
Alignant
You can also write std::begin(lol[0], std::end(lol[1]) and it'll print the whole thing :D
Dima
lol basics 5th grade
Alignant
This was just fooling around, lol
Alignant
And you definitely should not use C-like arrays in this fashion
Alignant
lol basics 5th grade
Thanks for ruining my day btw
Dima
Thanks for ruining my day btw
nah I am just kidding
Dima
you get A+
Alignant
In the 5th grade I would ^_^
Alignant
And v...vectors~
BinaryByter
And v...vectors~
only for dynamic arays
BinaryByter
vectors are slower than arrays
Dima
std::stack
olli
But do note std::arrays use no dynamic memory allocation
Alignant
only for dynamic arays
Well, I mean... C-arrays can be both static and dynamic. And you should use std::arrays and vectors instead.
BinaryByter
c arrays are static
you have to reallocate and copy them in order to simulate a dynamicity (which is what vector wraps)
Alignant
c arrays are static
Ah... realloc anyone? :D
olli
Dynamic is in terms of resizing, you cannot resize neither a std::array nor a c style array
BinaryByter
Ah... realloc anyone? :D
std::vector actually just re-allocates instead of changing the vector size
BinaryByter
olli
Ah... realloc anyone? :D
Does not change the array size but changes the array
Alignant
Cause you need a dynamic array in your life
BinaryByter
Cause you need a dynamic array in your life
And you still think that C is better for a beginner to learn?
Alignant
Does not change the array size but changes the array
C-style array can be allocated with a new(malloc) It makes it dynamic, cause its size is not known to the compiller
BinaryByter
C-style array can be allocated with a new(malloc) It makes it dynamic, cause its size is not known to the compiller
C-Style arrays are the things that look like this: int a [size]; actually in C you can use a variable as size index
BinaryByter
int size = 10; int a [size];
BinaryByter
should compile on a C11 compiler
BinaryByter
You CANNOT change the size of a C-array. you can only reallocate it