636 Posted Topics
Re: Stare at lines 52 and 87 of symbol.cpp until an enlightenment descends on you. | |
Re: To compile individual files you have to either write an individual rule for each object, or use a generic rule as [CODE]%.o: %.c $(CC) $(CFLAGS) -o $@ $<[/CODE] (refer to [I]automatic variables[/I] chapter in [ICODE]info make[/ICODE] for the meaning of @ and <). Put this rule in place of lines … | |
Re: [CODE]#include <stddef.h> ... * (int *) (((char *) sptr) + offsetof(struct mys, value)) = 1234;[/CODE] | |
Re: man fstat. Study the st_mode field. | |
Re: [QUOTE=rubberman;1522376]When you run into that problem, you will discover that you have 10K lines of code to fix... Be safe. Read the ANSI/ISO C++ standard. They are very clear on this point.[/QUOTE] Chapter and verse, please? 18.1-3 totally contradicts to what you say. | |
Re: [CODE] cin>> cn; int M [cn][cn];[/CODE] Don't do that, ever. Unfortunately it may work - but in fact you cannot initialize an array of unknown size like that. Even if the above worked, you are using [CODE]cn+1[/CODE] as loop limit. That is, the last time around, the loop counter is … | |
Re: Lines 163 and 190 don't do what you want them to do. Besides, the way you set up your constructors, the _subject is uninitialized. | |
Re: [B]> Can anyone explain me what I'm doing wrong?[/B] Sure. [B]> If I call display after destroy, the display continues showing the data after the second node.[/B] Question is, what do you expect? After destroy, an access to the list invokes an undefined behaviour. That is, once the list is … | |
Re: [QUOTE=Ancient Dragon;1519883]the return value of malloc could not be typecast as char* because that it the wrong type.[/QUOTE] Confused as always. malloc returns [ICODE]void *[/ICODE], which of course [B]can[/B] be typecasted to anything. As for the original question: [B]I run the code and the O/p is 10.[/B] Try to run … | |
Re: There is a Makefile. All you need to do is to type [ICODE]make windows[/ICODE] or [ICODE]make linux[/ICODE] (depending on what system you are on) at the command line. | |
Re: The copyright on MET claims 2001. No wonders. There's no such thing as iostream.h anymore. It is obsoleted. Your options are: 1. Find some fairly old compiler (they say gcc version 2.95 works... good luck with it) 2. Audit the code and get it up to the standard 3. Dump … | |
Re: >> CAn we trust wikipedia ? > No. Can we trust DaniWeb? The top 100 posters (that's [B]0.1%[/B] of the population) contributed 365917 posts (that's [B]25%[/B] of the post count). An estimated contribution of the next hundred is at least 100000. PS: The [URL="http://www.daniweb.com/certificates/stats.php"]statistics[/URL] page gives the top hundred. Is … | |
Re: [B]> That ends the debate. [/B] Well, as programmers we must realize that the debate never ends. Besides, neither approach looks pythonic enough to me. Since you already have the performance test set up, could you add the following? [CODE]def loop(text): def looper(t): while True: for c in t: yield … | |
Re: There are several problems with this code. 1. The producer locks the queue for much too long. The mutex can be safely released right after the queue entry is unlinked. In fact you make your producers to run sequentially, and since the file IO is a very time consuming operation, … | |
Re: Get rid of [CODE]#include "quicksort.c"[/CODE] | |
Re: You are calling pop() twice. Replace lines 182-185 with [CODE] temp = pop(s); if(temp == NULL) return;[/CODE] | |
Re: [CODE] pthread_create(&th[i], NULL, func_sort, (void*)arg1);[/CODE] You pass the same argument to all threads. Remember, that threads are running in the common address space, so a single copy of arg1 is shared among them. You need to create distinct individual arguments for each thread. | |
Re: The only problem with the java implementation is that (besides being overdesigned) it wouldn't work in the OP situation: [I]the bounds t to infinity[/I]. | |
Re: pthread_cond_timedwait() is a usual solution. | |
Re: A missing separator usually means that the rule line doesn't start with the tab. Make sure that there's no empty line between the dependency and the rule, and that the rule is indented with the tab - spaces do not work. | |
Re: [URL="http://support.microsoft.com/kb/828801"]Excel statistical functions: TREND[/URL] [INDENT]The TREND(known_y's, known_x's, new_x's, constant) function is used to perform Linear Regression. A least squares criterion is used and TREND tries to find the best fit under that criterion.[/INDENT] Is that what you are looking for? | |
Re: Two immediate questions: 1. Why do you think it should work properly? 2. What makes you think it doesn't? First question implies the environment (true 8088 vs emulation; where 6000h came from; interrupt state, clock frequency). The second implies, how do you measure the actual delay. | |
Re: [B]> Some compilers, such as GCC, automatically initialize integers to 0[/B] Correction. No compiler initialize an auto variable to anything. Every compiler initialize static variables to 0 (this is mandated by the Standard). [B]> issue a warning [/B] At a proper warning level GCC will issue a warning as well. | |
Re: In your second script the N command does join a current pattern space with the next line; however the s command causes the (updated) pattern space to be printed out. Essentially, you join pairs of lines. My recommendation would be to use a hold buffer, and careful addressing like this: … | |
Re: [B]> lets say the number is 110001000100 and n is 2...[/B] ... so after the shift it becomes 111100010001, and you need to get rid of the 2 leading ones, right? Hint: what happens if you shift 100000000000 right by one (that is, by n - 1)? I didn't see … | |
Re: Two problems with the code. An immediate and major one is that [CODE] char writefile[1000000];[/CODE] attempt to allocate one million characters (that is one megabyte) on the stack. The stack is a very limited resource. For example, Windows by default gives one megabyte for the whole stack, and by the … | |
Re: Add fflush() right after fprintf(). Quoting man fsetpos: [INDENT]The fsetpos() function shall fail if, either the stream is unbuffered or the stream's buffer needed to be flushed, and the call to fsetpos() causes an underlying lseek() or write() to be invoked[/INDENT] | |
Re: [B]> Am I doing it wrong?[/B] Yes. Initialize vg once for the m you need. To get a random number, instead of rand()%m just call vg(). | |
Re: Hint: You don't need to calculate hexagonal numbers. You just need to test if a given number is hexagonal. In other words, find out if the equation [B]x*(2*x - 1) = P(i)[/B] has integer roots. | |
Re: To be precise: start() is not an interface method for Runnable. It is a Thread method. Invoking thread.start() results in spawning the thread and executing the Runnable's run() method in it. Since you are not extending Thread (which I wouldn't recommend to do), the call at line 68 does not … | |
Re: [B]> changing the size of the array[/B] This is right. In your original code you were trying to allocate 4 megabytes of data on the stack. The default stack size is 1 meg. | |
Re: [B]> Everything posted is fine.[/B] You sure? [CODE] int grade1 = 0; char grade1 = 'A'; // this is where it fails [/CODE] | |
Re: [B]> But which character has the ASCII value of 0XFF is -1[/B] The stream you are reading is not necessarily textual. getchar() must read any data. | |
Re: [CODE]printf("%d %d %d\n",a=10,a=20,a=30);[/CODE] [B]> expression statements separated by commas[/B] This is not a comma expression - this is an argument list. They look very similar, but they are really different creatures (think about this: the comma expression yields just one value). In the argument list case there's no guarantee in … | |
Re: The most immediate problem is on lines 14 and 28; the local definition of catalogue shadows the global definition (didn't you get a compiler warning?). I am not sure what exactly happens, but it is pretty much possible that you sort one array, and print another. For example, appendEntry surely … | |
Re: os.walk returns the filenames without the path prefix. That is, you are trying to open them in the current directory, where they do not exist. change line 7 to [CODE] f = open(os.path.join(subdir, file), 'r')[/CODE] PS: your variable names are misleading. | |
Re: [B]> are outside the definition of tokens[/B] No. The Standard defines token as either of: [INDENT]keyword identifier constant string-literal punctuator[/INDENT] and punctuator in turn is either of [INDENT][ ] ( ) { } . -> ++ -- & * + - ~ ! / % << >> < > <= … | |
Re: At line 10 you open a file as prompted. At line 16 you immediately discard the result and open another file, which name is given as a command line argument. Which one do you really want? PS: if the command line has no arguments, the result is pretty much undefined. | |
Re: Sorry if I sound too US-centric. In the USofA, nothing is legally certain unless the judge rules on it. The GPL has been tried several times in the court of law, but each case yet has been settled. No ruling has been produced. That is, nobody knows what exactly does … | |
Re: Sorry, you are all wrong. You may have as many mains as you want, provided they are all static (except one, of course). I am not even talking about dll tricks. > there is nothing like a good test Not for the questions like this. Language is defined not by … | |
Re: > All of the 32bit tutorials Looks like you missed [URL="http://en.skelix.org/skelixos/tutorial02.php"]this[/URL], which accidentally comes first on a [U]protected mode screen access[/U] google search. | |
Re: // this appears to be causing the trouble No. It is line 9. The error message points to line 17. There you call read with no arguments, while the definition of ReadIn.read requires one. | |
Re: [CODE]int input(worker_t *); ... worker_t foo; input(&foo); ... worker_t employee[10]; input(&employee[5]); input(employee + 5);[/CODE] | |
Re: [B]My question is why do we even need AtomicInteger.[/B] It is not about mutability. An Atomic prefix suggests that its methods are sefe in the multithreaded environment without additional synchronization. | |
Re: [B]> if it contains a loop, i.e is a circular linked list[/B] Not exactly. The loop not necessarily includes the head (consider 1->2->3->2). In that case your algorithm will run forever. The solution takes two pointers traversing the list with different "speeds": [CODE]pointer1 <- head pointer2 <- head do: pointer1 … | |
Re: Try perror instead of printf. That will give you a more hintful error message. | |
Re: Code tags! [CODE]org $4000 Alph equ 26 26 Alphabets begin: lea LC,A0 store lowercase to A0 lea UC,A1 store uppercase to A1 move.b #Alph,d1 sub.b #1,d1 loop: move.b (A0)+,d0 convert LC to UC sub.b #32,d0 move.b d0,(A1)+ dbra d0,loop goes back to loop move.b #9,d0 TRAP #15 org $4100 LC … | |
Re: [B]> I don't see why the function has to be so complicated..[/B] Mostly because it reverses [I]characters[/I] in the string, not the [I]words[/I]. But it is a good start. Once the characters are reversed, you can apply the same function to each individual word, and reach the goal. | |
Re: [B]> gives error that undefined reference "exp"[/B] Including math.h is not enough. You need to link with the actual math library. How exactly do that depends on your compiler. Check the documentation. | |
Re: Call GetLastError() and display it with FormatMessage(). That will give you textual explanation of why "Attempt to bind failed". Besides that, the port value in sockaddr should be in the network byte order. Use htons() (or a whatever winsock provides for that matter). sin_addr is also conventionally assigned via interface … |
The End.