mack
/
i dont want
/
/
mito
I want to create a void pointer pointing to a specific address.
The address is a combination of int and some hex value
e.g address = 536457346 + 0x1F
can I just do (void*)(536457346 + 0x1F)
or do I have to explicitly convert that hex to int like (int)0x1F ?
#cpp
mito
I'm getting this warning
'type cast': conversion from 'int' to 'void *' of greater size
I don't understand what this means.
\Device\NUL
'''''''
int countSubsets(vector<int> a, int sum)
How can I pass another default integer variable n, but set it's value to a.size()?
Anonymous
'''''''
like
int countSubsets(vector<int> a, int sum, int n=a.size())(i know this syntax is invalid, hence I'm asking)
this is a recursive function, so I cannot define n inside the function
\Device\NUL
'''''''
'''''''
but still a good idea, thanks
\Device\NUL
Use size_t or ssize_t for casting
mito
\Device\NUL
mito
Shrivatsa
Can anyone give some advice I want to build project in C-programming
\Device\NUL
Ahh ok, I understand.
Use uint64_t or size_t to cast it. Best practice is size_t as different system can use different data model
mito
\Device\NUL
mito
Levi
let us c
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi guys, so I was trying to write on shared memory. It should be an easy task, the problem is, I can't get it to work. I tried this:
Given the fact that char *addr= shmat(stuff);
and the file is opened this way: int fd= open(stuff);
I tried this: write(fd, addr, SIZE);
but it does not write stuff, could please explain me why? Thank you!
/
hi i need help
/
i want to try using smart pointers
/
i need to create a char * using a smart pointer
/
std::unique_ptr < char > ret ( new char [ size + 1 ] () );
/
i tried this but if i use it on file -> read ( ret, size ); it says cannot convert
/
cannot convert to char *
/
i tried this now but it still not work auto ret = std::make_unique < char [] > ( size );
/
it tells me cannot convert unique_ptr < char [] > to char *
/
/
i have solved it using the get method
/
in the pointer class
RaHuL
Can anyone help..!
How to print a "string" using for loop ?
RaHuL
Leave it... I have solved
Anonymous
C
Pavel
std::unique_ptr < char > ret ( new char [ size + 1 ] () );
You can't store a pointer to char array as pointer to char, because it would be deleted incorrectly. You need to use std::unique_ptr<char[]>.
Also consider std::vector, which can solve the same tasks, but will provide more useful functionality. As someone mentioned on stackoverflow, the only time you need unique_ptr of C-array is when you don't have std::vector available for some reason.
Naman
If anyone can suggest some good book for dsa!
S
you can search in your nearest library.
/
Roxifλsz 🇱🇹
/warnlimit 3
klimi
/unban 1406106635
Roxifλsz 🇱🇹
/warntime 12w
Anonymous
Hi
Dima
Dima
bruhh
Dima
try posting link with spaces
k4leg
0x0 [dot] st [slash] o164.c
Do I understand correctly that this is a bug in ncurses 6.3 (or curses in general): the color pair is not updated in some cases? To reproduce in the above program: press jjkk (fg=6, fg=7, fg=0) or jhll (bg=7, bg=0, bg=1) when starting. If replace line 170 (the end of the endless loop, refresh();) with
clear();
print_asterisks(screen_resolution, resolution);
then everything is fine.
Andrey
Lyroy
Hey, is there any way to get notified when a boost::process::child has terminated its execution without polling child.running()?
Hussein
You may need to look at cross-platform frameworks like Boost or Qt.
yeah boost and Qt can do that too if you were doing it in C++
I thought you were coding in C
but this is also how to do it natively in C++ too using kernel libraries
choose whatever you like
but the concept is the same
1- you create a fork (child process)
2- the fork calls your function
3- whenever you want your main function can ask the OS to kill the fork
you can do this with threads but you will lose your sanity dealing with race conditions and undefined behavior in addition to mutex locks that will slow your program A LOT!!!
Hussein
FB
i made a program for bot how do i put it in bot
Hussein
pavel
If you have a race condition you must to handle it in process as well as in threads. But process synchronization in more complicated
pavel
Yes, you should pay much attention to be able stop thread in legal way
Hussein
Муртазо
Hello guys
I am trying to run some code in vscode. Precisely, I am using math.h library in c to round up some numbers.
gcc main.c
/usr/bin/ld: /tmp/cckUWZE6.o: in function `main':
main.c:(.text+0x4e): undefined reference to `ceil'
collect2: error: ld returned 1 exit status
However it is saying like this. What can be problem?
It is working in online compilers.
Amir.M
No matching function for call to Player::Player()
Friends, what is this error about, I can't understand?!
● Igor
Amir.M
No, this error occurs in the constructor definition of another class and has nothing to do with the Player class
Amir.M
I get this error in the constructor implementation of another class where I used Player class objects
Amir.M
Amir.M
That is, with the definition[5]Player mp, because arguments are not given to objects, does this problem arise?