FAQ Database Discussion Community

C - Why compare constants with & instead of switch/if?

I am reading the OpenSL documentation for Android. Quoting the following document: http://mobilepearls.com/labs/native-android-api/ndk/docs/opensles/ "Callback handlers should be prepared to be called more or less frequently, to receive additional event types, and should ignore event types that they do not recognize. Callbacks that are configured with an event mask of enabled...

About Function Pointer in C++

Do these lines mean the same? Both works without any warning messages! int (*pFunc)() = func1; // I learned this is right. int (*pFunc)() = &func1; // Works well with an ampersand too. Why do I have to put an ampersand in this case? Without it, doesn't work! int...

php file_get_contents($url) & turns into &

I am trying to make a request to the coinbase api like this $url = "https://api.exchange.coinbase.com/products/BTC-USD/candles?start=".date($format,$starting_date)."&end=".date($format,$ending_date)."&granularity=".$granularity; and then I pass that in file_get_contents($url) but it gives me an error file_get_contents(https://api.exchange.coinbase.com/products/BTC-USD/candles?start=2015-05-07&end=2015-05-08&granularity=900): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request. the problem ofcourse...

Which is the proper & in a string?

I have an image I am referring to in HTML5. It's name is "atmosphere-&-meteorology". When I refer to the , both atmosphere-&-meteorology and atmosphere-&-meteorology show up fine for me. Which way is proper?

How do I get the current folder in NodeJS for a Browserify'd file that relies on a base file in another folder?

I'm using AmpersandJS and I'm trying to emulate the pod structure of Ember so that, instead of the typical folders-per-type structure: app |-- views |-- index.js |-- login.js |-- people.js |-- templates |-- index.jade |-- login.jade |-- people.jade you have folders-per-component instead: app |-- index |-- view.js |-- template.jade |--...

Why is shortcut with `map` not working? [closed]

The two lines in this code: p ["9", "6", "4"] p %w(9 6 4) return exactly the same array ["9", "6", "4"]. But the first line with map: p ["9", "6", "4"].map(&:to_i) works fine, and the second one: p %w(9 6 4).map{&:to_i} gives: syntax error, unexpected & p %w(9 6...

Functions with pointer arguments in C++

I'm having some difficulties in understanding some aspects of functions with pointers. Here is the code I'm running: #include <iostream> using namespace std; class Item { public: Item(Item * it) { data = it->data; } Item(int d) { data = d; } void printData() { cout << data << endl;...

C++ return bool with && in return statement - need clarification

I'm not entirely sure what happens in this process and what the outcome would be. I've never come across using && in a return or especially a single one in the same return statement. bool myfunction(unsigned int x) { return x && !(x & (x­ - 1)); } I'd love...