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
Alignant
olli
It throws a warning
But most will argue "it still works". With such a compiler you could proof it not working
Alignant
Alignant
olli
olli
Parameter passed to main, parameters you start your executable with
olli
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
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
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
Dima
Dima
you get A+
Alignant
In the 5th grade I would ^_^
olli
BinaryByter
olli
Alignant
And v...vectors~
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
BinaryByter
c arrays are static
you have to reallocate and copy them in order to simulate a dynamicity (which is what vector wraps)
olli
Dynamic is in terms of resizing, you cannot resize neither a std::array nor a c style array
BinaryByter
Alignant
Alignant
Cause you need a dynamic array in your life
Alignant
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
olli