Anonymous
XP
Nameful
Cus no pointers?
There are pointers though
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
Mar!o
But if you really, really, need a raw pointer you can have it provided you declare that this code is unsafe
yeah that's cool like in C# for fast applications like games Rust is the better choise but for low level software I would always prefer C++ or C I don't want .map(...).zip().unwrap().extract().iter().filter_mut() in my OS or VM sorry
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
Mar!o
Since Rust tries to fix (and seems to succeed in fixing) the most common sources of security holes
in C but not C++ I agree that C in low level code is critical but C++ fixes most of the problems too (modern C++)
Anonymous
Is there anything faster than a mutex?
Mar!o
Is there anything faster than a mutex?
atomic variables/atomic semaphore mutex is a kernel space construct that's slow
Zoro
#cs50
Anonymous
Anything fast enough to be equal speed with single thread?
Nameful
in C but not C++ I agree that C in low level code is critical but C++ fixes most of the problems too (modern C++)
C++ fixes most of the problems in theory, but in practise there's no way of proving that your code is safe with C++. Rust is mathematically provably safe.
Mar!o
C++ fixes most of the problems in theory, but in practise there's no way of proving that your code is safe with C++. Rust is mathematically provably safe.
maybe it is it is true that you need to be very good in C++ to write safe code but if you know C++ it's a beast if you use compiler specific attribute there is nothing faster
Nameful
maybe it is it is true that you need to be very good in C++ to write safe code but if you know C++ it's a beast if you use compiler specific attribute there is nothing faster
Not even the best programmers write safe C++. Look at Chromium. Google has the money to employ great programmers and still 70% of security bugs in Chromium are things safe Rust should prevent
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
what can i learn? only c plz😂
write a small x86 assembler
Meftahi
#best-book
Anonymous
write a small x86 assembler
like an assembly to c converter?
Yasas
i wanna learn c. could somebody help me?
Yasas
just wanna learn Qt
Yasas
and opencv
Mar!o
like an assembly to c converter?
no an assembly to machine code converter
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
Should have started years ago
who said I've started this year🤷🏻‍♂
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?
Anonymous
This is not code writing service group, put away your homework!
Just allow people to give out their opinions and comments .....its their right
z
Just allow people to give out their opinions and comments .....its their right
It would have been fine if he asked specific part of his problem and not dropping the whole homework without even giving a try to do it himself.
RC
Anyone good at linked list?
OnePunchMan
Anyone good at linked list?
Yes ask your q. Here
Shuchang
How to make presentation
Anonymous
OnePunchMan
Add temp2->next = head->next; before head=temp2 And temp->next->next = NULL Before return.
Anonymous
And for others I remind that Rust is indeed offtopic here
Nameful
And for others I remind that Rust is indeed offtopic here
Even if you're contrasting it with C/C++?
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?
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;}
z
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;}
No, the assignment will only be local if you do that. Your caller may crash due to "Use After Free" if the pointer changes after realloc. You need to: void somefun(char **p) { char *tmp; char *ptr = *p; tmp = realloc(ptr, some_size); // some code.. // some code.. // some code.. // some code.. *p = tmp; }
Barak|ברק
So to affect the global scope char* I have to take **p in the local scope, just making sure I understood it right
Barak|ברק
Oh :) but still I'll have to make a *temp right?
z
Oh :) but still I'll have to make a *temp right?
Yeah, also you need to check whether it returns NULL or not.
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
/warn write it yourself
It was a mistake
Anonymous
/warn write it yourself
I sent here wrongly bro
Anonymous
powerpoint.
LibreOffice..
Anonymous
Anyone good at linked list?
I am also looking for buddy :)
Anonymous
Anonymous
C goes BASIC _10: printf("hello\n"); _20: goto _10;