636 Posted Topics

Member Avatar for SamarthWiz
Member Avatar for ktsangop

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 …

Member Avatar for ktsangop
0
391
Member Avatar for smmcfarl

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.

Member Avatar for raptr_dflo
0
449
Member Avatar for iamthesgt

You forgot to [ICODE]chdir(strPathname.c_str())[/ICODE] The logfile is created, but in the wrong place.

Member Avatar for iamthesgt
0
401
Member Avatar for ajayb

[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.

Member Avatar for Ancient Dragon
0
109
Member Avatar for FALL3N

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]

Member Avatar for FALL3N
0
207
Member Avatar for maybnxtseasn

[QUOTE=sfuo;1669920]If you compile that code the 2nd one is wrong.[/QUOTE] Care to elaborate?

Member Avatar for Narue
0
83
Member Avatar for guidely

> 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).

Member Avatar for guidely
0
4K
Member Avatar for mikecolistro

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]

Member Avatar for nezachem
0
306
Member Avatar for LevyDee

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.

Member Avatar for LevyDee
0
205
Member Avatar for BobTheLob

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)\" …

Member Avatar for BobTheLob
0
173
Member Avatar for johnnyboyslim

Looping [ICODE]while(!data.eof())[/ICODE] is incorrect. It causes one extra (unwanted) read, which in your case leads to a classic buffer overflow.

Member Avatar for johnnyboyslim
0
93
Member Avatar for Reverend Jim

MouseEvent (you are talking mouse events, right?) has methods AltDown(), ControlDown(), ShiftDown(), MetaDown()...

Member Avatar for Reverend Jim
0
169
Member Avatar for NV43

> 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) + …

Member Avatar for nezachem
0
167
Member Avatar for JoshuaBurleson

Yes, to remove a widget you'd do widget.grid_forget(). May we see the failing code (specifically, what is self in that context)?

Member Avatar for JoshuaBurleson
0
30K
Member Avatar for vedro-compota

I am afraid you've misunderstood. The code is plain C. No porting effort required. Except maybe an olbanic case in the comment.

Member Avatar for vedro-compota
0
338
Member Avatar for PapaGeek

It is disabled by default. Enable it with [ICODE]fsutil behavior set disablelastaccess 0[/ICODE] at the command prompt (as administrator of course)

Member Avatar for PapaGeek
0
160
Member Avatar for coding101

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?

Member Avatar for Mouche
0
131
Member Avatar for Majestics

[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?

Member Avatar for nezachem
0
264
Member Avatar for trejorchest
Member Avatar for trejorchest
0
224
Member Avatar for Leaningnew

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]

Member Avatar for nezachem
0
77
Member Avatar for OblibSystems

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 …

Member Avatar for sergent
0
391
Member Avatar for mrjillberth

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; …

Member Avatar for mrjillberth
0
2K
Member Avatar for neoj88

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.

Member Avatar for neoj88
0
147
Member Avatar for BobTheLob

[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 …

Member Avatar for BobTheLob
0
837
Member Avatar for marirs07

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].

Member Avatar for marirs07
0
3K
Member Avatar for mx tommy
Member Avatar for SakuraPink

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] …

Member Avatar for SakuraPink
0
240
Member Avatar for minimi

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.

Member Avatar for minimi
0
247
Member Avatar for Labdabeta

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 …

Member Avatar for BCBTP
0
127
Member Avatar for roisterguy

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.

Member Avatar for roisterguy
0
227
Member Avatar for coding101

> 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...

Member Avatar for thekashyap
0
156
Member Avatar for Labdabeta

[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 - …

Member Avatar for murnesty
0
99
Member Avatar for sheepdogg09

> 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?

Member Avatar for nezachem
0
114
Member Avatar for N1GHTS

[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 …

Member Avatar for N1GHTS
0
152
Member Avatar for aFg3
Member Avatar for Mouche
0
152
Member Avatar for asrockw7

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]

Member Avatar for Moschops
0
163
Member Avatar for Jamblaster

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.

Member Avatar for rubberman
0
493
Member Avatar for geojia

[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 …

Member Avatar for nezachem
0
108
Member Avatar for gihanbw

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].

Member Avatar for gihanbw
0
471
Member Avatar for jiapei100

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 …

Member Avatar for griswolf
0
282
Member Avatar for Adak

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 …

Member Avatar for Adak
-1
124
Member Avatar for .:Pudge:.

The segfault is due to the % at line 61. Escape it as %%num. To change directory, use chdir().

Member Avatar for nezachem
0
206
Member Avatar for SCass2010

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.

Member Avatar for SCass2010
0
251
Member Avatar for AndreiM

Please show us what you have, then we may try to direct you towards your goal.

Member Avatar for AndreiM
0
138
Member Avatar for pseudorandom21

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.

Member Avatar for Narue
0
80
Member Avatar for ccao

Did you try [URL="http://developer.nvidia.com/category/zone/cuda-zone"]CUDA[/URL]?

Member Avatar for ChaseRLewis
0
198
Member Avatar for matanking

[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 …

Member Avatar for matanking
0
104
Member Avatar for Tauren

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 …

Member Avatar for nezachem
0
214
Member Avatar for Tauren

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.

Member Avatar for nezachem
0
143

The End.