1,359 Posted Topics
Re: Actually, the simplest solution is to use a `static` local variable: int call_counter() { static int count = 0; return ++count; } | |
Re: Conceptually, a [string](http://en.wikipedia.org/wiki/String_(computer_science)) is an object that holds a piece of written text. The name 'string' is historical, and refers to the concept of ['string rewriting'](http://en.wikipedia.org/wiki/Semi-Thue_system), a mathematical technique for analyzing sentences in an abstract grammar; the intended mental image is of pieces of paper held together by a (physical) … | |
Re: Unfortunately, Moschops is right. Assembly language by its very nature isn't particularly friendly, and x86 assembly specifically is rather gruesome. The best you can really do is get a good IDE such as [RadASM](http://radasm.cherrytree.at/radasm/), [WinAsm](http://www.winasm.net/), [AsmEdit](https://sourceforge.net/projects/assemblyedit/) or [EasyCode](http://www.easycode.cat/English/index.htm), which lessens the severity of it somewhat. For the sort of work … | |
Re: ALso, the reason there is no `main()` method is simple: the program is written as an applet (a web-based program meant to be run in a browser) rather than a stand-alone application - something you would know if you were the original author of the program. I am assuming you … | |
Re: As an aside, I noticed that you have posted to both here ande [DevShed](http://forums.devshed.com/python-programming-11/python-loop-problem-946257.html) with the same problem. FYI, cross-posting is generally frowned upon, as it leads to duplication of effort. You should only post to one forum at a time, and only re-post elsewhere if you think you have … | |
Re: OK, since you don't mention what operating system you are running under, I will have to assume you are using Windows, though the answer for Linux and MacOS are more or less the same anyway. With Windows, the only Java compiler of importance is the one from Oracle themselves; under … | |
Re: As an aside: given that you are always allocating the same amount of memory for each of the arrays, and you never `free()` them, is it really necessary to use dynamic allocation for the arrays? What I mean is, with the code as it is now, you could just as … | |
Re: A minor point unrelated to the question: the `cout` object and it's selectors only found in C++, not C. | |
Re: Can you please show us what you have trid so far, and what problems you are having? | |
Re: There are a number of problems with this code, but the most important is that there is a syntax error in the increment part of the inner `for()` loop. for(j=65;j<=i;j++;count++) As things stand, this code shouldn't compile; the third semi-colon should be just a comma. for(j=65;j<=i;j++,count++) This isn't the cause … | |
Re: A few notes: * You should always declare the `main()` function as type `int`, and return a value at the end of it. While some compilers do allow you to declare `void main()`, it is non-standard and non-portable. Don't do it. * The `<conio.h>` header and the functions it declares … | |
Re: Finding a number's cube is simply a matter of multiplying it by itself three times: double cube(double x) { return x * x * x; } Are you sure you didn't mean the [cube root](https://duckduckgo.com/?q=newton%27s+method+cube+root)? | |
Re: **ajike**: Are you certain that the box you are trying to connect to has a telnet server running, and that port 23 isn't being blocked by the firewall on either system? Most system installations disable telnet by default these days, because of security concerns. | |
Re: One piece of advice I can give is that, whenever you find yourself using several variables of the form name*N*, consider refactoring them as an array or an `ArrayList`. The `hang0`, `hang1`, `hang2`,... `hang10` variables in particular stand out as something where a number of things would be simplified if … | |
Re: It's even better than that, actually; it is clear that the OP didn't even transcribe the questions correctly, as most of them are clearly incomplete. | |
Re: Given the sort of questions these are, there isn't much advice we can give that wouldn't constitute answering the questions. | |
Re: The reason it isn't working is because the condition in the `if:` statement is incorrect. When you write if first == "a" or "e" or "i" or "o" or "u": ... what it is really saying is if (first == "a") or ("e") or ("i") or ("o") or ("u"): That … | |
![]() | Re: With suitable libraries to draw on, you can write most types of programs in Python, except for really low-level systems work (device drivers and so forth). The biggest disadvantage over C isn't in what you can or cannot do with it, so much as how fast the program is likely … |
![]() | Re: Would you please post what you've done so far? Without being able to see the code, it would be difficult if not impossible to give you any advice. ![]() |
Re: Just how you would do that would depend on the compiler, and possibly on the development environment you are using as well. Do you have a compiler chosen already, or are you looking to get one? If you have a compiler already, do you have an editor or Integrated Development … | |
Re: In what way isn't it working? Does it fail to compile? Do you get any error or warning messages? Does it run and crash? Does it give the wrong values? We really need more details in your initial post in order to help you. BTW, two things you should know. … | |
![]() | Re: Well, for a design document, I suppose it's a start. You would need a *lot* more detail, however, even before you could consider writing any actual code. If your actual goal is to write a photo editing program, well, that's about as complex as any project you could have chosen. … |
Re: I'm afraid we'll need more information than just the assignment statement. Is there anything in particular that confuses you? * Do you know how to use multiple source and header files? * Do you know what a pointer is, and how to use one? * Do you know how to … | |
Re: OK, I'm puzzled about that myself, but not for the same reason. At this point in the function, the variable `temperaturef` doesn't have any set value, which means it should be giving a `NameError` exception instead, like this: NameError: name 'temperaturef' is not defined Instead, it is acting as if … | |
Re: Well, the good news is, a certain number of C++0x/C++11 features did make it into VS2010 and VS2012; the bas news is, constexprs weren't among them. A detailed explanation of which features are and aren't supported can be found [here](http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx). This leaves you with the prospect of using a different … | |
Re: Well, what you have to understand is that the braces aren't directly connected with the loop or conditional, *per se*; in fact, the control structures are actually defined as to accept the *one* statement immediately following the conditional. In [EBNF](https://duckduckgo.com/?q=extended+Backus-Naur+Form), it would be defined as: <if-statement> ::= 'if' '(' <conditional> … | |
Re: First off, in the future, when asking a question, please post a new thread of your own rather than resurrecting one from five years ago. Second off, the real question here is, what sort of hash function should you use? The fairly simple approach you mention (taking the modulo of … | |
Re: Oh, I see. Oh dear me. OK, then, I will start with the `if()` statement, as it is the easier of the two to understand. Basically, what an `if()` statement does is take a true or false value, and based on that value, select from one of two paths to … | |
Re: I would recommend starting with [BeautifulSoup](http://www.crummy.com/software/BeautifulSoup/), which is made for just such a purpose. | |
![]() | Re: I would, first off, recommend against using `scanf()` directly for this; since the input is by line, and of irregular size, I would instead read the data with `fgets()` and then apply `sscanf()` to the string after it has been read in. This should avoid the issue nicely, as you … ![]() |
Re: Standard, no, but it is [freely available](http://cs1graphics.org/) and appears to be reasonably well documented. Unfortunately, I'm short on time right now, or else I would dig into it a bit deeper; as it is, I'll try to get back to it later tonight, if I have the opportunity (though I … | |
Re: Part of the problem is that you are closing the output file inside the loop you are reading and writing in, which means you are no longer actually writing to the file after the first pass. But that's just the start of the problem. The problem is that you cannot … | |
Re: It would depend on just what you are doing, but generally speaking, you would have them in separate files. Keep in mind that you can only have a single public class in a file. | |
Re: First off, we don't do other people's homework for them. Second, we *don't* do other people's homework for them. And third, ***we don't do other people's homework for them***. Sensing a pattern here yet? No one here will simply hand you a solution on a silver platter. If you show … | |
Re: I believe I see where the problem lies. The *local variable* `ylop` is defined in main.c, inside the `main()` function, as a regular `char` variable. The problem is that the functions are being selected using conditional compilation, which is performed by the pre-processor, not the compiler *per se*. The thing … | |
Re: First off, I would say that this is different enough that you would have been better off creating a new thread, rather than posting in one several months old. Just for future reference. While I cannot say for certain without seeing the code, from the error message given it sounds … | |
Re: OK, perhaps we need to start over from scratch. What you need to understand is that an object is a model of something. It can be something real, like a car or a person, or something conceptual, like a list or a dictionary (I use those examples because, as it … | |
Re: I would start by considering how the chat protocol to use, whether it is one you have designed yourself, or an existing one such as [XMPP](http://xmpp.org/). While an existing protocol is likely to be much more elaborate than one you've worked out yourself, it would have the advantage that most … | |
Re: Technically, the `while()` loop is what is known as an 'indefinite iteration', which is to say that it repeats the body of the loop zero or more times, with the number of repetitions being unknown at the time the loop is begun. It repeats based on a condition which holds … | |
Re: **usy1010:** First off, you should never hijack an existing thread with an unrelated question. It is better to start a thread of your own. More importantly, to both you and the OP, you have to understand that DaniWeb is ***NOT*** a free-homework-solving service. Simply posting a question as you both … | |
Re: The answer to that is going to be entirely implementation-dependent, and the difference is probably negligible. Only by profiling can you get a definitive answer. The main cause of the difference probably will not be from the return per se, but from the need to pack and unpack the struct … | |
Re: As PyTony points out, the code as given does *not* use the [`zipfile` module](http://docs.python.org/2/library/zipfile.html), but rather calls on a separate program named 'zip' to perform the file operations. That is both unnecessary and non-portable. This is how it would work using the `zipfile` module: import zipfile zip = zipfile.ZipFile(target, 'w') … | |
Re: First off, you have to understand that no one here is going to write the program for you. This forum is for assisting programmers with projects, but we do not provide free homework solutions of the sort you seem to be looking for. In the forum rules, it states specifically: … | |
Re: > If you need to store large values (above 32,767 or below -32,767), use long. Actually, this range only applies to 16-bit compilers such as Turbo C. Pretty much all modern C compilers for Windows, Linux and MacOS use a 32-bit `int`, in which case the range of values will … | |
Re: First off, since you are manipulating them together, it may be a good idea to bundle the array and max together, along with the current size: struct people { struct person** data; int size, max; }; It is almost always better to separate the functions which manipulate data from the … | |
Re: You sholdn't need to; it is part of the standard Python library. I gather you were unable to use it? What version of Python are you using? What exactly happens if you enter the following into the Python interpreter prompt? import random random.randint(0, 6) | |
Re: The origina; post was from two months ago; it is safe to say that the 48 hour deadline has long since passed. :-p | |
Re: First off, let's get this code suitably indented, so that it is readable: #include <stdio.h> int main() { write(1,"salam",5); char a[2]; char b[5]; read(0,a,2); if(a[0]=='8') { write(1,"ok",2); read(0,b,5); write(1,"ok2",3); } return 0; } I know that for newcomers, this may make it look like modernist poetry of some sort, and … | |
Re: The easiest solution for this is to use a `vector` of `vector`s and let the library do the heavy lifting, but I assume that that isn't available to you for this assignment. If that is the case, then I'll walk you through what you'd need to do here. Declaring the … | |
Re: Basically, you would need to call the interrupt twice, once for each string you are printing. SECTION .text global _start _start: mov eax, 4 ;sys_write mov ebx, 1 ;output to screen mov ecx, string ;creates address for my string variable mov edx, length ;creates address for my length variable int … |
The End.