- Strength to Increase Rep
- +10
- Strength to Decrease Rep
- -2
- Upvotes Received
- 253
- Posts with Upvotes
- 194
- Upvoting Members
- 128
- Downvotes Received
- 12
- Posts with Downvotes
- 12
- Downvoting Members
- 5
389 Posted Topics
Re: If the user enters a number too large to fit into a long, LONG_MAX will be returned. If the user enters a number that's exactly LONG_MAX, LONG_MAX will also be returned. The first would be an error case, the second would not (in the case that `sizeof(int) == sizeof(long)` - … | |
Re: Which part of that assignment are you having trouble with? | |
Re: > Even if you make abc global, it still doesn't work in Visual Studio 2015 Because your function is returning a *copy* of abc and that copy is a temporary object that goes out of scope at the sequence point, just as deceptikon explained. > returnValue seems to point to … | |
Re: This has (hopefully) been answered here: http://www.dreamincode.net/forums/topic/398067-first-and-the-follow-compilers/ | |
Re: What you posted does not look like source code, it looks like what you might see when you open a binary file in a text editor. Presumably you downloaded the zcode file (which is a bytecode format), not the source code. I do not think the source code of Zork … | |
Re: Note that using a different extension won't prevent people from opening the file in a text editor. It'll just stop a text editor from being the default application that will open when you double click on it in your file manager (unless the user then selects a text editor as … | |
Re: > <for loop> ::= for ( <expression> ; <expression>; <expression> ) <statement> All three expressions in a for-statement are optional and from C99 onwards the first one may be a variable definition instead. Also note that the assignment specifically says that `<statement>` does not include composite statements (for whatever reason), … | |
Re: Using your first definition `account1.compareTo(account2)` will call `account2.name.compareTo(account1.name)` and using your second definition it will call `account1.name.compareTo(account2.name)`. So using the result of the comparisson will be the other way around and thus the sort order is reversed. | |
Re: This isn't what's causing your syntax error, but Java doesn't have a type named `sum` nor do you define one anywhere in your prorgram (unless you defined it in a different file that you didn't show), so `sum c` is a type error (both on line 7 and line 8). … | |
Re: The `>` operator is only defined for primitive types. To compare `Comparable` objects, use the `compateTo` method instead. | |
Re: It looks like the Ribbit class does not have a `userid=` method - presumably because you did not define one and the corresponding table does not have a `userid` column either. | |
Re: Any implementation will definitely *read* everything (well some languages have some kind of "stop here" token, which causes the impelementation to stop reading at that token, but in those case the stuff after would simply not be considered part of the program at all). Even if it did decide to … | |
Re: There's only a difference when you use the return value of the increment for something. So the two loops are completely equivalent. | |
Re: Please post a compilable and runnable piece of code that reproduces your problem. | |
Re: 2147483647 is the largest number that an int can store. When you convert it to float, it becomes 2147483648.0 due to floating point accuracies. When you convert that back to int, you'd get 2147483648, except that that's too large to fit into an int. So instead you get an overflow, … | |
Re: > In the program Why you used 0 in return 0 ; The return value of main is the program's exit code. If it is 0, that means that the program terminated successfully. A different return value means that the program failed. This distinction matters most in shell scripts: if … | |
Re: Your question seems to be missing some words. Did you mean "After returning true, does the for loop continue?" If so, the answer is no. When the return statement is reached, the control flow returns to the call site. | |
Re: When you don't specify the size of an array, the size is inferred from the initializer. So when you write `int arr[] = {1,2,3}`, that's the same as `int arr[3] = {1,2,3}`. Likewise `char formula[] = {'\0'}` is the same as `char formula[1] = {'\0'}` and equivalently `char fomula[] = … | |
Re: It'd have helped us if you had described in what way the code did not behave as expected, but your problem is that you access the matrix out of bounds (the matrix can hold 2x2 items, but you're trying to store 3x3). Also you're printing "1th" and "2th" when the … | |
Re: Syntax errors come with a line and column number as well as some indiciation of what's missing (or what's there that shouldn't be). So to find a syntax error you should look around the given line and column for anything that might fit the error message. If the message is … | |
Re: > I am not to properly understand why, and when we have to dynamic cast. Strictly speaking, you don't ever have to use `dynamic_cast`. You *can* use `dynamic_cast` when the castee is a pointer or reference to a class that contains at least one virtual member (that's what's meant by … | |
Re: If a file has never been added, it is untracked. Untracked files are not affected by anything you do with git (like switching branches). One way of looking at it is that, until you added the file, the file did not exist in any branch. Instead it existed in the … | |
Re: NP means a NTM can solve it in polynomial time (or equivelantly that a DTM can verify the result in polynomial time). Note that NP is a superset (possibly, but not necessarily, a proper superset) of P, meaning that everything in P is also in NP. A problem X being … | |
Re: > no instance of overloaded function "System::Console::WriteLine" matches the argument list argument types are: (const std::string) I've never used C++/CLI, but it looks like `std::string` is a distinct type from `System::String` and presumably `Console::WriteLine` only works with the latter as it is a .net method and `std::string` is a C++ … | |
Re: Whether you can parse each line individually depends on the language. I'd say in most languages, you'd need to parse the program as a whole. But yes, a simple (as in: non-JITing) interpreter generally consists of two phases: parsing and execution. > I suppose the code needs instructions on how … | |
Re: If you know how many elements you're going to add to the vector (or you at least have a reasonable upper bound), you can also use `reserve` to reserve the proper amount of memory up front, preventing reallocations. Then you'd have exactly one move constructor call per `push_back` and no … | |
Re: The `controller` variable is not defined within the `counter` method. You need to either pass it as a parameter or make it a member of the object (by doing `self.controller = controller` in the constructor) and then access it as `self.controller` instead. In the future please include any error messages … | |
Re: > Is {(1,1), (2,2), (3,3)} symmetric? transitive? Yes! Yes! Obviously I'm not your grader, but I'd expect that you need to give some explanation along with your answers to get a full score. Other than that you are correct. > Why is R = {(1,2), (2,3), (1,3), (2,1)} not transitive? … | |
Re: `gcc` produces a binary executable, not a shell script. To run it, type `./main.out`. | |
Re: No a char value can not be larger than what fits inside a char. However what getchar returns does not have to be a char value. It could also be EOF. Except for the missing `&`, your `scanf` line is perfectly fine. When `scanf` reaches the end of file (or … | |
Re: You need to `#include <stdio.h>` to get the declaration of `fopen`. As it is now you're implicitly declaring `fopen` in a way that is incompatible with its definition. You should be getting a warning about that (and in C99 and later you should instead be getting an error that you're … | |
Re: > Something else to consider, using the String.IndexOfAny method will shorten your code considerably And, perhaps more importantly, improve the runtime from being quadratic in the worst case to being linear (in the length of the string). | |
Re: You're right, that when you do `something = new Something();` that basically assigns a "very safe pointer" (a.k.a. reference) to `something`. In fact when you do `something = anything;`, you're assigning a reference. Also note that `x += y` is just a shortcut for `x = x + y;`. So … | |
Re: How long are the strings you enter? If the first string has more than 2 characters, your first call to `gets` overflows your array. Likewise your second call to `gets` overflows if the second string entered is `2 * sl` characters long or longer. Either way the call to `strcat` … | |
Re: > You're right and that 'variable' is the number of elements. That variable is whatever you say it is. In the context of computer science it's usually the size of the input, but it could be anything as long as you make that clear. For example it's very common to … | |
Re: > When I try to compile this program in gcc I get this error As the error message says, you need to supply the mentioned language options to make the code compile. Alternatively, if you want to make your code compile in C89 mode, you need to replace `char *p … | |
Re: Are you sure that that's the definition of `check` that's in scope when you call it? Do you perhaps have any other definitions of `check` in your program, perhaps even one that takes two arguments? In any case, it would help if you gave us a reproducible code sample of … | |
Re: You can't, you need a separate field (usually of an enum type) to keep track of which field of the union is set. | |
Re: > javac command not found in linux fedora Have you installed the JDK? > vi .bash_profile > export JAVA_HOME=/usr/bin/java JAVA_HOME should be a directory, not an executable, and you shouldn't have to set it yourself. > export PATH=$PATH:/usr/bin/java Again PATH should contain directories, not executables, and /usr/bin is already in … | |
Re: If you do make them variables, `dircopy $src $dst` will work fine. | |
Re: Learning Java on Arch Linux is no different than learning Java on any other system. You don't need an emulator - both the Oralce JDK and OpenJDK are available for Linux natively, as are all commonly used Java IDEs (eclipse, netbeans, IntelliJ). So your steps for learning Java would be: … | |
Re: > If static modifier is not applied before does it makes it an instance method ? Yes. | |
Re: You check the file size after you've already opened the file for writing. Since opening a file for writing creates an empty file with that name (overriding the existing file if it exists), this means that a) the file will always exist and b) it's size will always be 0. … | |
Re: Your joueur array holds only one element, but your index goes up to `1` (which would be the second element), which is out of bounds. | |
Re: To tell you where you went wrong, it'd be good to know how you got to ten. For each iteration of the outer while loop what's the value of `i` going in, what's the value of `j` after the inner while loop and what's the value of `i` after incrementing … | |
Re: > i can`t understand this code.... It stores the number `1` in the variable `dx` if the number stored in the variable `a1` is greater than that in the variable `c1` and the value stored in `b1` is larger than that in `a1`. | |
Re: Did you create the text file on Windows? If so, it probably uses `'\r\n'` as the line ending, so after stripping the `'\n'`, the passwords will end up as `'password\r'` and thus not compare equal to `'password'`. That would explain why the problem does not occur in Windows as Python … | |
Re: The third is almost certainly the fastest (and the second the second fastest) as it only iterates over a third of the array (and the second over half). However this also means that the third and second functions don't do what you intend. If they did, there would unlikely to … | |
Re: As NathanOliver said, "t6" isn't a char, it's a char array. To get 't' and '6', you can simply access them as `"t6"[0]` and `"t6"[1]` respectively. | |
Re: Also asked (and answered) [here](http://www.dreamincode.net/forums/topic/359353-strange-program-compiles/). |
The End.