389 Posted Topics

Member Avatar for gobiking

If you just write `int sum` or `int sub`, you'd be using those variables uninitialized in your loop, which would invoke undefined behavior. So don't do that. Your while loop will run until `value` is either equal to `'q'` or `'Q'`. This will only happen if the user enters 113 …

Member Avatar for gobiking
0
226
Member Avatar for asaidi

> `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable) Do you have one of the runtimes listed at the URL installed? If not, that's your problem. You need to install one of them. If you do have one of them installed, it …

Member Avatar for sepp2k
0
335
Member Avatar for Violet_82

No, it's perfectly fine to write `if(variable1 && variable2)`. What makes you think that doesn't work?

Member Avatar for Violet_82
0
194
Member Avatar for Vasthor

Making a local variable `static` means that it will remember its value between multiple calls of the same function. It does not mean that other function can access that function. A variable that is defined within one function can't be accessed from other functions (at least not directly - it's …

Member Avatar for sepp2k
0
230
Member Avatar for Labdabeta

if (desired-options[i]>0.0) You never check whether `desired - options[i] == 0`. You should push the item on the vector and return 0 in that case. PS: Is there a specific reason that you're using `0.0` and not just `0`? I realize you want the code to work with all types …

Member Avatar for Labdabeta
1
212
Member Avatar for TexasJr

When defining template functions or member functions of template classes, you can't put the definitions in a separate file from the declaration. Both the declaration and the definition need to be visible to the code that uses your functions. So you need to put the contents of Dynqueue.cpp into Dynqueue.h …

Member Avatar for TexasJr
0
2K
Member Avatar for christopher.north.520125

> Alternatively, you can add a request for input at the end of your program to force the process from terminating until input is provided. But he already did that: input("\n\nPress the enter key to exit.")

Member Avatar for vegaseat
0
116
Member Avatar for shanki himanshu

Maybe the question says something about the array ending with a specific number? Like the last element of the array might be 0 or -1? In that case you can find out the size of the array by going through the array until you encounter that number. Or possibly it …

Member Avatar for shanki himanshu
0
379
Member Avatar for Suzie999

u_char * newdata[raw_len] C++ does not allow variable length arrays, that is when declaring an array like this, the length must be a constant. So `raw_len` is not allowed as the length. There is no standard way to create arrays of unknown size on the stack. However some C++ compilers …

Member Avatar for Suzie999
0
103
Member Avatar for Vasthor

The error message is saying that you specified the default value for `find_words` both in the declaration and the definition of the function. You're only supposed to do it in the declaration.

Member Avatar for Vasthor
0
434
Member Avatar for Faith.Moraa

The items sys.argv are strings. So if the user gives 949 as the argument, code will be the string `'949'`, not the number `949`. Since `==` does not automatically convert between different types, `949 == '949'` will be false -- only `'949' == '949'` would be true. So if you …

Member Avatar for Schol-R-LEA
0
142
Member Avatar for treasure2387

Even if you could define methods within methods, why would you expect Fnction to become a static method of the Stuff class? The definition is not inside the Stuff class - not even indirectly.

Member Avatar for ddanbe
0
177
Member Avatar for debasishgang7

One way to do it would be to use `re.sub` with a function argument. That function could increase a counter every time it's called and then either return the given string unchanged or return the replacement string depending on whether the counter is equal to your n.

Member Avatar for bumsfeld
0
6K
Member Avatar for NidhiSree

> Your second example just catches one specific exception. It catches all exceptions that are a subclass of `Exception`. Since every exception is a subclass of `Exception`, that means it catches all exceptions -- just like the first one.

Member Avatar for Ketsuekiame
0
251
Member Avatar for gmorcan

You came across what error? If you're getting an error message, please post it. If your code acts differently than you want it to, please explain what you expect and in what way it acts differently. PS: Using `return` inside a for loop like you're doing, will likely not do …

Member Avatar for woooee
0
265
Member Avatar for lewisrs89

You defined your methods using the names Area and Perimeter with a capital A and P respectively. You tried to call them as area and perimeter with a lower case a and p. Since Python is case sensitive, that does not work. Also: If you want to call a function …

Member Avatar for bumsfeld
0
1K
Member Avatar for alexamicaa

Maybe it would be more fruitful to attempt to learn Python rather than hoping that someone will do your homework for you (spoiler alert: noone will). PS: Please don't post the same question on [multiple][1] [sites][2] on the internet at the same time. It's against the rules here and it's …

Member Avatar for sepp2k
-2
667
Member Avatar for saurabh.mehta.33234

You're invoking undefined behavior, the output could be anything (notably gcc will produce different output with -O1 than with -O2). It is highly unlikely that your compiler writes a specific byte sequence into bytes used for padding. Rather I'd expect it simply leaves them untouched, so they will just have …

Member Avatar for saurabh.mehta.33234
-1
125
Member Avatar for hayate98
Re: Else

`%c` reads any character, including whitespace. So since you still have a space or newline in the buffer from the last scanf, it will just read that. If you use the format string " %c" with a space in front of the `%c`, it will discard all whitespace before it …

Member Avatar for hayate98
0
174
Member Avatar for nmakes

It means "Text means a character array of size 80", yes. There's no such thing as an array of typedefs because typedefs are a compile-time concept only - they're not something that can be stored in arrays. The syntax of a `typedef` is basically the same as that of a …

Member Avatar for deceptikon
0
579
Member Avatar for prem2

What do you mean by "oops"? I assume the oop part stands for Object Oriented Programming. What does the s stand for? Anyway object oriented programming in Ruby isn't fundamentally different than in other languages, though obviously the fact that Ruby is dynamically typed and otherwise also very dynamic makes …

Member Avatar for sepp2k
0
127
Member Avatar for saurabh.mehta.33234

Each Animal object has an instance variable named `a`. Every time a new Animal object is created, its `e` variable is initialized to `new Animal()`, which creates a new Animal object. So every time you create a new Animal object, you create another Animal object. So if you create one …

Member Avatar for saurabh.mehta.33234
0
140
Member Avatar for clouds_n_things
Member Avatar for krystosan

In Python (and many other languages) there is a difference between changing variables and changing objects. A statement of the form `myvar = new_value` will change the variable `myvar`. Most other things that you can do with `myvar` (like `myvar[i] = foo` or `myvar.append(bar)`) will change the object, not the …

Member Avatar for Lardmeister
0
210
Member Avatar for terabyte

> Many string functions seem to work without the null byte... is it necessary to add it all the time? Which functions are you talking about specifically? If the function takes a size as an argument or only reads up to a certain delimiter in the string that's guaranteed to …

Member Avatar for deceptikon
0
143
Member Avatar for terabyte

It's always incorrect to use a pointer *that doesn't point to valid memory* to do anything at all. It's perfectly correct to take a pointer that points to valid memory containing a 0-terminated sequence of characters and pass that to a function that expects a string.

Member Avatar for sepp2k
0
117
Member Avatar for alex910TN

The compiler doesn't recognize `Node` until after the typedef has been fully parsed. So you can't use the typedef inside the struct. In order to write a recursive struct, you'll need to name your struct without `typedef` and use that name in the struct. struct node { struct node* next; …

Member Avatar for cproger
0
253
Member Avatar for johnny0627

The line `dice1, dice2, dice3 = numb(dice)` does not appear in the code you've posted, so I think you accidentally posted the wrong code. Assuming that the definition of `numb` that you gave in the code you've posted is the same one that you use in your real code and …

Member Avatar for woooee
0
212
Member Avatar for saurabh.mehta.33234

If you're declaring a variable with `extern`, it must have external linkage. This means it can't be `static`. It is not possible to forward-declare a static variable. So your only option are to not make it static or to put the definition at the top of the file and get …

Member Avatar for saurabh.mehta.33234
0
312
Member Avatar for woooee

What exactly were you trying to measure here? If you just wanted to measure the cost of lookups, wouldn't it have made more sense to just measure a function that makes a bunch of lookups in an already-built list or dictionary without measuring the time it takes to build the …

Member Avatar for sepp2k
1
205
Member Avatar for sai.aleenus

Using which library? Or if that's part of the question: for which operating system?

Member Avatar for Echo89
0
241
Member Avatar for filxy

As the error indicates those names are not declared at the point where you use them. In C++, the declaration of any identifier generally must come before its use. So if you want to use InitScanner and ScanOneToken on lines 43 and 44, you need to declare them before then. …

Member Avatar for sepp2k
0
291
Member Avatar for tshukela.george

Why are you trying to boot from CD 5? I would expect that CD 1 is the boot CD and CD 5 is not.

Member Avatar for sepp2k
0
258
Member Avatar for GeneClaude

You should be getting a warning on line 19 telling you that you gave two pointers to scanf, but your format string only contains one specifier. If you didn't get that warning, you should increase the warnings level of your compiler.

Member Avatar for Nutster
0
440
Member Avatar for tayyabatiq

No, you can't do this - . and ' aren't overloadable operators. You can overload & for AND and ! for NOT though (and make OR | while you're at it). That way the operators are also consistent with those of the builtin bool type. PS: How exactly do you …

Member Avatar for Nutster
0
264
Member Avatar for cthornton71

Do you want to know how to concatenate a string and an integer using +? If so: by converting the integer to a string first. That might look like this: s = "foo" x = 42 foo42 = s + str(x) That said using `format` might be better than using …

Member Avatar for IIM
0
86
Member Avatar for burcinerek

The + operator associates left to right, so when you write `"A+B= "+a+b` that's parsed as `("A+B= "+a)+b`. `"A+B= "+5` is `"A+B= 5"` and `"A+B= 5"+7` is `"A+B= 57"`, so that's the result. You need to add 5 to 7 first and then add the result to the string. To …

Member Avatar for sepp2k
0
155
Member Avatar for Frensi

In Python 2 the / operator returns an integer if both operands are integers - rounding the result down if necessary. So 3/2 would be 1 in Python 2. In Python 3 this behavior has been changed, so that / always returns a float even if both operands are integers. …

Member Avatar for sepp2k
0
11K
Member Avatar for SoreComet

You seem to think that if the end of file is reached, fscanf will store EOF in the given variable. It won't - it will simply keep the variable unchanged. The only way to tell whether fscanf successfully read a value is to check the return value of fscanf - …

Member Avatar for SoreComet
0
365
Member Avatar for Navlag

> What happens when you add an element to a vector that is already at capacity? The capacity is increased (often doubled, but that's up to the implementation), new storage is allocated with the given capacity and the contents of the vector are copied to the new storage. > Does …

Member Avatar for Ancient Dragon
0
215
Member Avatar for jalpesh_007

Yes, you can use class files from different directories by adding all the directories to your classpath. If you're using an IDE, you can do so in your project's settings. If you're compiling from the command line, you can use the -classpath switch or the CLASSPATH environment variable to set …

Member Avatar for sepp2k
0
355
Member Avatar for Aaron_JY

Variables that are declared inside a method will always go out of scope at the end of that method. You don't need to do anything special to make it that way.

Member Avatar for sepp2k
0
113
Member Avatar for SeePlusPlus2

The distinction between O, Theta and Omega isn't about best- versus worst-case. You can use any of these notations to analyze any case you want. That is, the statements "QuickSort's worst case is in Theta(n^2)" and "QuickSort's best case is in Theta(n log n)" are both valid usages of Theta. …

Member Avatar for sepp2k
0
233
Member Avatar for arupface

Here's one example of a class variable being used at the top level of the class definition: class MyClass @@number_of_instances = 0 def self.number_of_instances @@number_of_instances end def initialize @@number_of_instances += 1 end end As you can see, the class variable `@@number_of_instances` is used in 3 places here: it is read …

Member Avatar for sepp2k
0
195
Member Avatar for Kunj123

Scheme already has a function named `append`, which takes multiple lists as arguments and returns the concatenation of all the lists. So you should name your function something else, like `append-element` perhaps. You can define your function by simply using the existing `append` function to concatenate the list you want …

Member Avatar for sepp2k
0
124
Member Avatar for sparsh610_1

The reason that your numbers look the same when you print them is that by default printf rounds the number to 6 decimal places. If you use something like `%.20f`, you'll see that your two numbers really look something like this: float=3.09999990463256835938 double=3.10000000000000008882 So you see that the two numbers …

Member Avatar for sepp2k
0
229
Member Avatar for arupface

You can not change the superclass of a class after it has been defined. That's just not possible. If you just asked out of curiosity, that's basically all there is to say. However if you asked because you have a specific problem that you think could be solved by changing …

Member Avatar for sepp2k
0
215
Member Avatar for Jacklittle01
Member Avatar for gtsreddy

> Bowls made by the Mayans and by the Sumerians still work today (if found intact). [..] are they better than the bowls actually made today? They're certainly a lot more expensive, so I can only assume they must be better.

Member Avatar for vijayan121
0
718
Member Avatar for steven.myers.3726

The first two lines don't load anything. You'd need a load instruction for that. They simply perform pointer arithmetic. The first line makes `$t0` point to the fifth *byte* of the A array. If A is an array of 32-bit values, that means that `$t0` points to the second element …

Member Avatar for sepp2k
0
794

The End.