Anonymous
except maybe some embedded applications
Anonymous
I began with c and the steep learning curve bored me. Switched to py then later came back to c
Anonymous
OH WAIT
Anonymous
there are some things
Anonymous
you can do in C but not in C++
Anonymous
but they are considered bugs by C++ programmers
Anonymous
Hi
Anonymous
C99 has variable length arrays
Anonymous
which C++ says is stupid
Anonymous
and disallows
olli
C99 has variable length arrays
As optional, compilers do not need to implement that
olli
using VLAs might not be the best choice ...
Anonymous
if i recall C++ likes to complain when i try calling a function pointer with a different prototype then the function i am calling
Anonymous
however this is perfectly ok in C
Anonymous
offsets into the middle of the function are much harder to calculate in C++
Anonymous
https://en.m.wikipedia.org/wiki/Restrict
Anonymous
this is not in C++
olli
offsets into the middle of the function are much harder to calculate in C++
How do you do that? Arithmetic operators on function pointers are not defined
BinaryByter
U can xD
I know I know
BinaryByter
but not as well as in C++
Anonymous
Anonymous
then swap the prototype to a new function prototype to handle execution from that point
Anonymous
then run it
Anonymous
i have some C code
Anonymous
that shows how to do this
Anonymous
but it has to be compiled under O0
Anonymous
using gcc
Anonymous
,
olli
Yes because it's UB
Anonymous
C++ prevents gotos from crossing initialization
Anonymous
Anonymous
this is defined behaviour
olli
how?
Anonymous
for a specific compiler
Anonymous
you know that the compiler will generate certain machine code for different lines of code
Anonymous
given a 0 optimization level
Anonymous
you calculate the machine code bytes needed in order to get to the section you want to execute
olli
I though we were talking about C not a compiler?
Anonymous
this if anything is IB
Anonymous
implementation defined behaviour
olli
Well, actually every UB is probably somehow IB since the vendors are free to do it how they want it
BinaryByter
/unban @girlfriendmenno
BinaryByter
/unban @girlfriendmenno
Mihail
BinaryByter
wat?
Shivam
Lol
Mihail
re send the command
BinaryByter
#ot
Shivam
Off topic?
Anonymous
In C, a function prototype without parameters, e.g. int foo();, implies that the parameters are unspecified. Therefore, it is legal to call such a function with one or more arguments, e.g. foo(42, "hello world"). In contrast, in C++ a function prototype without arguments means that the function takes no arguments, and calling such a function with arguments is ill-formed. In C, the correct way to declare a function that takes no arguments is by using 'void', as in int foo(void);, which is also valid in C++. Empty function prototypes are a deprecated feature in C99 (as they were in C89). this is what i was talking about
Anonymous
you calculate the machine code bytes needed in order to get to the section you want to execute
what i was doing in here is i would inject some asm code into the function saying how to use the stack frame and so on for passing variables
Anonymous
would make the function ()
Anonymous
then i would call the function as is without any issues
Anonymous
then i would call the function again but this time giving a offset and passing a bunch of parameters
Anonymous
into the function pointer definition
Dexter
Dexter
I want to make this upside down I tried but messed up....
Prometheus
I want to make this upside down I tried but messed up....
Windows has a feature to rotate the screen lol. But seriously, how did it turn out when you tried to do it?
BinaryByter
Thank god you did not said rotate your lappy upside down
that would be worth a try as well though
Prometheus
That's probably the way that has the least chance of crashing your system are least.
Prometheus
Thank god you did not said rotate your lappy upside down
So what was the output when you tried it?
Ariana
you can add numbers to characters
Ariana
A+1=B
Ariana
B+1=C...
Mihail
what's the point of the ascii function?
Dexter
Wait a min please I believe in trying several times before wasting others time... Last time i encountered an error that was due to environment... I want to be sure this time...
Dexter
what's the point of the ascii function?
I make all my programs like this... You may say its how i write codes on C It has various benefits when you have a long code
Mihail
your function does literally that, but worse in every way
Mihail
yes using functions is obviously a good idea, but just making up functions isn't
Mihail
to do things like setting a number
Dexter
My fingers are actually making out with the keyboard I'll let you know in a min But if i failed again I need your help guys