YVEF
Hi Guys. Is there any existing function that can erase (zeroing) part of array which contains some string (until \0). for example: char arr[7] = { 'h', 'i', '\0', 'b', 'l', 'a', '\0'}. some_erase(arr) => { '\0', '\0' '\0' , 'b', 'l', 'a', '\0' }
Alex
algorithm::erase
YVEF
algorithm::erase
thanks. but do you know such C functions?
Igor🇺🇦
thanks. but do you know such C functions?
memset https://www.cplusplus.com/reference/cstring/memset/
Igor🇺🇦
thanks. but I don't know a size
How do you want to handle anything related to arrays if you don't know the size? To work with C style arrays you have to pass size all the time.
Anonymous
#best-book
Nils
Does void* x, y; mean both x and y are a pointer? So is it different from void *x, y; ?
YVEF
How do you want to handle anything related to arrays if you don't know the size? To work with C style arrays you have to pass size all the time.
ease. while(arr[index] != '\0' && index != array_size) arr[index] = NULL. but I just what to know about existing one:) btw I know array size. I need just stop erasing when achieve an end of string
Anonymous
/get cbook
Jaaa
Int **arr what does this mean
YVEF
But you said you said you don't know the size. 🤷‍♂️ I'm confused. Why can't you you use memset?
it's just an example. if I have no size, I also can do it while(arr[index] != '\0') without size checking. it's dangerous but anyway possible. So, now I do it this way - memset(arr, 0, strlen(arr)). I didn't know about strlen function. And anyway it's 2n operations which is not perfect
Vedant
i recommend you visiting fivver
Vedant
ohh..but thats not fair bro
Jaaa
Int **arr = new int*[n]
Jaaa
What does this mean
Pavel
Int **arr = new int*[n]
You allocate array of int pointers of size n on heap and assign the pointer to that array to variable arr which is of type "pointer to pointer to int".
Jaaa
How you can say that it is in heap @gameraccoon
Jaaa
I got it
Pavel
How you can say that it is in heap @gameraccoon
new allocates on heap (technical term that is used in C++ standards is free memory AFAIK, but everyone knows that it's heap :))
Jaaa
How how the equation would be if I doesn't use pointer and I want to allocate array on heap
Jaaa
vector<int>
🛑🛑🥺
Pavel
C++
I would suggest to use std::vector
Jaaa
I doesn't reach on that topic
Jaaa
Till that's why. ...
Alex
usually you don`t need to use raw pointers in C++. there are libs
Anonymous
it's just an example. if I have no size, I also can do it while(arr[index] != '\0') without size checking. it's dangerous but anyway possible. So, now I do it this way - memset(arr, 0, strlen(arr)). I didn't know about strlen function. And anyway it's 2n operations which is not perfect
Are you trying to implement memory management by hand? The [Boehm garbage collector](https://www.linuxjournal.com/article/6679) is a popular solution. I've never actually used it though... Today would be a good day to give it a try! https://www.youtube.com/watch?v=gthWRmT1qG4
Pavel
Till that's why. ...
I'm not sure if you can achieve this at least with dynamic n size. Since the type of raw array is determined from its size, if you don't know size at compile time you usually refer to it by pointer (and store the size somewhere also). But I'm now sure, we really don't use raw arrays often since std::vector covers most of the cases when they are needed.
Anonymous
Hello everyone
PLAUNIT
Hi
Anonymous
H r u
CrazyDev
Anyone need Programming eBooks for FREE (pdf)? Message me
CΞMİL
/purge
CΞMİL
you asked me to write
Wojak
Anyone need Programming eBooks for FREE (pdf)? Message me
Why would anyone need a programming eBook from you? It's anyway from the google unless it's your own
Wojak
and if it's your own, why would anyone want it ?
Wojak
you asked me to write
Yeah! rose is a bit8h sometime, forget her and move on
Anonymous
Thanks. I will check it)
This article is better, it turns out to be pretty easy. https://blog.varunramesh.net/posts/the-boehm-gc-feels-like-cheating/
Prometheus
I figure this may qualify since it's programming in c++. Anyone ever use QT? I keep getting the error "strip: file format not recognized" on a c++ source file when compiling with qmake. Any idea how to fix this?
Prometheus
Nevermind. Apparently those errors can just be ignored
Anonymous
Hello
Prometheus
hi
Andrew
hi
Nameful
hi
Prometheus
there is qt group
Yeah. I figured it out.
CΞMİL
hello
Anonymous
hello
Hii bro
CΞMİL
Hii bro
THANK YOU
Anonymous
Does anybody want to run C code with LLVM? Then try this: c #include <stdio.h> int main() { puts("Hello, World!"); return 0; } and then in the shell shell $ clang -emit-llvm -c ./hello.c $ lli ./hello.bc The ".bc" extention stands for "bitcode".
Anonymous
There might not be execution priviles on a mounted disk... I just thought a C related tip of the day would be a good idea. :/
IAmMADMAX
hello
Anonymous
Hi
Anonymous
Any real c programmer here?
IAmMADMAX
Can anyone help me in a question?
Anonymous
#include <stdio.h> void selection_sort(); int a[30], n; void main() { int i; printf("\nEnter size of an array: "); scanf("%d", &n); printf("\nEnter elements of an array:\n"); for(i=0; i<n; i++) scanf("%d", &a[i]); selection_sort(); printf("\n\nAfter sorting:\n"); for(i=0; i<n; i++) printf("\n%d", a[i]); getch(); } void selection_sort() { int i, j, min, temp; for (i=0; i<n; i++) { min = i; for (j=i+1; j<n; j++) { if (a[j] < a[min]) min = j; } temp = a[i]; a[i] = a[min]; a[min] = temp; } }
Anonymous
On my system there is no <conio.h> or <bits/stdc++>, but it compiles with those commented out. How is it misbehaving?
Asher
Recommended any best online free c c++ courses I do have prior knowledge of programming
Anonymous
/get cs50
Asher
Can someone with full knowledge of any one specific language provide his services on freelance websites? Or you need more than one? Please do explain
Anonymous
You should consider doing web development.
Asher
Yes i have started.. Plus what would be good for now to use as backend language, php or python?
Vedant
Yes i have started.. Plus what would be good for now to use as backend language, php or python?
python......so that you could expand your know to other domains too
Asher
🙏thanks
Anonymous
The projects on freelancing sites would not be easy for beginners with only coding skillz... They always want something business relevant.