636 Posted Topics
Re: Settings, line 7. Looks like a typo in the username. | |
Re: This is a quite unusual way to serve connections. You don't need to shutdown a listening socket; the same one will accept new connections as many times as you want: [CODE] listen(serverSocket, 1); while(1) { clientSocket = accept(serverSocket, 0, 0); do_stuff(clientSocket); shutdown(clientSocket, SD_BOTH); closeSocket(clientSocket); }[/CODE] In your code, after the … | |
Re: Run your program in a debugger. It will show you exactly where the segfault occurs, along with the function call sequence which lead to it. Usually it is more than enough to pinpoint the problem. | |
Re: You forgot to [ICODE]chdir(strPathname.c_str())[/ICODE] The logfile is created, but in the wrong place. | |
Re: [QUOTE=Ancient Dragon;1670700]My guess is that a semaphore is just a system DWORD since all it does is count from 0 to some maximum value. See [URL="http://msdn.microsoft.com/en-us/library/windows/desktop/ms685129(v=vs.85).aspx"]this link[/URL][/QUOTE] I seriously doubt that. | |
Re: What system is this? Also, can you quote more context from the man page? Because normally to get a modtime one would call [CODE]stat '%Y' filename[/CODE] | |
Re: [QUOTE=sfuo;1669920]If you compile that code the 2nd one is wrong.[/QUOTE] Care to elaborate? | |
Re: > Change [ICODE]sizeof(*s)[/ICODE] to [ICODE]sizeof(struct ship)[/ICODE] Care to elaborate what difference woud it make? To OP: The problem is that sort() parameters are [ICODE]struct ship *[/ICODE] (disguised as void *), while you treat them as [ICODE]struct ship **[/ICODE] (notice the double indirection). | |
Re: In the inner loop [CODE] while (wait1 < endwait) {[/CODE] (lines 113 to 147) neither wait1 nor endwait ever change. You have to structure the loop similar to the outer one: [CODE] outer_loop_stop_time = clock() + outer_loop_run_time; while(clock() < outer_loop_stop_time) { inner_loop_stop_time = clock() + inner_loop_run_time; while(clock() < inner_loop_run_time) {[/CODE] | |
Re: Few notes: 1. Child's stdout has been redirected to the pipe (line 21), hence don't expect anything on console. 2. Redirection (line 22) causes child to read from the writable end of the pipe. | |
![]() | Re: The [ICODE]SUBDIRS[/ICODE] variable contains a space. From make point of view, the line [CODE]make -C /lib/modules/2.6.38-8-generic/build SUBDIRS=/home/andrew/Documents/OS_Projects/Chapter 6 modules[/CODE] means that [ICODE]SUBDIRS=/home/andrew/Documents/OS_Projects/Chapter[/ICODE], while [ICODE]6[/ICODE] and [ICODE]modules[/ICODE] are targets to make. You may either rename your directory to Chapter_6, or change your makefile to something like [CODE] $(MAKE) -C $(KDIR) SUBDIRS=\"$(PWD)\" … ![]() |
Re: Looping [ICODE]while(!data.eof())[/ICODE] is incorrect. It causes one extra (unwanted) read, which in your case leads to a classic buffer overflow. | |
Re: MouseEvent (you are talking mouse events, right?) has methods AltDown(), ControlDown(), ShiftDown(), MetaDown()... | |
Re: > I do not think it is properly computing the sum. Yes. But it has nothing to do with threads. The way you joining the threads means that nothing is running concurrently. Essentially you are calling sroot 3 times in a row, as in [CODE]sum = sroot(n/3) + sroot(2*n/3) + … | |
Re: Yes, to remove a widget you'd do widget.grid_forget(). May we see the failing code (specifically, what is self in that context)? | |
Re: I am afraid you've misunderstood. The code is plain C. No porting effort required. Except maybe an olbanic case in the comment. | |
Re: It is disabled by default. Enable it with [ICODE]fsutil behavior set disablelastaccess 0[/ICODE] at the command prompt (as administrator of course) | |
Re: Just for fun, do [ICODE]touch bin[/ICODE], and then run [ICODE]./a.out /[/ICODE] again. See that stat doesn't fail on [ICODE]bin[/ICODE] anymore, yet it is presented as a plain file. Can you explain this observation? ![]() | |
Re: [QUOTE=Majestics;1662665]How can we access hard disk addresses from c language, accessing ram address is easy? Also can we access MBR of NTFS through c , just a bit dissusion required for starting my work? Thank You All in Advance.....[/QUOTE] It is very much OS specific. What exactly are you after? | |
Re: Lines 50 vs 87-92. Make up your mind on bool vs char contents of Board[][]. | |
Re: To be precise, an error must occur before any conversion took place. Errors in question are numerous. For a posix system, you may want to read an ERRORS section of [URL="http://www.opengroup.org/sud/sud1/xsh/fscanf.htm"]man fscanf[/URL] | |
Re: My recommendation is to sort of forget the [I]most common and effective languages used in industry[/I] part, and study languages which represent the extremes of different programming models. It really gives a perspective on what software engineering is about. One possible set includes C, Forth, Haskel, Java, Lisp, Python, and … | |
Re: Notice that the blocks of code at lines 30-71 and 72-113 are nearly identical. The only difference is that "*" and "o" are swapped. Create a method [ICODE]doMove(String title, String self, String other)[/ICODE], and use it as [CODE] for(;;) { if(team) { doMove(name, "* ", "o "); team = false; … | |
Re: Run your program in a debugger. Set a breakpoint at line 32. Inspect the value of avgScore. Get surprised. Figure out why it is so. If you don't know how to use a debugger, print avgScore after line 31. | |
![]() | Re: [QUOTE=BobTheLob;1656640]Hey guys. I'm working on a project where a parent process forks two children (so Process A is parent to both Process B and Process C). I need the children to write to the pipe so that the parent can see it. When I make a simple one child pipe … ![]() |
Re: There is no solution with just functions. You need a macro, very similar in fact to [URL="http://en.wikipedia.org/wiki/Offsetof"]offsetof[/URL]. | |
Re: At lines 49-50, why do you index matches with i? | |
Re: Depends on how the executable (which you refer to as cpp) expects the input: 1. It reads the filename: [CODE]echo file1.xml | ./a.out > 3d-1.xml[/CODE] 2. It reads the contents of a file: [CODE]./a.out < file1.xml > 3d-1.xml[/CODE] 3. It takes a filename as an argument: [CODE]./a.out file1.xml > 3d-1.xml[/CODE] … | |
Re: At line 41, you always comparing t against s[1...], no matter how deep you are in the enclosing loop. If the string has a pattern at position 1, you'll match it many timers. Otherwise, you'll never match it. In other words, initialization [ICODE]j=1[/ICODE] is wrong. | |
Re: To correct a confusion: math.h is a header. A library (that is, implementation) is libm.so in unix world, and something similar in windows. You may inspect the source code of libm by looking at the [URL="http://www.netlib.org/fdlibm/"]netlib[/URL] e.g. (which is pretty standard implementation). Maybe you will figure out how to optimize … | |
Re: Nothing in the assignment says that you have to print them as decimals. Just print them as hex. You may want to clarify it with your professor though. | |
Re: > I don't know of a way to get notifications when someone enters it Monitor the parent directory. Entering the target directory modifies atime, so watching for IN_ATTRIB pretty much accomplishes the task. PS: of course, nobody knows [I]who[/I] did the access... | |
Re: [QUOTE=StuXYZ;1648694]I have a nice little bit of OLD code that I use to count the number of bits, and I have adapted the idea. [Note I didn't write the original idea of using 0333 and 0111, but I do not know who did]. [code=c++] unsigned int uCount = MyInt - … | |
Re: > The issue being, I can't find any info on the bc/dc utilities Did you try typing [ICODE]info dc[/ICODE] (and/or [ICODE]info bc[/ICODE]) at the command prompt? | |
Re: [QUOTE=N1GHTS;1648056] When this library is loaded by the host application at runtime and this function is called, is the returned pointer pointing to some place in RAM or to the binary file on disk?[/QUOTE] Pointers do not point places in RAM. The are pointing into the address space of the … | |
Re: [QUOTE=aFg3;1647649]got many issues[/QUOTE] So what are the issues? ![]() | |
Re: Check out [URL="http://eathena-project.googlecode.com/svn/trunk/src/common/core.c"]http://eathena-project.googlecode.com/svn/trunk/src/common/core.c[/URL]. Also notice how [ICODE]core.o[/ICODE] is get linked ([URL="http://eathena-project.googlecode.com/svn/trunk/src/char/Makefile.in"]http://eathena-project.googlecode.com/svn/trunk/src/char/Makefile.in[/URL]): [CODE]COMMON_OBJ = ../common/obj_all/core.o (and a bunch more common objects) ... char-server: obj_txt $(CHAR_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @CC@ @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @LIBS@[/CODE] | |
Re: Unions is a poor man's way to express the idea of polymorphism. See for example a definition of [URL="//http://linux.die.net/man/3/xevent"]X Windows event[/URL] and related API. | |
Re: [CODE]struct VALUE * new_VALUE(char type, char *value){ ... val->VALUE=value; ... }; struct llist * l_insert_H(struct llist *ls, char type, char * value, int status) { ... struct VALUE *val; val= new_VALUE(type, value); ... }; main (int argc, char *argv[]) { ... TKN Token; ... }[/CODE] You have only one instance … | |
Re: The compiler aligns BITMAPHEADER at a 4-byte boundary. Since MAGIC occupies only 2 bytes, the compiler (when laying out the image structure) inserts 2 bytes of padding between [ICODE]magic[/ICODE] and [ICODE]head[/ICODE]. | |
Re: Something similar to [CODE]for filename in *; do mv $filename `echo $filename | iconv -f UTF8 -t ANSI`; done[/CODE] Warning: the above will fail badly if the filenames contain spaces. Tweak accordingly. Test with echo instead of mv first. PS: I am not sure that ANSI is a correct encoding … | |
Re: Just do the same math: In any case, guests * cost_of_chicken must be spent. The rest, that is budget - guests * cost_of_chicken may be used to pay an excess price of steak, that is price_of_stake - price_of_chicken. steaks = (budget - guests * cost_of_chicken) / (price_of_stake - price_of_chicken) Am … | |
Re: The segfault is due to the % at line 61. Escape it as %%num. To change directory, use chdir(). | |
Re: Since you are on a Posix system, the best practice would be to adhere to [URL="http://linux.die.net/man/3/getopt"]getopt()[/URL]. It's a part of libc; no extra libraries involved. | |
Re: Please show us what you have, then we may try to direct you towards your goal. | |
Re: 1. Download and install a [URL="http://msdn.microsoft.com/en-us/windows/hardware/gg454508"]WDK[/URL]. 2. Study the documentation and samples. 3. Find a datasheet for the device you want to drive. After that a driver for a mouse-class device is a matter of one week. | |
Re: Did you try [URL="http://developer.nvidia.com/category/zone/cuda-zone"]CUDA[/URL]? | |
Re: [QUOTE=raptr_dflo;1632284]I took a quick look, and as far as I can tell, your program can't get past line 33 because the only way out of your while loop is via system("exit") (which I didn't even think about until just now, and appears to kill off the CommandPrompt that your program … | |
Re: The [URL="http://msdn.microsoft.com/en-us/library/aa379924%28v=vs.85%29.aspx"]MSDN[/URL] is very clear: the data buffer is an in/out parameter, that is [quote]The plaintext in this buffer is overwritten with the ciphertext created by this function.[/quote] Your pointer is pointing to a read-only string literal. Besides, keep in mind that a ciphertext may take more space than the … | |
Re: PKC is inherently slow. If performance is an issue, you may want to consider hybrid approach. Use PKC at the handshake phase, to securely exchange session keys. Then encrypt the payload with a symmetric algorithm. |
The End.