636 Posted Topics

Member Avatar for keicola

First of all, both arrays must have the same size - they represent the same tree, so they have exactly as many elements as there are nodes in the tree. No need to test both sizes. Second, in the terminating situation you should return NULL, not the root. Third, there …

Member Avatar for keicola
0
202
Member Avatar for speedofdark

Line 48: [CODE] node *newnode;[/CODE] node is just a pointer, which points nothing in particular. Trying to dereference it may result in any strange consequences imaginable. You need to initialize it with [CODE] node *newnode = new node();[/CODE] Regarding a temp nodes in other functions, you should initialize them as …

Member Avatar for speedofdark
0
221
Member Avatar for Mr68360

[B]> Would a "sparse" check of just those file descriptors (using a set iterator) in the set be ok to use?[/B] Absolutely OK.

Member Avatar for nezachem
0
246
Member Avatar for sjones1025

The url3 has too many % signs. The %20e sequence tries to format an argument as a floating point into 20 characters. Change stray %s into %%s: [ICODE]Authority%%20eq%%20'%s'&$inlinecount[/ICODE]

Member Avatar for sjones1025
0
106
Member Avatar for gaurav.pruthi88
Member Avatar for beejay321

Arguments for strcmp must be terminated with 0. Your wordone and wordtwo are not: they are arrays of 4 characters, and all four are filled up with input. The trailing garbage they have is different thus causing strcmp to report inequality.

Member Avatar for Moschops
0
228
Member Avatar for Duki

Please post some more details: - How does it crash? - Does the executable have debug information? - Do you have sources? - What does [ICODE]ulimit -c[/ICODE] report?

Member Avatar for nezachem
0
106
Member Avatar for Xytheron

The code you suggested leads to the race with a high chance of a deadlock: [CODE] write(fd[WRITE_END], write_msg, strlen(write_msg) + 1); while (read(fd[READ_END], (char*)&ch, sizeof(char)), ch != '\n') { ... }[/CODE] Here the parent would immediately read back whatever it just wrote, eventually leaving both processes hung at the read(). …

Member Avatar for charlybones
0
208
Member Avatar for Phil++
Member Avatar for threwup

[B]> So I was wondering if I am doing this right?[/B] Certainly not. The mux has 8 data inputs, and 3 control inputs. Remember that the 3 bits of control represent a number from 0 to 7. The number is the index of the input which should be copied to …

Member Avatar for threwup
0
2K
Member Avatar for eline83

Another hint: take the differences of your sequence (that is, f(n) - f(n - 1)). You will see the pattern very clearly.

Member Avatar for mike_2000_17
0
109
Member Avatar for becool007

[B]> Pragma once is suppose to help, no?[/B] No. Pragma once only helps against multiple inclusions into the same translation unit (read, same .cpp file), that is, at the compilation time. Your situation is different: Average Calculator.cpp and PaintHandler.cpp both independently include Average Calculator.h; they are both independently compiled, and …

Member Avatar for becool007
0
371
Member Avatar for realproskater

Line 95: you are copying an original array on top of what you just calculated. You want it other way around.

Member Avatar for alexchen
0
6K
Member Avatar for rockerjhr

[B]> why the compiler(gcc) outputs a warning[/B] Because your main is (correctly) declared as returning int, but does not actually return anything.

Member Avatar for nezachem
0
219
Member Avatar for ThatGuy2244

Read the documentation carefully. You manage to violate practically all restrictions for the out instruction: [CODE]out Output (write) to port Syntax: out op, AL out op, AX op: 8-bit immediate or DX Action: If source is AL, write byte in AL to 8-bit port op. If source is AX, write …

Member Avatar for ThatGuy2244
0
807
Member Avatar for TheDestroyer
Member Avatar for fab2

The variable is just some (named) piece of a computer memory. It always has a value. Before you assign something to it, the value is garbage: useless, unpredictable, yet a value. This is why initialization is so important. Fix your program by initializing: [CODE]int smallest = INT_MAX;[/CODE]

Member Avatar for anirudh33
0
111
Member Avatar for CPT

Few problems here. First, there's only one struct employee allocated (line 4), and would be written over and over with each new record. Second, I said "would be" above, because &emp in the fread is wrong; it should be just emp. Can you see the difference? Third, it is very …

