Yes you need to define it yourself.
C doesn't have templates.
If such function does exist it would look like void swap(void* a, void* b, size_t length), but unlike std::swap, it's not type-safe.
And there's no hint such function could be inlined, which is important if swapping is frequent (in ...
What have you been up to by the way? I've not spoken to you in a while.
C'est le dernier "block" de l'année scolaire pour moi. J'ai seulement un "thesis" qui m'en reste maintenant.
@JohnDoe If you're only swapping integers, and you want to save yourself from using a temporary variable, you can technically do the following (at the cost of more arithmetic operations of course):
I'm trying to allocate and protect a memory page, then trigger a segmentation fault when accessing it so I can play with my signal handler. I am technically behind where I was in the past because something broke.
Likely because I was running it on Ubuntu not macOS.
The overall objective is to implemented shared memory.
I.E: I protect a memory page with a parent process, and the children processes trigger faults when writing to it. I then synchronize their memory.
Hello. I have another question (sorry if it is daft again like the other one): I am trying to take command line arguments and pass them to the WinApi GUI. My code is here, the problem is that the MessageBox function requires const char * whereas while trying to get the actual message from the command line I need a char * (to run strcpy())
I have read about converting const char * to char *stackoverflow.com/questions/25549562/… but is also says it's a bad idea. So I don't know how to solve the problem. Could anyone suggest some way around the problem?
@Stargateur I want to take command line arguments. For example: Message Hello World (where Message is the name of my program). I want to display Hello World but minus the Message part.
I did get it working with just MessageBox(NULL, argv[1], NULL, MB_OK); but that only does one argument. I need to take any amount.
@Stargateur It works :) . Thanks, I still have to learn how you did it though. What is the longhand way of while (*++argv) {? I'm not sure what this does.
@Simon If you don't understand my code you should read a C book, and yes I could write it for "readable" but I always make it hard to read to force people to understand the code that we give to them instead of just copy past it ;)
@Stargateur I am not saying, nor suggesting, you should write it any different. I am saying I don't understand what you wrote in places, and would like some more information (actually I prefer it if I can't just copy and paste it without actually understanding it)... Still going through it at the moment.
Suppose I protect a piece of memory (p) with PROT_NONE (no reading, or writing). Somewhere along the way, I perform the operation:
*p = 1
I am definitely attempting a Write. Does that also contain a Read though, given I am asking for *p.
Suppose I have signal handlers setup for SIGSEGV.
Which condition will I violate first?
And suppose I grant Read/Write permissions only depending on the reason for the signal. Will I receive a second consecutive signal once the other operation is performed (I don't know the order)?
> You use global without reason > You don't initialize hints instead you affect it. > You use global without reason > You don't verify all your system call error ! > You use global without reason