I just wanted people to explain to me what the code I'll give is.Why did they not even inform me that my post was rejected?
I just wanted people to explain to me what the code I'll give is.Why did they not even inform me that my post was rejected?
What are you talking about? Was your post rejected? It seems to me that this is your first message here.
Devoted my life to programming...
A post can be "rejected" (in a sense) because of a lack of code tags.
Also, apparently some posts are being "moderated", which means they should show up later.
Maybe it was just a temporary error in the forum Hawksed? If you want to give it another try, consider copying your message into a text editor in case it fails to post again.
It was an unrepairable train-wreck of formatting.
I suggest you study what other posts look like when it comes to formatting code, and make sure yours looks the same through the preview feature before pressing submit.
Also, you might want to work on your opening gambit of "I know nothing, please explain this code I found".
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
okay
Oh really, so why was it full of TR/TD tags as well?
Help me understand what the code does
All you did was ctrl-a ctrl-c and ctrl-v and you call that effort?
You may as well have just included the URL to where you copied it from - that would have been more useful.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
It's just that your site does not want to highlight the syntax, so unnecessary efforts are useless. I put the code on pastebin:
[C] vdc.c - Pastebin.com
Such efforts are worth it.
Except that it does. Here's a sample of one of the functions from your pastebin code:Originally Posted by Hawksed
Basically, post it in the same unadorned text as in your editing environment, within [code][/code] tags. You may find that the syntax highlighting does not appear to be applied immediately after you post, but it will be on the next page load. You may encounter a bug where leading whitespace right after the opening code tag is not kept, but that's a fairly rare problem and can be worked around or just ignored.Code:static int do_cmd(int sock, int argc, char **argv) { char final_cmd[255] = "0 "; /* 0 is a (now required) sequence number */ int i; size_t ret; for (i = 1; i < argc; i++) { char *cmp; if (!index(argv[i], ' ')) asprintf(&cmp, "%s%s", argv[i], (i == (argc -1)) ? "" : " "); else asprintf(&cmp, "\"%s\"%s", argv[i], (i == (argc -1)) ? "" : " "); ret = strlcat(final_cmd, cmp, sizeof(final_cmd)); if (ret >= sizeof(final_cmd)) abort(); free(cmp); } if (write(sock, final_cmd, strlen(final_cmd) + 1) < 0) { perror("write"); return errno; } return do_monitor(sock, 1); }
Last edited by laserlight; 03-31-2017 at 02:05 AM.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
You might want to paste code from your editor to notepad first to remove any nonsense formatting, and then paste here from notepad, again, using code tags. Some environments are particularly bad about adding colors or weird fonts; all of which will cause the syntax highlighting to be turned off.
Code:Maybe it's not this bad, but everyone can see what happens in this case.
If you're on Chrome, you can paste as plain text via ctrl-shift-v. Edge just strips all formatting anyway.