Member Avatar for nezachem
0
147
Member Avatar for moroccanplaya

The semicolon at line 15 means that the code actually is [CODE]while (( n = fread(buffer,1,sizeof buffer, original_pointer)) > 0) /* Do nothing */ ; /* End of loop */ { fwrite(buffer,1, n , copy_pointer)[/CODE] and fwrite is called once, after the loop finished, with n equal to -1. Also, …

Member Avatar for moroccanplaya
0
112
Member Avatar for bleedi

Your server closes new_socket after each message it receives. Your client, on the other hand, sends all its messages over the same socket. That is, the second message is sent through the socket which is already closed. Therefore, the crash. Rethink your design. Either let the client reestablish connection for …

Member Avatar for nezachem
0
209
Member Avatar for moroccanplaya

[B]> Try to open it for reading. If it opens, it exists. [/B] This approach suffers an inherent race condition. Moreover, in most cases (including this) such test is redundant. Both windows and posix systems provide an atomic solution to the OP problem. For windows it is CreateFile with the …

Member Avatar for WaltP
0
268
Member Avatar for scrivomcdivo

This is just one of the issues, and you are definitely made a correct move. Now, the 'c' object in c.execute() is undefined (you have conn, you have cursor, but what is c?). The fact that python doesn't complain means that the c.execute line is never actually executed. It means …

Member Avatar for nezachem
0
113
Member Avatar for Newbi1984
Member Avatar for nezachem
0
928
Member Avatar for arshi9464

Typo correction: a 16-bit register may contain data in the range of 0..65535; 255 is a maximal value of an 8-bit register.

Member Avatar for nezachem
0
99
Member Avatar for Dizzzy
Member Avatar for NicAx64
0
266
Member Avatar for Reverend Jim

The standard recommendation is to replace all the windows style paths with cygwin paths, such as /cygdrive/d/FRODAN/whatever. make dropped support for windows style paths since at least 2006.

Member Avatar for nezachem
0
4K
Member Avatar for prvnkmr194

You don't want to deal with interrupts, unless you are in an OS-less environment. For Windows, read [URL="http://www.codeproject.com/KB/system/HwDetect.aspx"]this[/URL].

Member Avatar for prvnkmr194
0
107
Member Avatar for Allasso

It is very important to understand that an application and the kernel reside in different address spaces. It means, among other things, that the application possibly cannot call anything in the kernel; the only way to "call" it is through the syscall mechanism, which essentially is the interrupt. This answers …

Member Avatar for Allasso
0
181
Member Avatar for VernonDozier

Here's a fairly crazy proposal: Pipe your files through [ICODE]sed -e 's/^#include/INCLUDE'[/ICODE] prior to gcc -E, and then back through [ICODE]sed -e 's/^INCLUDE/#include/'[/ICODE] (all that assuming that you don't want to expand any of your includes, and no line in your code begins with INCLUDE; in any case, the sed …

Member Avatar for VernonDozier
0
174
Member Avatar for vedro-compota

1. The compiler sees the call to getdet at line 4. It has to assume something about this symbol. The assumption is that it is a function returning int. At line 6 it sees that getdet is a function returning a pointer. This mismatches its previous assumption. Warning is emitted. …

Member Avatar for vedro-compota
0
188
Member Avatar for Don_k

Few problems here. 1. Design problems. 1.1 You declare the function as void, yet in some cases return a value. Make up your mind (should I write a function like this, I'd declare it int and return the file descriptor). 1.2 The function opens just one file; therefore it needs …

Member Avatar for nezachem
0
148
Member Avatar for kuchick32

[B]> I calculated that this function gives the number of sequence that sums to a number n[/B] I seriously [URL="http://en.wikipedia.org/wiki/Partition_%28number_theory%29"]doubt[/URL] that.

Member Avatar for frogboy77
0
132
Member Avatar for Kirielson

Always test the return values of the system calls. In this case, is ShmID valid? What is errno after shmget? What is errno after shmat?

Member Avatar for Kirielson
0
160
Member Avatar for abarkwith

[URL="http://dell9.ma.utexas.edu/cgi-bin/man-cgi?inotify+7"]inotify[/URL] is what you are looking for.

Member Avatar for nezachem
0
58
Member Avatar for Fbody

[B]would something like this be better?[/B] A step in the right direction, for sure. In the updated version you can easily identify the Factory, and factor it out, for example: [CODE]int main() { while(true) { subsystem = Subsystem::open(); subsystem.execute(); delete subsystem; } }[/CODE] The static open() method deals with the …

Member Avatar for Fbody
0
161
Member Avatar for darkbreaker

I agree that the code is not polished. I disagree though with the proposed "encapsulation of ifs". Your approach requires 25 comparisons for each non-accented letter - just to leave it alone. Really wasteful, isn't it? Consider a redesign based on a lookup table. Such table indexed by the original …

Member Avatar for darkbreaker
0
138
Member Avatar for Annettest
Member Avatar for VasquezPL
Member Avatar for yuri1969

Closing the listening socket is a right way to go. Then accept() returns -1 and sets errno to EBADF, as you already observed. You just need some more logic in the "threading stuff" to analyze what have actually happened. For example, test not_ended: if it is false, you know for …

Member Avatar for yuri1969
0
5K
Member Avatar for letaki

[ICODE]char args[7][50][/ICODE] and [ICODE]char * args[7][/ICODE] are completely different creatures. The former is an array of 7*50 characters, while the latter is an array of 7 pointers. A function [ICODE]foo[/ICODE] taking [ICODE]char args[7][50][/ICODE] would have have a signature[ICODE]foo(char[][50])[/ICODE]; it is vital to know the width of such array to work …

Member Avatar for nezachem
0
1K
Member Avatar for baldwindc

Search this forum for why using eof() is not a right way to control the read loop. [CODE]do { mystream.getline(line, 100); mystream >> country_name >> happiness_value; total_happiness = total_happiness + happiness_value; count++; outputstream << country_name << " \t \t " << happiness_value << endl; } while (!mystream.eof());[/CODE] In short, to …

Member Avatar for baldwindc
0
1K
Member Avatar for a-humam

You did it backwards. msgctl copies data from the buf to the kernel space. So, you need to modify BUF with the desired values, and then call msgctl. Keep in mind that BUF as it is contains garbage. Before any other operations fill it up with the correct values via …

Member Avatar for a-humam
0
146
Member Avatar for vinitmittal2008

In the circular queue you may not rely on relative head and tail positions. You must keep track of the number of elements manually. Extend the struct queue with an int count initialized to 0. Increment it on every enqueue and decrement on every dequeue operations. Rewrite is_empty and is_full …

Member Avatar for vinitmittal2008
0
2K
Member Avatar for greenman78

[B]> of maybe using pointers[/B] Wouldn't help. A compiler is smart enough to do that for you. In fact, any code-level optimization will gain you very little. Looks like you are multiplying matrices. Strasser algorithm is a way to go.

Member Avatar for stokes1900
0
114
Member Avatar for rafi1082

The problem is with parent closing the write ends too early, so that the corresponding file descriptor is reused in the next pipe() call; bottom line is, at the read() time parent attempts to read from the closed descriptor. Comment out lines 28-29 and see for yourself. PS: always test …

Member Avatar for rafi1082
0
130
Member Avatar for Wumbate
Member Avatar for nezachem
0
37
Member Avatar for BadPointer

firstnode never changes. AddToList is passed the _value_ of firstnode (which is NULL), and operates on the local variable. Upon return, firstnode remains NULL. You have to either pass an address of firstnode, [CODE]void AddToList(LankadLista ** listaptr, char name[]) { ... *listaptr = newnode; ... } main() { ... AddToList(&firstnode, …

Member Avatar for BadPointer
0
108
Member Avatar for polygon

It is important to realize that the child process cannot possibly affect the parent's environment. When you run the command from the executable file, a second copy of bash is forked, it has its environment changed and then dies leaving no trace. The builtins (dot and source for example) are …

Member Avatar for vaibhav1983
0
513
Member Avatar for ItecKid

Most likely, it is dying at line 32. You have to allocate writable memory for the whole backup filename.

Member Avatar for ItecKid
0
2K
Member Avatar for ItecKid

The entry returned by readdir is statically allocated. That is, you end up with only one instance of it, and all the pointers in the files array will have the same value. You need to hold each d_name individually: replace line 41 with [CODE]files[count] = strdup(entry->d_name);[/CODE]

Member Avatar for nezachem
0
109

The End.