Anonymous
XP
Mar!o
Yeah in unsafe code. Normally you use refs or wrapped pointers like in C++.
Nameful
Yeah
Anonymous
#noendl
Nameful
But if you really, really, need a raw pointer you can have it provided you declare that this code is unsafe
Anonymous
Oof, but flushing is needed for synchronized printing
Nameful
Mar!o
Why do you not want that?
because it hides the generated code very well
if I write a simple for loop in C I know that's going on.
The same in C++ even with a range base loop.
But with Rusts overkill abstracted iterators I do not.
So for low level software I would not use Rust
But like I said for games and general applications which needs to be fast it's a good choise
Nameful
I would argue Rust is even more relevant for low-level software that probably runs with higher privileges than a game or a general application
Nameful
Since Rust tries to fix (and seems to succeed in fixing) the most common sources of security holes
Anonymous
Anonymous
Is there anything faster than a mutex?
Zoro
#cs50
Anonymous
Anything fast enough to be equal speed with single thread?
Nameful
https://www.zdnet.com/article/chrome-70-of-all-security-bugs-are-memory-safety-issues/
Anonymous
guys im a 11grader i want to learn something stunning to make my classmates go 😱😱😱 ahahaha
Anonymous
what can i learn? only c plz😂
Otumian
Mar!o
Mar!o
Meftahi
#best-book
Anonymous
Anonymous
Yusuf
Yasas
i wanna learn c. could somebody help me?
Yasas
just wanna learn Qt
Yasas
and opencv
Yasas
Mar!o
Yasas
well, it is.
Yasas
in an indirect way
OnePunchMan
Mar!o
well, it is.
no
assembly is just text representation of machine code
each instruction you write in assembly is splitted into multiple instructions at machine code level
for example
movl $1, %eax
movl (%eax), %ecx
are all different machine code instructions but you write mov only
Yasas
yep.
Yasas
well,im intending to build an operating system based on ubuntu, thats pretty much the reason im gonna learn c.
Mar!o
in an indirect way
also machine code is binary only
very complex encoded data
x86 has variable length instructions so assembling assembly is not even that easy
Anonymous
https://www.chegg.com/homework-help/questions-and-answers/question-write-c-program-creates-linked-list-10-random-integers-0-100-program-must-perform-q76620405
Anonymous
help guys
Pavel
help guys
What problems do you have with it?
z
RC
Anyone good at linked list?
OnePunchMan
Shuchang
How to make presentation
Anonymous
OnePunchMan
Add temp2->next = head->next;
before
head=temp2
And temp->next->next = NULL
Before return.
Anonymous
Anonymous
And for others I remind that Rust is indeed offtopic here
Nameful
Official hooligan of Pius XII
Hello, since I've been using Python and Bash most of the time I ran into an obstacle when starting out with C++. Below I attach my simple implementation of quicksort in Python (why not C++ scratch? I think a correct code is simply better to read :)). As you can see it recursively generates 3 arrays and when the stack is done, it merges those arrays into a single, sorted one that is finally returned. Could anyone at least point me what should I use to achieve it in C++? I don't care about arrays, it may work with vectors (but arrays are preferable), as well. I've been reading about it a lot but all the time I get either different quicksort functions or accessing the base array via pointer, none of them does help me. If you want to show an example code, it may be even Java. I will appreciate any help, thanks in advance :)
def quicksort(array):
if len(array) < 2:
return array
else:
div_point = [array[randint(0, (len(array)-1))]]
lesser, greater = [], []
for element in array:
if element < div_point[0]:
lesser.append(element)
elif element > div_point[0]:
greater.append(element)
else:
div_point.append(element)
return quicksort(lesser) + div_point + quicksort(greater)
Barak|ברק
Hey, if I take a pointer and do realloc on the same pointer , it'll keep it's initial pointer address?
char *ptr;--> this address.
/* Code */
ptr = realloc (ptr, 100*sizeof(char);
ptr --> the same as this?
z
Barak|ברק
So it's best that I'll make a new pointer in a function if I take a pointer as argument, use the one I made and then just reassign the new one to the parameter pointer?
void somefun(char *p){
char *ptr;
/* Some code */
p = ptr;}
Barak|ברק
So to affect the global scope char* I have to take **p in the local scope, just making sure I understood it right
z
Barak|ברק
Oh :) but still I'll have to make a *temp right?
z
Because realloc may fail, when it fails, it returns NULL, and set the errno to ENOMEM.
Barak|ברק
Thanks!! You helped me a lot!
Anonymous
float about_four_en_arf = sqr(4.5F);
Anonymous
Anonymous
Suka
Anonymous
C goes BASIC
_10: printf("hello\n");
_20: goto _10;
Talula