All Questions

794 votes
13 answers
320k views

When to use single quotes, double quotes, and backticks in MySQL

I am trying to learn the best way to write queries. I also understand the importance of being consistent. Until now, I have randomly used single quotes, double quotes, and backticks without any real ...
Nate's user avatar
  • 27.5k
175 votes
2 answers
28k views

What is a debugger and how can it help me diagnose problems?

This is intended to be a general-purpose question to assist new programmers who have a problem with a program, but who do not know how to use a debugger to diagnose the cause of the problem. This ...
Raedwald's user avatar
  • 48k
2317 votes
32 answers
478k views

How do you parse and process HTML/XML in PHP?

How can one parse HTML/XML and extract information from it?
234 votes
3 answers
42k views

How to use ThreeTenABP in Android Project

I'm using Android Studio 2.1.2 and my Java setup is the following: >java -version > openjdk version "1.8.0_91" > OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~15.10....
kael's user avatar
  • 6,675
695 votes
5 answers
99k views

Why is iostream::eof inside a loop condition (i.e. `while (!stream.eof())`) considered wrong?

I just found a comment in this answer saying that using iostream::eof in a loop condition is "almost certainly wrong". I generally use something like while(cin>>n) - which I guess implicitly ...
MAK's user avatar
  • 26.5k
556 votes
18 answers
269k views

How do I create variable variables?

I know that some other languages, such as PHP, support a concept of "variable variable names" - that is, the contents of a string can be used as part of a variable name. I heard that this is ...
user avatar
760 votes
22 answers
1.1m views

Asking the user for input until they give a valid response

I am writing a program that accepts user input. #note: Python 2.7 users should use `raw_input`, the equivalent of 3.X's `input` age = int(input("Please enter your age: ")) if age >= 18: ...
849 votes
31 answers
569k views

How to test multiple variables for equality against a single value?

I'm trying to make a function that will compare multiple variables to an integer and output a string of three letters. I was wondering if there was a way to translate this into Python. So say: x = 0 y ...
user1877442's user avatar
  • 8,681
680 votes
6 answers
297k views

Why is “while( !feof(file) )” always wrong?

What is wrong with using feof() to control a read loop? For example: #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char *path = "stdin"; FILE ...
William Pursell's user avatar
572 votes
3 answers
58k views

What is the difference between client-side and server-side programming?

I have this code: <script type="text/javascript"> var foo = 'bar'; <?php file_put_contents('foo.txt', ' + foo + '); ?> var baz = <?php echo 42; ?>; ...
deceze's user avatar
  • 518k
2540 votes
8 answers
387k views

What is The Rule of Three?

What does copying an object mean? What are the copy constructor and the copy assignment operator? When do I need to declare them myself? How can I prevent my objects from being copied?
fredoverflow's user avatar
957 votes
19 answers
80k views

List of lists changes reflected across sublists unexpectedly

I created a list of lists: >>> xs = [[1] * 4] * 3 >>> print(xs) [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]] Then, I changed one of the innermost values: >>> xs[0][0] = 5 >...
Charles Anderson's user avatar
361 votes
25 answers
1.0m views

What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?

What does ArrayIndexOutOfBoundsException mean and how do I get rid of it? Here is a code sample that triggers the exception: String[] names = { "tom", "bob", "harry" }; for (int i = 0; i <= ...
Aaron's user avatar
  • 11.6k
1496 votes
22 answers
468k views

How does the "this" keyword work, and when should it be used?

I am looking to find a clear explanation of what the "this" keyword does, and how to use it correctly. It seems to behave strangely, and I don't fully understand why. How does this work and ...
Maxim Gershkovich's user avatar
4611 votes
38 answers
3.1m views

How slicing in Python works

How does Python's slice notation work? That is: when I write code like a[x:y:z], a[:], a[::2] etc., how can I understand which elements end up in the slice? See Why are slice and range upper-bound ...
Simon's user avatar
  • 80.1k

15 30 50 per page