[Solved] Creating and pushing back a vector of functions

You shouldn’t be using typedef here. That means you are aliasing those types to the names you specify, not creating instances of them. You should do this instead: //create a vector of functions which take no arguments and return an int std::vector<std::function<int()>> functionvector {}; //implicitly converts the function pointer to a std::function<int()> and pushes functionvector.push_back(function1); … Read more

[Solved] How to input integer numbers with space in between

int x; while(cin>>x) { store the number one by one } //process Simply do it this way. Store the numbers in the array. Or you can do it this way- string s; getline(cin,s); std::stringstream myss; myss<<s; std::string t; int x; std::vector<int> v; while(std::getline(myss,t,’ ‘)) { if(std::stringstream(t)>>x) { // store x in an vector. v.push_back(x); } … Read more

[Solved] trying to get an absolute positioned div to center within another relative positioned div

You need to check the height and width of the element you’re centering on and set the top and left accordingly. $(‘.labelEdit’).click( function() { var x = $(“#editDialog”).width() / 2 – $(“#editItemDialog”).outerWidth() / 2; var y = $(“#editDialog”).height() / 2 – $(“#editItemDialog”).outerHeight() / 2; $(“#editItemDialog”).css({“top”: y, “left”: x}); $(‘#editItemDialog’).show(‘slow’); }); Basically, we’re setting the top … Read more

[Solved] How to track down the cause of “syntax error: missing ‘)’ before identifier” and others? [closed]

Alternatively to what’s suggested here, you fix the problem in the header file without actually moving the definition of PCLIENT into the header: … struct _client; … // Accept Client. BOOL AcceptClient(struct _client* current_client); … // Receive data from client. BOOL recv_data(struct _client* current_client, char *buffer, int size); … // Send data. BOOL send_data(struct _client* … Read more

[Solved] Hide/visible app mode in iphone [closed]

There are two possibilities for this: 1) When reactivated, the method applicationDidBecomeActive: in your application delegate will be called. Note that this will also be called when the app is being started for the first time. 2) An UIApplicationDidBecomeActiveNotification is being posted to the notification center. Objects (views) that need to react to that may … Read more

[Solved] How to get number of weeks by month in year?

As already mentioned NSCalendar has a method rangeOfUnit:inUnit:forDate:. The proper calendar units are CalendarUnitWeekOfYear and CalendarUnitMonth The result might be different for the locale and first weekday of the week settings. let calendar = NSCalendar.currentCalendar() let weekRange = calendar.rangeOfUnit(NSCalendarUnit.CalendarUnitWeekOfYear, inUnit: .CalendarUnitMonth, forDate: NSDate()) let weekArray = Array(weekRange.location..<weekRange.location + weekRange.length) Swift 3: let calendar = Calendar.current … Read more

[Solved] Adding to a mySQL database [closed]

Here’s the tutorial from me so that you can able to post it with this code or even you try to modify this code based on your needs. Here’s the code created on php code. THE HTML CODE <select name=”KODECITIES”> <option value=0 selected>- CITIES Code -</option> <?php $con = mysql_connect(“localhost”,”root”,””); if (!$con) { die(‘Could not … Read more

[Solved] How to map an object as per key and value using JavaScript?

You could take an array for the wanted groups and related keys and take an iterative and recursive approach. var data = [{ _id: “5c407834953d7f420d56f866”, allocated_to: “FIELD”, zone: “NORTH”, state: “DELHI”, location: “NEW DELHI”, customer_name: “REET INFOTECH”, bank_name_of_customer: “YES BANK”, cl_contract_id: “LAI-00016881”, lk_loan_account_id: “LK0000015094”, front_end_manager_name: “SONAL”, area_collection_manager: “ASHIS JENA”, installment_date: “”, collection_manager: “” }, { … Read more

[Solved] PHP exception custom message

The “fatal error” part is generated because the exception is thrown outside a try-catch statement, and is finally caught by the php error handler. Uncaught exceptions are always fatal. Try surrounding the code that generates the exception with a try-catch statement like: try{ $foo->bar(); catch(UserException $ex){ // Do something with the exception. } Alternately you … Read more

[Solved] Fetch teacher and subject wise details in mysql and php

Why don’t you combine both into a single SQL? SQL query to fetch the details of each teacher in a searched institute and their subject strength where institute is equal to searched institue. Show only that teacher details which is not having strength of 25 students in each subject where institue is equal to searched … Read more

[Solved] sed parsing xml file1 index file2

the awk line should work for u: awk ‘FNR==NR{if(NR%2)i=$0;else a[i]=$0;next;}{if($0 in a){print; print a[$0]}else print}’ file2 file1 EDIT here I see no EXTRA lines. see the test. (maybe your example data format is not same as your real data.). however I have shown the way, how to do it. you can change the awk oneliner … Read more

[Solved] Check input numbers in prolog

Since you tried something for your isDigit/1 predicate I’ll help about that : Version with an if structure : isDigit(X) :- ( number(X), X >= 0, X =< 8 -> true ; writeln(‘[0-8] AND Number’), fail). Version with a disjunction (as you tried in your OP) : isDigit(X) :- number(X), X >= 0, X =< … Read more

[Solved] Building a menu in Android [closed]

This is a sample code I made. all of them are buttons in xml public class MenuActivity extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); } @Override // My menu inflater public boolean onCreateOptionsMenu(Menu menu) { new MenuInflater(this).inflate(R.menu.menu, menu); return (super.onCreateOptionsMenu(menu)); } // code for the actions that it … Read more