636 Posted Topics
Re: [QUOTE][CODE]#define FERMATH #if[COLOR="Red"][B]n[/B][/COLOR]def FERMATH class Fermat {...}[/CODE][/QUOTE] Your include guards are wrong. What happens here is that the code for class Fermat is only included if FERMATH is [B]not[/B] defined (and of course it is!). Swap the directives at the beginning of the file. | |
Re: You have to [ICODE]clear()[/ICODE] your stream. When the line ends with the last number, a corresponding extract hits the end of string, and the stream is in end-of-file condition. Calling str() does not clear it. | |
Re: He's comparing an int to a pointer at line 18. And assigning a pointer to an int at line 19. Changing double quotes to single quotes (at line 18 and 19) would help. | |
Re: [QUOTE]I've added the 'ofstream output' to the Print_Detail prototype. The error is that the call Print_Detail doesn't take 5 arguments. [/QUOTE] [QUOTE][CODE] input(lettercode, GPA); line 83 getting the error[/CODE][/QUOTE] No. The error is that [ICODE]input[/ICODE] is not a function of 2 arguments. In fact, it is not a function at … | |
Re: Irrelevant parts snipped: [QUOTE][CODE]bool enque(QUE *que, void *data) { .... newNode->data = data; ... } int main() { ... char *data; .... for(i = 0; i < strlen(infix); i++) { token = infix[i]; *data = token; enque(que, data); } ... }[/CODE][/QUOTE] The main() passes the same pointer in each call … | |
Re: How about [CODE] else if ( e % 2 == 1 ) { p = b*p; [COLOR="Red"]e -= 1;[/COLOR] }[/CODE] | |
Re: Probably, you want to [ICODE]print(value)[/ICODE] instead. PS: note that subprocess.call returns the exit status, not the output. You may want to redirect stdout. | |
Re: Is this a class for computer science, numerical analysis or math.phys.? In any case, the way the assignment is written, you'll need 2 10x10 arrays. Iterate over the "first" storing new estimates in the "second". Compare the "second" values to the "first" using a proper metrics to find out if … | |
Re: [QUOTE][CODE] scanf ("%d", A[i][j]);[/CODE][/QUOTE] This is what is wrong (hint: scanf needs an address to scan into). | |
Re: [QUOTE=Aia;1207959][CODE]*(unsigned int*)&recvline[0] = 11111; *(unsigned int*)&recvline[sizeof(unsigned int)] = 22222; /*this section*/ *(void(**)(void))&recvline[2 * sizeof(unsigned int)] = (void(*)(void))&myhello; /*this section*/[/CODE] Casting is not for l-value. Only for r-value.[/QUOTE] Correct, but not applicable. The result of cast, e.g. [ICODE](int *) foo[/ICODE], is not an lvalue, and cannot be assigned. [ICODE](int *) foo … | |
Re: [CODE]while(aux=read(sockfd, buffer, 16)!=0)[/CODE] is not doing what you expect it to do. Hint: it assigns aux a result of comparison. One side point: you should not use fgets and fputs (at least not as careless as you do). read and write are better suited for the task. Also, n server.c … | |
Re: This is a documented behaviour. FTP.dir() returns None. However, it calls a callback function for each line of the transfer. The default callback prints lines to stdout. You need to provide your own callback. | |
Re: Your code is notified (that is, OnReceive gets called) when it is safe to read. Then, Receive returning 0 means that the peer closed the connection. It may or may not indicate that the download completed. To make such conclusion you must look for the particular headers, primarily Content-Length, Connection, … | |
Re: [QUOTE]stack and queue are also not defined in the scope[/QUOTE] They should be std::stack and std::queue. [QUOTE]q and s are not defined in the scope[/QUOTE] Since stack and queue are not defined, the compiler cannot define s and q as well. The namespace resolution (above) should take care about it. | |
Re: Please explain lines 19 and 20. | |
![]() | Re: [QUOTE][CODE]for(int i = 0; i < 11; i++){[/CODE][/QUOTE] Why 11? |
Re: Your approach indeed doesn't work for non-integer exponents. It is just not applicable. Check out Taylor series, or some other approximation. | |
![]() | Re: [QUOTE]it is a char array[/QUOTE] You must realize that until you disclosed this vital piece of information all attempts to help were shots in the dark. Now you may try to go with a [CODE]union u { unsigned long SomeLongArray[2]; char SomeCharArray[8]; };[/CODE] which will force the alignment, and avoid … ![]() |
Re: [QUOTE=firstPerson;1194950]Trace it out. [code] //return T2(12) = 12*2 = 24 def dozen(): return T2('12') [/code] Split it up and analyze it.[/QUOTE] I bet you didn't. (Hint: [ICODE]T2('12')[/ICODE] returns [ICODE]'1212'[/ICODE] | |
Re: Clear ISIG and turn off a canonical mode: [CODE]options.c_lflag &= ~(ISIG | ICANON);[/CODE] PS: and please use code tags. | |
Re: One thing to add. A straightforward implementation of Taylor series, as in the post #3, quickly leads to numerical problems. A 32-bit integer cannot hold a factorial of numbers beyond 12, which essentially limits the series to the first six members (hence the line 54 of the original post). A … | |
Re: The code has two obvious problems. First, its time complexity is at best quadratic. Second, the randomness is not guaranteed. Given that there are linear algorithms with a true random results (see, for example, [URL="http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle"]shuffling[/URL]), I don't think that this code has any value. | |
Re: [QUOTE=Ancient Dragon;1192595]You can't make the return value of that function anything other than an integer. Why? Because they are not normal functions -- it acts more like a self-contained process than another function, except that threads have access to all global data in the entire program. So when a thread … | |
Re: [QUOTE=Extremus;1192778][B]System:[/B] Vista What I want to do is to catch the mouse release event, which I have researched for but nothing useful came up. I found out the way to catch the pressed event: What I want to use it for is to catch the time elapsed between the 'pressed' … | |
Re: I seriously doubt that what you are looking for exists. Your goal is achieved by a combination of an assembler, a simulator, and a debugger (the latter two are usually bundled together). You don't need to modify the simulator code. The process is to assemble your program, load it into … | |
Re: The return value of Parse method has nothing to do with what you return from the start_element handler. The latter, in fact, is ignored. To keep the parsed info, the handler should create an object to keep it, and store the object in the persistent collection. It is a fun … | |
Re: [QUOTE=warlock07;1180974]So here is the algorithm I am trying to design...i'm not sure it will make any sense. I have a sequence of n numbers(in ascending order). I have an another number 'x'. If i have 2 chances to compare x with a number greater than it but unlimited chances to … | |
Re: The heap got corrupted somewhere else. Looks like you are using arrays. Make sure there's no overruns, or any other writes beyond the allocated memory, or double deletes, etc, etc, etc. After you find the problem, dump arrays altogether and rewrite everything with vectors. | |
Re: If I understand your problem correctly, I'd just modify the protocol in a following way. Let the connected client, prior to anything else, wait for a "go ahead" from the server. Let the server count the accepted connections. Once the desired count is reached, let the server send that "go … | |
Re: [B]I want to know how my local static variable is in .data segment and my global static is in .bss specifically?[/B] One of them ends up in .data, because it is initialized. Another one ends up in .bss because it is not (or, rather, initialized by 0). [B]and what about … | |
Re: Separate reading digits and constructing a number. Something like [CODE]int get_noisy_digit() { int ch1, ch2; while((ch1 = getchar())!= EOF) { if(!IS_DIGIT(ch1)) continue; if((ch2 = getchar()) == ch1) return ch1; ungetc(ch2); } return EOF; }[/CODE] That said, I doubt the protocol is any good. | |
Re: [QUOTE=Gribouillis;1088552]A None value is not displayed by the python shell, as in this example [code=python] >>> value = None >>> value >>> [/code] [/QUOTE] [QUOTE=vegaseat;1088677]However this will work in the Python shell ... [code]>>> value = None >>> print(value) None >>> [/code]Looks like the old shell has tripped up a … | |
Re: [QUOTE=Dwarrel;1182125]Hi, i'm trying to learn some assembly, ive got a assignment from school to control a lcd screen. I've got some sample code that i mostly understand but i can't figure out what the SBI command does. Using atmega32, with avr studio 4 [CODE]sbi PortD, LCD_E[/CODE] At this point PortD … | |
Re: First of all, malloc does not take up a stack. The memory comes from the completely different area. Second, you have to realize that in modern OSes malloc only reserves a range of virtual addresses. A successful malloc does not guarantee that there would be enough physical memory by the … | |
Re: [QUOTE=craig_ka;1180002]Have you tried to do anything yet, I'd like to help but I won't do you program from start to finish. It looks like it could be solved using a 0-1 knapsack with slight modification for the heights changing as you pick. If you post some code you're working/stuck on … | |
Re: [QUOTE=Ancient Dragon;1180479]>>*(float*) variable = 34; It is typcasting [b]variable[/b] into a float *, then assigning the value 34 [B]to[/B] it. [/QUOTE] Correction: [B]through[/B] it. | |
Re: [QUOTE=johndoe444;1178009][CODE]find . -name 'my*' [/CODE] The quotes avoid the shell expansion - without them the shell would replace my* with the list of files whose names begin with my in the current directory. What thus the above statement mean? Isn't it doing the same thing I mean looking for file … | |
Re: [QUOTE=max.v8;1177993]just run loops to increment their counter[/QUOTE] So far so good. [QUOTE] that would be compared to the integers in the file, so it would be a typical code, like this: [code=c] // NOTE: dato is a pointer to a file for (x=1; x<=100;x++){ freq=0; for ( i=0; !feof( dato … | |
Re: [QUOTE=johndoe444;1177971]from wikipedia: 1. [CODE]find . -name "*.foo" -print0 | xargs -0 grep bar[/CODE] The above command uses GNU specific extensions to find and xargs to separate filenames using the null character; What is the null character? What is the significance of "separate filenames using the null character;"? why should we … | |
Re: [QUOTE=trantran;1161277] (Also note that the little face in the original example are created automatically by the blog software when I type colon colon asterisk (to indicate data pointer such as : ::*)[/QUOTE] You may consider using code tags, such as [ICODE]::*[/ICODE]. In fact, it is a requirement for this forum. | |
Re: Both snippets suffer the same problem. They do not update the one pointer (current->next->previous and current->previous->next respectively). The first snippet gives an impression of working because of the way you traverse the list. Try to traverse it in both directions and you will see the problem. | |
Re: [QUOTE=jephthah;1177175]yeah, i try not to jump between functions, this is just to get out of any single function cleanly in the case of a hardware error. i guess im just soliciting opinions between doing it the first way (with gotos) or the second (without). or another way i havent considered. … | |
Re: The code is not portable. It is very linux-specific. It uses termios, and it assumes that stdin is selectable. Another problem is that it doesn't test the select error code. When select returns -1, the fds is undefined, and kbhit would return garbage. Otherwise, it is a fairly standard way … | |
Re: I doubt you can significantly speed these calculations up by "normal" means. Take a look at SIMD (aka SSE) capabilities of your very good computer. | |
Re: [QUOTE=lionaneesh;1176969][CODE] printf("Enter word to add: "); fflush(stdin); fgets([COLOR="Red"]word[/COLOR],9,stdin); fflush(stdin); printf("Meaning : "); fflush(stdin); fgets([COLOR="Red"]word[/COLOR],9,stdin); add(word,meaning); [/CODE] what i m trying is to input is two character arrays :- 1. word 2. meaning 1. the program only inputs the meaning and not the word. [/QUOTE] You are reading into the same … | |
Re: [QUOTE=AngusFloydKAOS;1175337]Let me see if I can clarify what I want. I want to take a string of numbers (2009-0330) from c and basically have some script variable equal to the same numbers so I can then use these numbers in my script. Does that answer your question?[/QUOTE] Not really. Some … | |
Re: [QUOTE=josolanes;1176118] The following is a piece of my dateIOManip.h: [code=cpp] struct fullManip {}; ostream &operator << (ostream &out, fullPtr) { Date::Flags[&out] = "full"; return out; } [/code] -Josh[/QUOTE] Never ever put any definition with global linkage in the include file. An include file may contain only declarations. | |
Re: [QUOTE=BestJewSinceJC;1176256]I'm trying to write my own system calls. I have a .c file where I'm putting the system calls. My system calls use a struct, so I have declared a global variable that is an array of my struct. Lets just call it [CODE] //Stuff is the name of the … | |
Re: Did you look at [URL="http://en.wikipedia.org/wiki/Variadic_macro"]this[/URL]? | |
Re: I don't know what is wrong. You do. Does it not compile? does it crash at runtime? does it not produce the desired results? |
The End.