Change file order in a Windows Directory in C
Like when you drag a file on top of another one and change the order, like that. ...
Like when you drag a file on top of another one and change the order, like that. ...
I have developed a reverse-string program. I am wondering if there is a better way to do this, and if my code has any potential problems. I am looking to practice some advanced features of C. char* reverse_string(char *str) { char temp; size_t len = strlen(str) - 1; size_t i; size_t k = len; for(i = 0; i < len; i++) { temp = str[k]; ...
So, as I learned from Michael Burr's comments to this answer, the C standard doesn't support integer subtraction from pointers past the first element in an array (which I suppose includes any allocated memory). From section 6.5.6 of the combined C99 + TC1 + TC2 (pdf): If both the pointer operand and the result point to elements of t...
I am a person who is trying to learn C, but I got stuck at a few points while doing my projects: 1) How exactly can I implement random integer generation? I have Googled and found the code for 0 to x generation with the code below, yet how about between 2 integers that I decide (like between X and Y)? int random; random = random(100); ...
There is a nice feature in modern windows applications for vista. It is picture in the window header. For instance new skype (v4) and google chrome have it. I was woundering what is technology behinde it? If you switch off aero style, windows still has decaration. Probably application totaly redraw window frame. However, I didn't find ...
When developing a C/C++ (=2?) plugin based framework with shared objects/dynamic libraries that need to support live swapping what examples would be helpful to look at for implementation details? Thanks. Note: live swapping is the key point here, no need to restart the system is a requirement ...
If a call to fread() returns 0 and ferror() indicates an error (vs. EOF), is it OK to retry the read or is it better to close and reopen the file? I can't start over entirely -- the input file has been partially processed in a way that can't be undone (say I'm writing out a chunk at a time to a socket and, due to existing protocol, have...
I am trying to output things like 안, 蠀, ☃ from C #include <wchar.h> int main() { fwprintf(stdout, L"안, 蠀, ☃\n"); return 0; } output is ?, ?, ? How do I print those characters? Edit: #include <wchar.h> #include <locale.h> int main() { setlocale(LC_CTYPE, ""); fwprintf(stdout, L"안, 蠀, ☃\n"); return 0; } this ...
I'm writing a little library where you can set a range; start and end points are doubles. The library has some build-in or calculated default values for that range, but once they are set by the range setting function, there is no way to go back to the default value. Hence what I like to do is to use the NaN value as the indicator to use...
Hi, I'm working on a refactoring tool for C with preprocessor support... I don't know the kind of refactoring involved in large C projects and I would like to know what people actually do when refactoring C code (and preprocessor directives) I'd like to know also if some features that would be really interesting are not present in any ...
I have the following simulation in C for cars in a traffic circle For example, 7 <space> <enter> gives more cars to the simulation, while s1 <enter> puts a top sign to the incoming road #1. I want to put the simulation to an internet page such that users can try it. However, I do not know where I should start. I know Joomla a...
I'm learning C and I can't figure out one of the K&R exercises, the listing: Exercise 2-3, Write the function htoi(s), which converts a string of hexadecimal digits (including an optional 0x or 0X) into its equivalent integer value. The allowable digits are 0 through 9, a through f and A through F. I suppose I need to d...
Hi All, I am looking for the way to calculate the one-way delay in a packet-switched network. I do not want to use NTP or PTP (Network Time Protocol, Precision Time Protocol). Consider the scenario: Host-1 Sends the packet to Host-2. Both Hosts have different Clock rates and the hosts are located in different countries. Packet may be...
While I am aware of the differences between debug and release builds, I am curious if attaching the debugger to a process (built release or debug) changes that processes behaviour? For reference, I'm developing on HP 11.31 Itanium but still am curious for the general case. ...
I'm writing a simple function in C whose purpose is to take a 6 bit number, work out the first 3 bits, and based on that, return a "r", "w" or "o". However, when I compile I get this warning: 'return makes integer from pointer without a cast'. Then, when I run the program, I find that the function is returning a weird character that def...
This question is actually a result of an interesting discussion at programming.reddit.com a while ago. It basically boils down to the following code: int foo(int bar) { int return_value = 0; if (!do_something( bar )) { goto error_1; } if (!init_stuff( bar )) { goto error_2; ...
Hi all, I know that #defines etc. are normally never indented. Why? I'm working in some code at the moment which has a horrible mixture of #defines, #ifdefs, #elses, #endifs, #etc. All these often mixed in with normal C code. The non-indenting of the #defines makes them hard to read. And the mixture of indented code with non-indented...
If the area pointed to was moved, a free(ptr) is done. Can you please explain the above line about realloc()? This line is from a man page for calloc, malloc, realloc and free. ...
Hello, I seem to be having a very frustrating time with an inherited class calling an explicit superclass constructor. I just can't seem to get the syntax right! All the examples I have seen on the matter so far do not separate out the header and in-line class definition (using {}'s) from forward-declarations with a header file, so I'...
Sorry, I'm sure this is simple but I'm tired and can't figure it out. I have an array of elements, each element is in fact a particle which is a data structure (a struct in c) containing, among other things the particles current position (int x,y,z). I want to compare the elements x position not just the element itself. Looking at the...